-
-
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
cc-wrapper: Account for NIX_LDFLAGS and NIX_CFLAGS_LINK in linkType #253116
Conversation
Without this, pkgsStatic.pkgsLLVM.hello fails with segfaulting binaries because of the issue described at [0]. In summary, llvm's linker has a different behaviour to GCC's when supplied with both -static and -Wl,-dynamic-linker=...; GCC copes with it, but LLVM produces a binary which segfaults on startup. It appears to be necessary to omit the dynamic linker in this case. nixpkgs' static adaptor passes -static via NIX_CFLAGS_LINK which was not accounted for prior to this commit in the checkLinkType logic. For good measure I put the other NIX_ flags affecting link in the same logic. Additionally, $NIX_CFLAGS_LINK_@suffixSalt@ is not available until later than it was originally set, so set $linkType close to its point of use. I checked for earlier uses by studying the shell trace output and couldn't find any. [0] NixOS#111010 (comment) Signed-off-by: Peter Waller <[email protected]>
cc @rrbutani for when you're back. |
Ping @rrbutani and others, can we progress this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkgsStatic.pkgsLLVM.bash
built and launched
There were errors like this, but they were there before too so not a regression.
bash> x86_64-unknown-linux-musl-ld: error: undefined symbol: termsig_handler
bash> >>> referenced by head.c:146
bash> >>> head.o:(head_builtin)
bash> >>> referenced by head.c:82
bash> >>> head.o:(file_head)
bash> >>> referenced by head.c:88
bash> >>> head.o:(file_head)
bash> x86_64-unknown-linux-musl-ld: error: undefined symbol: interrupt_state
bash> >>> referenced by head.c:146
bash> >>> head.o:(head_builtin)
bash> >>> referenced by head.c:0
bash> >>> head.o:(file_head)
bash> x86_64-unknown-linux-musl-ld: error: undefined symbol: throw_to_top_level
bash> >>> referenced by head.c:146
bash> >>> head.o:(head_builtin)
bash> >>> referenced by head.c:82
bash> >>> head.o:(file_head)
bash> >>> referenced by head.c:88
bash> >>> head.o:(file_head)
bash> x86_64-unknown-linux-musl-ld: error: undefined symbol: builtin_help
bash> >>> referenced by head.c:122
bash> >>> head.o:(head_builtin)
bash> x86_64-unknown-linux-musl-ld: error: undefined symbol: builtin_usage
bash> >>> referenced by head.c:124
bash> >>> head.o:(head_builtin)
bash> clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
bash> make[1]: *** [Makefile:169: tty] Error 1
bash> clang-11: make[1]: *** [Makefile:175: tee] Error 1
bash> error: linker command failed with exit code 1 (use -v to see invocation)
Probably something to do with the shared flag
bash> x86_64-unknown-linux-musl-clang -shared -Wl,-soname,head -o head head.o
In case anybody ends up bisecting to here, your problem might be #269429, which was not caused by this PR, just made more prominent by it. |
Description of changes
Without this, pkgsStatic.pkgsLLVM.hello fails with segfaulting binaries
because of the issue described at [0].
In summary, llvm's linker has a different behaviour to GCC's when
supplied with both -static and -Wl,-dynamic-linker=...; GCC copes with
it, but LLVM produces a binary which segfaults on startup. It appears to
be necessary to omit the dynamic linker in this case.
nixpkgs' static adaptor passes -static via NIX_CFLAGS_LINK which was not
accounted for prior to this commit in the checkLinkType logic. For good
measure I put the other NIX_ flags affecting link in the same logic.
Additionally, $NIX_CFLAGS_LINK_@suffixSalt@ is not available until later
than it was originally set, so set $linkType close to its point of use.
I checked for earlier uses by studying the shell trace output and
couldn't find any.
[0] #111010 (comment)
Signed-off-by: Peter Waller [email protected]
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)