Open Lassulus opened 5 years ago
I suspect it's some bogus linker script. For instance this works fine:
{ pkgs }: let
hello_c = pkgs.writeText "hello.c" ''
int main() {
return 0;
}
'';
in pkgs.stdenv.mkDerivation {
name = "test";
buildInputs = with pkgs; [ glibc glibc.static ];
phases = [ "buildPhase" ];
buildPhase = ''
gcc ${hello_c} -o $out
'';
}
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Hello,
Almost three years later, I've encountered this issue. Here's one small additional detail: I noticed the above derivation works, but it doesn't if we swap glibc
and glibc.static
like so
in pkgs.stdenv.mkDerivation {
// ...
buildInputs = with pkgs; [ glibc.static glibc ];
// ...
}```
Since it is recommended by the bot, I'm pinging @edolstra and @Ma27
@Guekka, I'm afraid the "ping" didn't work, because it's inside the code section :)
@Guekka, I'm afraid the "ping" didn't work, because it's inside the code section :)
Oh, good catch. Thanks! Moving it here:
Since it is recommended by the bot, I'm pinging @edolstra and @Ma27
I have encountered the same issue while working on TLS general dynamic model in Zig's zld linker. It seems that with glibc.static
the linker ends up receiving both static and dynamic version of glibc resulting in link errors (if you're lucky), or worse, in loader errors.
Same issue here. The difference between [ glibc.static glibc ]
and [glibc glibc.static]
cause the order of -L/nix/store/*/lib
reversed. It's euqal to below:
$ gcc check.c -o check -L/nix/store/{glibc_path}/lib -L/nix/store/${glibc_static_path}/lib
$ ./check
$ gcc check.c -o check -L/nix/store/${glibc_static_path}/lib -L/nix/store/{glibc_path}/lib
$ ./check
[1] 847400 segmentation fault ./check
However, same error occur when I just leave glibc.static alone,:
$ gcc check.c -o check -L/nix/store/${glibc_static_path}/lib
$ ./check
[1] 847559 segmentation fault ./check
Issue description
having
glibc.static
in buildInputs produces broken binaries if gcc is called without -static calling the binary results in a segfault:Steps to reproduce
Technical details
"x86_64-linux"
Linux 4.19.34, stockholm/NixOS, 19.04.git.2dbdf0185-dirty@mors/19.03.git.67bc63f (Koi)
yes
yes
nix-env (Nix) 2.2
""
""
/var/src/nixpkgs