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

Fix import lib generation under MinGW #438

Merged
merged 2 commits into from
Jan 12, 2025

Conversation

kleisauke
Copy link
Contributor

Override import_name after parsing the .def file, as -Wl,--output-def, in LLVM and Binutils does not include a library name in the generated .def file.

cargo-c/src/target.rs

Lines 112 to 118 in c37aec4

} else if os == "windows" && env == "gnu" {
// This is only set up to work on GNU toolchain versions of Rust
lines.push(format!(
"-Wl,--output-def,{}",
target_dir.join(format!("{lib_name}.def")).display()
));
}

https://github.com/llvm/llvm-project/blob/llvmorg-19.1.6/lld/COFF/MinGW.cpp#L173-L192
https://github.com/bminor/binutils-gdb/blob/binutils-2_43_1/binutils/dlltool.c#L1813-L1872

Also bump implib while we are here, to ensure the import library works when targeting i686-pc-windows-gnu{,llvm}.

@sdroege
Copy link
Contributor

sdroege commented Jan 12, 2025

CC @amyspark

@lu-zero lu-zero merged commit 851aab5 into lu-zero:master Jan 12, 2025
17 checks passed
@kleisauke kleisauke deleted the fix-import-lib-mingw branch January 13, 2025 09:13
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

Successfully merging this pull request may close these issues.

4 participants