New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customize the MinGW-w64 dlltool
program name
#28
Comments
It's interesting, how does rustc itself know it has to use Instead of adding an new environment variable tweak, I'd rather try to find out what tool prefix rustc is using for the target and use that. I just have no idea where to start... |
Oh, for the linking, I did have to override that using the FROM quay.io/fedora/fedora:37
RUN dnf install -y gcc ucrt64-gcc ucrt64-winpthreads-static
RUN curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --target x86_64-pc-windows-gnu
WORKDIR /root
RUN python3 -m venv --upgrade-deps venv
ENV PATH="/root/.cargo/bin:/root/venv/bin:${PATH}"
RUN pip install maturin
RUN maturin new -b pyo3 ucrt-test
WORKDIR /root/ucrt-test
RUN cargo add pyo3@0.16.5 -F abi3-py38,generate-import-lib
# To ensure python3-dll-a is downloaded before rewriting the dlltool constant
RUN cargo fetch
RUN sed -i -e 's/x86_64-w64-mingw32-dlltool/x86_64-w64-mingw32ucrt-dlltool/' "$HOME"/.cargo/registry/src/github.com-*/python3-dll-a-0.2.5/src/lib.rs
# Build the wheel
ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32ucrt-gcc
RUN maturin build --target x86_64-pc-windows-gnu
# Extract the .pyd file and verify that it doesn't use msvcrt.dll
RUN unzip target/wheels/ucrt_test-0.1.0-cp38-abi3-win_amd64.whl ucrt_test/ucrt_test.pyd
RUN mingw-objdump -p ucrt_test/ucrt_test.pyd | grep DLL Answering your question about the default linker name for the |
PyO3 can be updated to parse Maybe adding a new env variable like |
Allow users to override the default `dlltool` program name for MinGW-w64 targets. Fixes PyO3#28
Sorry for the wait, the fix was released as v0.2.6. Try setting |
Bump the minimum `python3-dll-a` dependency version. Document the implemented workaround for PyO3/python3-dll-a#28
Currently, the
dlltool
program from MinGW-w64 is set to a hard-coded constant (namely,x86_64-w64-mingw32-dlltool
for the 64-bit version). Would it be feasible to allow a custom name, such as by checking for an environment variable?The motivation here is that Fedora 37 will be adding support for the MinGW-w64 UCRT toolchain. Thus, the new
ucrt64-binutils
package has/usr/bin/x86_64-w64-mingw32ucrt-dlltool
.As a quick hack to check that it works, I replaced the constant and was able to successfully build a
.pyd
using the UCRT:(My first approach was to create a link from
/usr/bin/x86_64-w64-mingw32ucrt-dlltool
to/usr/bin/x86_64-w64-mingw32-dlltool
, but for some reason it doesn't work.)The text was updated successfully, but these errors were encountered: