-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Building static-linux-musl binary with clang: gcc_eh library not found #177129
Comments
I bisected this to this commit: c6dd11c
@alyssais do you know what might be causing this? |
Oh, according to this mailing list entry, this behavior is kind of expected (although it is quite old -- is this still the case?):
Which part of the nix cc toolchain adds the flag for libgcc_eh then? Maybe it is just not needed? \edit: It seems that clang itself is adding these flags for the linker, so it expects I work-around that problem currently by creating an empty |
Trying to use the llvm clang toolchain, targeting static musl, failed with: ``` /nix/store/fnw7g7s8z6wmaank060jpqppl0hiqbal-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: cannot find -lgcc_eh: No such file or directory clang-11: error: linker command failed with exit code 1 (use -v to see invocation) ``` See NixOS/nixpkgs#177129
Trying to use the llvm clang toolchain, targeting static musl, failed with: ``` /nix/store/fnw7g7s8z6wmaank060jpqppl0hiqbal-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: cannot find -lgcc_eh: No such file or directory clang-11: error: linker command failed with exit code 1 (use -v to see invocation) ``` See NixOS/nixpkgs#177129
I'm also gettting a problem related to this when trying to cross compile
|
BTW, there is an upstream bug for LLVM here. |
I just hit this. The nixpkgs clang derivation already patches the source to switch from |
It's added by the Clang driver: https://github.com/llvm/llvm-project/blob/135d92f903161e66ff82ab846acfbc5015ef3096/clang/lib/Driver/ToolChains/CommonArgs.cpp#L2055-L2066 It seems like we might want to patch this. |
This breaks Lix's nix-static, since it uses clang https://git.lix.systems/lix-project/lix/issues/527. |
I just hit this as well, while cross-compiling a static Rust package for
Strangely, I did not encounter the same issue for other platforms, only Windows MinGW 64 bit failed. @avdv could you explain your work-around? |
Basically I did the same as lix: just create an empty static archive called |
Awesome, it worked for me as well. Thank you! |
Describe the bug
After upgrading nixpkgs to 22.05 from 21.11, trying to build a simple hello world C program, using the
pkgsStatic.llvmPackages_11.stdenv
orpkgsStatic.llvmPackages.stdenv
orpkgsStatic.clangStdenv
results inSteps To Reproduce
Steps to reproduce the behavior:
nix build .
Expected behavior
I am able to build a static executable, based on musl, with clang.
Additional context
It seems like the gcc_eh.a library is indeed missing:
Removing the
-lgcc_eh
option from the linker flags and manually running the resulting command produces a valid executable. (but I suppose this only works since I am not using exceptions ?)Notify maintainers
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Note, I am using nix flake to configure my system:
The text was updated successfully, but these errors were encountered: