Skip to content

0.28 raw-dylib linking regressed MSYS2/MinGW (libpython3X.dll vs python3X.dll) #6157

Description

@ddelange

Summary

PyO3 0.28 (PR #5866) switched Windows linking to Rust's raw-dylib and hardcoded the imported DLL name as python3X.dll. This regressed MSYS2/MinGW (*-pc-windows-gnu) downstream builds, where the Python DLL is named libpython3X.dll (Unix-style lib prefix). Every Python C-API symbol now comes back undefined at link time.

This was already flagged by @ognevny on the merged PR but doesn't have a tracking issue:
#5866 (comment)

hi, this change seem to regress MINGW downstream builds, probably because we use libpython3.dll library (it uses the lib prefix like any other UNIX environment)

The previous escape hatch (generate-import-lib) is now a deprecated no-op per the 0.28 changelog, so downstreams have no way to opt out aside from pinning pyo3 = "0.27.x".

Downstream impact

Truncated link error from the failing log:

ld.exe: ...libpyo3-*.rlib: undefined reference to `PyUnicode_FromStringAndSize'
ld.exe: ...libpyo3-*.rlib: undefined reference to `Py_GenericAlias'
ld.exe: ...libpyo3-*.rlib: undefined reference to `PyDict_New'
... (many more)
collect2.exe: error: ld returned 1 exit status

Proposed direction

Emit the lib-prefixed DLL name in extern_python_dll! / the raw-dylib import on *-pc-windows-gnu targets when the Python install is the MSYS2-style one — or expose a build-script knob so downstreams can override the import name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions