Skip to content
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

Generate import library without external tools #20

Open
messense opened this issue May 18, 2022 · 5 comments
Open

Generate import library without external tools #20

messense opened this issue May 18, 2022 · 5 comments

Comments

@messense
Copy link
Member

messense commented May 18, 2022

I've take some time to port llvm-dlltool to Rust, implib-rs is a crate implements generating Windows import library from module definition file.

Unfortunately rust-ar doesn't support writing symbol table, so the currently it requires to run ranlib after generation to be useful. Thus it's not ready to be integrated in python3-dll-a right now. Hopefully someday we can find a solution to it.

I wonder how hard it is to port the mingw64 version, it'd be nice to support them both.


Update: implib crate now produces the exact same .lib file like llvm-dlltool and it works for linking with lld with the this python3-dll-a patch:

image

@ravenexp
Copy link
Collaborator

Please keep in mind that RFC 2627 is still being actively worked on, and when it hits stable it will make hacks like xwin or python3-dll-a obsolete.

@messense
Copy link
Member Author

messense commented May 19, 2022

Looks like the implementation of RFC 2627 does not support DATA: https://github.com/rust-lang/rust/blob/10913c00018c76103b2fd4260d8c02ec728fd244/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp#L1731 , will that be a problem for pyo3?

@ravenexp
Copy link
Collaborator

Yes, PyO3 uses quite a lot of DATA symbols for singletons like _Py_NoneStruct.

@messense
Copy link
Member Author

messense commented May 19, 2022

And to support multiple Python versions and abi3 in pyo3-ffi, the link attributes are tedious with lots of cfgs.

#[link(name = "python3.dll", kind = "raw-dylib")]
#[link(name = "python37.dll", kind = "raw-dylib")]
#[link(name = "python38.dll", kind = "raw-dylib")]
#[link(name = "python39.dll", kind = "raw-dylib")]
#[link(name = "python310.dll", kind = "raw-dylib")]
#[link(name = "python311.dll", kind = "raw-dylib")]

And this MINGW Python dll name thing is annoying too.

@ravenexp
Copy link
Collaborator

Yes, code like that is best generated by the build script or a macro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants