-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
ld.gold crashes or produces invalid executables when Musl is used as a libc #49071
Comments
ld.gold
crashes or produces invalid executables when Musl is used as a libc
Just for clarity, is this the error you get when compiling on plain x86?
|
Exactly. If you see the config.log it should show that the linker has
refused to link. Should also be able to reproduce in nix-shell.
…On Thu, 25 Oct 2018 at 13:44, Niklas Hambüchen ***@***.***> wrote:
Just for clarity, is this the error you get when compiling on plain x86?
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build -E 'let pkgs = (import <nixpkgs> {}).pkgsMusl; in pkgs.hello.overrideDerivation(_: {CFLAGS="-fuse-ld=gold";})'
these derivations will be built:
/nix/store/c7d5hz6ynzc6gyg69w2ja8jdx11537zl-hello-2.10.drv
these paths will be fetched (0.69 MiB download, 0.69 MiB unpacked):
/nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz
copying path '/nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz' from 'https://cache.nixos.org'...
building '/nix/store/c7d5hz6ynzc6gyg69w2ja8jdx11537zl-hello-2.10.drv'...
unpacking sources
unpacking source archive /nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz
source root is hello-2.10
setting SOURCE_DATE_EPOCH to timestamp 1416139241 of file hello-2.10/ChangeLog
patching sources
configuring
configure flags: --disable-dependency-tracking --prefix=/nix/store/wdl72bp6a41iiqv5ph37nwqbhx1sf825-hello-2.10
checking for a BSD-compatible install... /nix/store/bxwz6wdxr0lgj9c629azmxi35i68qrv2-coreutils-8.29/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /nix/store/bxwz6wdxr0lgj9c629azmxi35i68qrv2-coreutils-8.29/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/tmp/nix-build-hello-2.10.drv-0/hello-2.10':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
builder for '/nix/store/c7d5hz6ynzc6gyg69w2ja8jdx11537zl-hello-2.10.drv' failed with exit code 1
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#49071 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA00CyJD-lmz9ZrnbexYPzfSdMIAdTLNks5uoaQJgaJpZM4X4kDl>
.
|
I see, in
|
This is the same case that happens in my VM I think. If you try to compile
a simple C program inside the nix-shell of hello with -static-libgcc then
the produced executable should work, for some reason.
Its really curious that on my bare metal machine ld.gold just bails. I’ve
seen the gcc, binutils and musl derivations are the same on both machines
yet they behave differently.
Are you running it inside a VM?
…On Thu, 25 Oct 2018 at 13:51, Niklas Hambüchen ***@***.***> wrote:
I see, in config.log:
configure:4154: checking whether we are cross compiling
configure:4162: gcc -o conftest -fuse-ld=gold conftest.c >&5
configure:4166: $? = 0
configure:4173: ./conftest
./configure: line 4175: 14393 Segmentation fault ./conftest$ac_cv_exeext
configure:4177: $? = 139
configure:4184: error: in `/tmp/nix-build-hello-2.10.drv-0/hello-2.10':
configure:4186: error: cannot run C compiled programs.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#49071 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA00C7t2_w5o4zz8NUSI1WomtU60MZPAks5uoaW6gaJpZM4X4kDl>
.
|
No, I'm running on Nix on a standard Ubuntu 16.04 64-bit. |
Related resources:
Looking at
|
FWIW it seems to work with clang, which is curious:
As for using gold, may want to try something like: 37b2f59 Or otherwise ensuring our wrappers always know what linker to invoke. I don't think this is the problem, but something to consider for future gold usage once this is resolved :). |
The thread mentions building with
Which may be related? It's disabled on non-musl too, FWIW. |
Adding
Adding |
Also does anybody have an idea why
doesn't work (using |
Just asked @fpletz at NixCon, he said that hardening should only add flags, not remove them; @cleverca22 said that happens here: https://github.com/NixOS/nixpkgs/blob/62feeed1a5aaf23b8c0883ae0cc17cd913cdce56/pkgs/build-support/cc-wrapper/add-hardening.sh So not sure why |
With help of @cleverca22 and looking at nixpkgs/pkgs/build-support/cc-wrapper/add-hardening.sh Lines 47 to 52 in 62feeed
It seems you need to pass both
And indeed
works. |
I'd expect that
Contrary to expectations, this doesn't seem to add the pie flags. |
It works if you use overrideAttrs instead! \o/
…On Thu, 25 Oct 2018 07:30:03 -0700, Niklas Hambüchen ***@***.***> wrote:
I'd expect that `hardeningEnable = ["pie"];` should also work, but it doesn't:
```
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build -E 'let pkgs = (import <nixpkgs> {}).pkgsMusl; in pkgs.hello.overrideDerivation(_: {CFLAGS="-fuse-ld=gold"; hardeningEnable = ["pie"]; })'
```
Contrary to expectations, this doesn't seem to add the pie flags.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#49071 (comment) part: text/html
|
Oh right, this works!
@dtzWill Should we add something to the musl bits that detects if gold is used and passes pie accordingly? Also, I assume there should be some upstream gold bug filed somewhere? The musl thread didn't link any being filed. |
The command which worked for @nh2 : NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build -E 'let pkgs = (import <nixpkgs> {}).pkgsMusl; in pkgs.hello.overrideDerivation(_: {CFLAGS="-fuse-ld=gold -fPIE -pie";})' Failed in my machine :( Same error as always:
|
How about using overrideAttrs instead? Otherwise it didn't work for me
either.
Thisis probably due to the same sorts of things that make overrideAttrs
generally what you should use:
https://nixos.org/nixpkgs/manual/#sec-pkg-overrideAttrs (and warning at top
of following blurb about overrideDerivation).
Unfortunately I personally remember this is true for one of them, but never
which one is which. Luckily muscle memory usually gets it right as long as
I don't think about it too much haha.
…On Thu, Oct 25, 2018, 12:05 PM Alberto Valverde ***@***.***> wrote:
The command which worked for @nh2 <https://github.com/nh2> :
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build -E 'let pkgs = (import <nixpkgs> {}).pkgsMusl; in pkgs.hello.overrideDerivation(_: {CFLAGS="-fuse-ld=gold -fPIE -pie";})'
Failed in my machine :( Same error as always:
checking whether the C compiler works... no
configure: error: in `/build/hello-2.10':
configure: error: C compiler cannot create executables
See `config.log' for more details
builder for '/nix/store/g6m7i019af8p838ldzv4jlfxds40fw2g-hello-2.10.drv' failed with exit code 77
error: build of '/nix/store/g6m7i019af8p838ldzv4jlfxds40fw2g-hello-2.10.drv' failed
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#49071 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAx4si-ezr7zcBqzmca4l5NjTCIlH7jiks5uoe9wgaJpZM4X4kDl>
.
|
Didn't know about 3$ NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build -E 'let pkgs = (import <nixpkgs> {}).pkgsMusl; in pkgs.hello.overrideAttrs(_: {CFLAGS="-fuse-ld=gold -fPIE -pie";})'
these derivations will be built:
/nix/store/g6m7i019af8p838ldzv4jlfxds40fw2g-hello-2.10.drv
building '/nix/store/g6m7i019af8p838ldzv4jlfxds40fw2g-hello-2.10.drv'...
unpacking sources
unpacking source archive /nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz
source root is hello-2.10
setting SOURCE_DATE_EPOCH to timestamp 1416139241 of file hello-2.10/ChangeLog
patching sources
configuring
configure flags: --disable-dependency-tracking --prefix=/nix/store/rmwms3g2v6isnswxlm1w799vb82zfp24-hello-2.10
checking for a BSD-compatible install... /nix/store/bxwz6wdxr0lgj9c629azmxi35i68qrv2-coreutils-8.29/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /nix/store/bxwz6wdxr0lgj9c629azmxi35i68qrv2-coreutils-8.29/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/build/hello-2.10':
configure: error: C compiler cannot create executables
See `config.log' for more details
builder for '/nix/store/g6m7i019af8p838ldzv4jlfxds40fw2g-hello-2.10.drv' failed with exit code 77
error: build of '/nix/store/g6m7i019af8p838ldzv4jlfxds40fw2g-hello-2.10.drv' failed The other command which worked for you, with $ NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build -E 'let pkgs = (import <nixpkgs> {}).pkgsMusl; in pkgs.hello.overrideAttrs(_: {CFLAGS="-fuse-ld=gold"; hardeningEnable = ["pie"]; })'
these derivations will be built:
/nix/store/qllg7c478rnba15rzh73va3adlw88zhk-hello-2.10.drv
building '/nix/store/qllg7c478rnba15rzh73va3adlw88zhk-hello-2.10.drv'...
unpacking sources
unpacking source archive /nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz
source root is hello-2.10
setting SOURCE_DATE_EPOCH to timestamp 1416139241 of file hello-2.10/ChangeLog
patching sources
configuring
configure flags: --disable-dependency-tracking --prefix=/nix/store/2k3lazi3vkm73gm033dxnlc8svasnzid-hello-2.10
checking for a BSD-compatible install... /nix/store/bxwz6wdxr0lgj9c629azmxi35i68qrv2-coreutils-8.29/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /nix/store/bxwz6wdxr0lgj9c629azmxi35i68qrv2-coreutils-8.29/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/build/hello-2.10':
configure: error: C compiler cannot create executables
See `config.log' for more details
builder for '/nix/store/qllg7c478rnba15rzh73va3adlw88zhk-hello-2.10.drv' failed with exit code 77
error: build of '/nix/store/qllg7c478rnba15rzh73va3adlw88zhk-hello-2.10.drv' failed My computer must be cursed :( |
Is this now also a plain x86_64 machine or something else? |
Yes, it's a plain x86_64 machine running Nixos on bare hardware. |
For the record, inside a nixos VM in a laptop, passing I can't understand the discrepancies between machines, both are
I'll try to run it on other machines today to see if I can spot a pattern |
This is
|
That is pretty odd. Perhaps comparing the full |
@nh2 I will try that and post the diff if different. I meanwhile tried to compile using clang 6 with: NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build -E 'with (import <nixpkgs> {}).pkgsMusl; (pkgs.hello.override { inherit (llvmPackages_6) stdenv; }).overrideAttrs (o:{ CFLAGS="-fuse-ld=gold"; NIX_DEBUG=1;})' but llvm fails to build since the gold tests fail with a very similar error:
|
I've compared the NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build -E 'let pkgs = (import <nixpkgs> {}).pkgsMusl; in pkgs.hello.overrideAttrs(_: {NIX_DEBUG="1"; CFLAGS="-fuse-ld=gold -Wl,--debug=all"; hardeningEnable = ["pie"]; postInstall="exit -1";})' -K (the If I understand it correctly, the "broken" The beginning of the diff looks like this: --- hello-config-bad.log 2018-10-28 21:27:33.391979234 +0100
+++ hello-config-good.log 2018-10-28 21:22:29.845499594 +0100
@@ -12,9 +12,9 @@
hostname = localhost
uname -m = x86_64
-uname -r = 4.14.78
+uname -r = 4.14.76
uname -s = Linux
-uname -v = #1-NixOS SMP Sat Oct 20 07:48:54 UTC 2018
+uname -v = #1-NixOS SMP Sat Oct 13 07:27:30 UTC 2018
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
@@ -188,7 +188,7 @@
-plugin
/nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/libexec/gcc/x86_64-unknown-linux-musl/7.3.0/liblto_plugin.so
-plugin-opt=/nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/libexec/gcc/x86_64-unknown-linux-musl/7.3.0/lto-wrapper
- -plugin-opt=-fresolution=/build/cciodIpK.res
+ -plugin-opt=-fresolution=/build/ccbNLFDA.res
-plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lc
@@ -214,7 +214,7 @@
-dynamic-linker
/nix/store/35mb6imifzx9316y7nknhh6apx1k7a24-musl-1.1.19/lib/ld-musl-x86_64.so.1
--debug=all
- /build/cceIfKHc.o
+ /build/ccnaDnPl.o
-rpath
/nix/store/xsngrd6w0r2aaqc3fdzyi16a4hpndwa2-hello-2.10/lib64
-rpath
@@ -279,14 +279,14 @@
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Read_symbols /nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/crtbeginS.o (user: 0.000000 sys: 0.000000 wall: 0.000000)
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 running task Add_symbols /nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/crtbeginS.o
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Add_symbols /nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/crtbeginS.o (user: 0.000000 sys: 0.000000 wall: 0.000000)
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 running task Read_symbols /build/cceIfKHc.o
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Opened new descriptor 9 for "/build/cceIfKHc.o"
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Attempt to open /build/cceIfKHc.o succeeded
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Unlocking file "/build/cceIfKHc.o"
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Released descriptor 9 for "/build/cceIfKHc.o"
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Read_symbols /build/cceIfKHc.o (user: 0.000000 sys: 0.000000 wall: 0.000000)
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 running task Add_symbols /build/cceIfKHc.o
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Add_symbols /build/cceIfKHc.o (user: 0.000000 sys: 0.000000 wall: 0.000000)
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 running task Read_symbols /build/ccnaDnPl.o
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Opened new descriptor 9 for "/build/ccnaDnPl.o"
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Attempt to open /build/ccnaDnPl.o succeeded
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Unlocking file "/build/ccnaDnPl.o"
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Released descriptor 9 for "/build/ccnaDnPl.o"
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Read_symbols /build/ccnaDnPl.o (user: 0.000000 sys: 0.000000 wall: 0.000000)
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 running task Add_symbols /build/ccnaDnPl.o
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Add_symbols /build/ccnaDnPl.o (user: 0.000000 sys: 0.000000 wall: 0.000000)
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 running task Read_symbols /nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/crtendS.o
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Opened new descriptor 10 for "/nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/crtendS.o"
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Attempt to open /nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/crtendS.o succeeded
@@ -388,7 +388,25677 @@
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Attempt to open /nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/libgcc.a succeeded
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Unlocking file "/nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/libgcc.a"
/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Released descriptor 11 for "/nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/libgcc.a"
-/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Read_symbols -lgcc (user: 0.000000 sys: 0.010000 wall: 0.000000)
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Read_symbols -lgcc (user: 0.000000 sys: 0.000000 wall: 0.000000)
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 running task Add_archive_symbols /nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/libgcc.a
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 completed task Add_archive_symbols /nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/libgcc.a (user: 0.000000 sys: 0.000000 wall: 0.000000)
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: 0 running task Read_symbols -lgcc_s
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Attempt to open /nix/store/35mb6imifzx9316y7nknhh6apx1k7a24-musl-1.1.19/lib/libgcc_s.so failed
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Attempt to open /nix/store/35mb6imifzx9316y7nknhh6apx1k7a24-musl-1.1.19/lib/libgcc_s.a failed
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Closed descriptor 11 for "/nix/store/4k79vw3p32n2w7z11d9rh4788chq73ja-gcc-7.3.0/lib/gcc/x86_64-unknown-linux-musl/7.3.0/libgcc.a"
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Opened new descriptor 12 for "/nix/store/4dw6k7sdkw8r2b5rgka8r659451l3xx9-gcc-7.3.0-lib/lib/libgcc_s.so"
+/nix/store/8jpp32r1yqzqcgjycnvjy0hm30ng2f86-binutils-2.30/bin/ld.gold: Attempt to open /nix/store/4dw6k7sdkw8r2b5rgka8r659451l3xx9-gcc-7.3.0-lib/lib/libgcc_s.so succeeded |
"pie" hardening is not enabled by default. Maybe it should be? |
@matthewbauer The way I read the links is that gold for unknown reasons (likely a bug) doesn't work with musl unless Perhaps it should be enabled by default for this combination (gold + musl)? |
Yeah sounds like a good idea. We don't know whether you will use ld.gold ahead of time, so better to just do it with musl everywhere. |
Fixes NixOS#49071 On ld.gold, we produce broken executables when linking with the Musl libc. This appears to be a known bug when using ld.gold and Musl. This thread describes the workaround as enabling PIE when using ld.gold and Musl: https://www.openwall.com/lists/musl/2015/05/01/5 By default we don’t enable PIE to avoid breaking things. But in the Musl case we are breaking things by not enabling PIE. So this adds a special case for defaultHardeningFlags which keeps the pie hardening for everything. Any packages that break with PIE can add the pie flag to disableHardeningFlags array (a no-op for now on anything but Musl).
I've filed an upstream issue for gold at https://sourceware.org/bugzilla/show_bug.cgi?id=23856 I recommend everyone involved subscribing to it. |
Fixes #49071 On ld.gold, we produce broken executables when linking with the Musl libc. This appears to be a known bug when using ld.gold and Musl. This thread describes the workaround as enabling PIE when using ld.gold and Musl: https://www.openwall.com/lists/musl/2015/05/01/5 By default we don’t enable PIE to avoid breaking things. But in the Musl case we are breaking things by not enabling PIE. So this adds a special case for defaultHardeningFlags which keeps the pie hardening for everything. Any packages that break with PIE can add the pie flag to disableHardeningFlags array (a no-op for now on anything but Musl).
ld.gold doesn't play well with musl as is documented in NixOS#49071 and https://sourceware.org/bugzilla/show_bug.cgi?id=23856
ld.gold doesn't play well with musl as is documented in #49071 and https://sourceware.org/bugzilla/show_bug.cgi?id=23856
ld.gold doesn't play well with musl as is documented in NixOS#49071 and https://sourceware.org/bugzilla/show_bug.cgi?id=23856 (cherry picked from commit 4675649)
ld.gold doesn't play well with musl as is documented in NixOS#49071 and https://sourceware.org/bugzilla/show_bug.cgi?id=23856 (cherry picked from commit 4675649)
Issue description
ld.gold
crashes or produces invalid executables when using the musl libc. This prevents the use of musl and GHC onarmv7l
(where it also manifests itself) since GHC requiresld.gold
on that platform to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177This also affects
lld
from LLVM 4 apparentlySteps to reproduce
nix-build -E 'let pkgs = (import <nixpkgs> {}).pkgsMusl; in pkgs.hello.overrideDerivation(_: {CFLAGS="-fuse-ld=gold";})'
The above command either fails (on a bare-metal x86_64 system) or produces an executable which segfaults at start (on a x86_64 system running on VM in a laptop). Interestingly, if one passes
-static_libgcc
the produced executable is apparently correct inside the VM but also fails to be created on the bare-metal machine.Technical details
The above system is the desktop bare-metal one
The text was updated successfully, but these errors were encountered: