Skip to content

bintools-wrapper: skip dynamic linker for static binaries#107596

Merged
Mic92 merged 1 commit intoNixOS:stagingfrom
Mic92:fix-static-pie-take2
Dec 30, 2020
Merged

bintools-wrapper: skip dynamic linker for static binaries#107596
Mic92 merged 1 commit intoNixOS:stagingfrom
Mic92:fix-static-pie-take2

Conversation

@Mic92
Copy link
Member

@Mic92 Mic92 commented Dec 25, 2020

Motivation for this change

Revised version of #106908

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now checks if a linker is present for the selected cc-wrapper. This was not the case before and broke darwin.

@Mic92
Copy link
Member Author

Mic92 commented Dec 25, 2020

@dasJ could you build nix-build -A tests.cc-wrapper -A tests.cc-wrapper-clang on macos from this commit?

@dasJ
Copy link
Member

dasJ commented Dec 25, 2020

building '/nix/store/dw92gm1zc22mcn43grbpy6bdc8a84aza-Csu-osx-10.11.6.drv'...
unpacking sources
unpacking source archive /nix/store/5bdnlv9gsq6rcx22qcdq4drnlsf8vfpk-Csu-85.tar.gz
source root is Csu-85
setting SOURCE_DATE_EPOCH to timestamp 1381273907 of file Csu-85/start.s
patching sources
configuring
no configure script, doing nothing
building
build flags: -j8 -l8 SHELL=/nix/store/x9mh477dvw0929zgbpkvpxqy4ifdh5qj-bootstrap-tools/bin/bash
Makefile:153: target '/lib' given more than once in the same rule
cc  -r  -Os -mmacosx-version-min=10.6 -mdynamic-no-pic -nostdlib -keep_private_externs start.s crt.c dyld_glue.s -o crt1.v1.o  -DCRT -DOLD_LIBSYSTEM_SUPPORT
cc  -r  -Os -mmacosx-version-min=10.6 -nostdlib -keep_private_externs start.s crt.c dyld_glue.s -o crt1.v2.o  -DCRT
cc  -r  -Os -mmacosx-version-min=10.6 -nostdlib -keep_private_externs start.s crt.c -o crt1.v3.o  -DADD_PROGRAM_VARS
cc  -r  -Os -mmacosx-version-min=10.6 -nostdlib -keep_private_externs start.s crt.c -o crt1.v4.o  -DADD_PROGRAM_VARS
cc  -r  -Os -mmacosx-version-min=10.6 -nostdlib -keep_private_externs start.s crt.c dyld_glue.s -o gcrt1.o  -DGCRT  -DOLD_LIBSYSTEM_SUPPORT
cc  -r  -Os -static -Wl,-new_linker -nostdlib -keep_private_externs start.s crt.c -o crt0.o
cc  -r  -Os -mmacosx-version-min=10.6  -nostdlib -keep_private_externs dyld_glue.s icplusplus.c -o dylib1.v1.o  -DCFM_GLUE
cc  -r  -Os -mmacosx-version-min=10.6  -nostdlib -keep_private_externs dyld_glue.s -o dylib1.v2.o  -DCFM_GLUE
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
clang-7clang-7clang-7: : clang-7: : clang-7errorerror: errorerror: : : : error: linker command failed with exit code 1 (use -v to see invocation)
linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation)

linker command failed with exit code 1 (use -v to see invocation)

clang-7clang-7: : errorerror: : linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation)

make: *** [Makefile:95: dylib1.v2.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [Makefile:81: crt1.v4.o] Error 1
make: *** [Makefile:92: dylib1.v1.o] Error 1
make: *** [Makefile:75: crt1.v2.o] Error 1
make: *** [Makefile:84: gcrt1.o] Error 1
make: *** [Makefile:72: crt1.v1.o] Error 1
make: *** [Makefile:78: crt1.v3.o] Error 1
builder for '/nix/store/dw92gm1zc22mcn43grbpy6bdc8a84aza-Csu-osx-10.11.6.drv' failed with exit code 2
building '/nix/store/i3dy62d7lkq4q7y9h1qfan3wmfripk1g-ICU-osx-10.10.5.drv'...
cannot build derivation '/nix/store/55147vsyg0yn4r9ihslq1iivnlsgwhxg-Libsystem-osx-10.12.6.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/5i0mk08mpbyxmx3w1ihbkyqkpzv2farz-binutils-wrapper-2.31.1.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/72qlykisycs8k1ijbkjgdqkn3vy30v8z-bootstrap-stage0-clang-wrapper-7.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/7i75jzy70kna2w64mxfcn5mxmllz65qb-bootstrap-stage0-clang-wrapper-7.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/pz8rzm7pc5736rjm94rgwd9g4bh0jkij-bootstrap-stage2-stdenv-darwin.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/qzj31ki0xjssjx3vdwz9qq3lzf265ckw-bootstrap-stage2-stdenv-darwin.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/0ykdcjc9rs4c1v704i9zdfhy89dcqf2h-bootstrap-stage3-stdenv-darwin.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/9j9sabnb199hv8zzl2qn940r3h43ivrl-bootstrap-stage3-stdenv-darwin.drv': 1 dependencies couldn't be built
building '/nix/store/51ypnbfgkzavfxb7vy1zrm5vvwbdmss0-c-ares-1.17.1.drv'...
cannot build derivation '/nix/store/8c83x986by46g1zcnaddn618yrlk9p0a-clang-wrapper-7.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/if61idhrb1qyrrs6178n5pn3lhhgn03h-clang-wrapper-7.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/0pddc1klap22v7ry13jkk65vih3gg7k5-perl-5.32.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/5pyqwhz45k89jwk80hpywx3g9sr5xiz3-stdenv-darwin.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/2wsmcf7xdcd5wv39xvlkpd2736nd6w77-bash-4.4-p23.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/s7n5dm941pcfs1d50hjxr6kck4j4fr9d-cc-wrapper-test.drv': 1 dependencies couldn't be built
error: build of '/nix/store/bw2221k52bn5qivb7kv5wgyvq82a9zps-cc-wrapper-test.drv', '/nix/store/s7n5dm941pcfs1d50hjxr6kck4j4fr9d-cc-wrapper-test.drv' failed
[1]    11276 exit 100   nix-build -A tests.cc-wrapper -A tests.cc-wrapper-clang

@SuperSandro2000
Copy link
Member

building '/nix/store/dw92gm1zc22mcn43grbpy6bdc8a84aza-Csu-osx-10.11.6.drv'...
unpacking sources
unpacking source archive /nix/store/5bdnlv9gsq6rcx22qcdq4drnlsf8vfpk-Csu-85.tar.gz
source root is Csu-85
setting SOURCE_DATE_EPOCH to timestamp 1381273907 of file Csu-85/start.s
patching sources
configuring
no configure script, doing nothing
building
build flags: -j8 -l8 SHELL=/nix/store/x9mh477dvw0929zgbpkvpxqy4ifdh5qj-bootstrap-tools/bin/bash
Makefile:153: target '/lib' given more than once in the same rule
cc  -r  -Os -mmacosx-version-min=10.6 -mdynamic-no-pic -nostdlib -keep_private_externs start.s crt.c dyld_glue.s -o crt1.v1.o  -DCRT -DOLD_LIBSYSTEM_SUPPORT
cc  -r  -Os -mmacosx-version-min=10.6 -nostdlib -keep_private_externs start.s crt.c dyld_glue.s -o crt1.v2.o  -DCRT
cc  -r  -Os -mmacosx-version-min=10.6 -nostdlib -keep_private_externs start.s crt.c -o crt1.v3.o  -DADD_PROGRAM_VARS
cc  -r  -Os -mmacosx-version-min=10.6 -nostdlib -keep_private_externs start.s crt.c -o crt1.v4.o  -DADD_PROGRAM_VARS
cc  -r  -Os -mmacosx-version-min=10.6 -nostdlib -keep_private_externs start.s crt.c dyld_glue.s -o gcrt1.o  -DGCRT  -DOLD_LIBSYSTEM_SUPPORT
cc  -r  -Os -static -Wl,-new_linker -nostdlib -keep_private_externs start.s crt.c -o crt0.o
cc  -r  -Os -mmacosx-version-min=10.6  -nostdlib -keep_private_externs dyld_glue.s icplusplus.c -o dylib1.v1.o  -DCFM_GLUE
cc  -r  -Os -mmacosx-version-min=10.6  -nostdlib -keep_private_externs dyld_glue.s -o dylib1.v2.o  -DCFM_GLUE
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
ld: unknown option: -dynamic-linker=/usr/lib/dyld
clang-7clang-7clang-7: : clang-7: : clang-7errorerror: errorerror: : : : error: linker command failed with exit code 1 (use -v to see invocation)
linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation)

linker command failed with exit code 1 (use -v to see invocation)

clang-7clang-7: : errorerror: : linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation)

make: *** [Makefile:95: dylib1.v2.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [Makefile:81: crt1.v4.o] Error 1
make: *** [Makefile:92: dylib1.v1.o] Error 1
make: *** [Makefile:75: crt1.v2.o] Error 1
make: *** [Makefile:84: gcrt1.o] Error 1
make: *** [Makefile:72: crt1.v1.o] Error 1
make: *** [Makefile:78: crt1.v3.o] Error 1
builder for '/nix/store/dw92gm1zc22mcn43grbpy6bdc8a84aza-Csu-osx-10.11.6.drv' failed with exit code 2
building '/nix/store/i3dy62d7lkq4q7y9h1qfan3wmfripk1g-ICU-osx-10.10.5.drv'...
cannot build derivation '/nix/store/55147vsyg0yn4r9ihslq1iivnlsgwhxg-Libsystem-osx-10.12.6.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/5i0mk08mpbyxmx3w1ihbkyqkpzv2farz-binutils-wrapper-2.31.1.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/72qlykisycs8k1ijbkjgdqkn3vy30v8z-bootstrap-stage0-clang-wrapper-7.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/7i75jzy70kna2w64mxfcn5mxmllz65qb-bootstrap-stage0-clang-wrapper-7.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/pz8rzm7pc5736rjm94rgwd9g4bh0jkij-bootstrap-stage2-stdenv-darwin.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/qzj31ki0xjssjx3vdwz9qq3lzf265ckw-bootstrap-stage2-stdenv-darwin.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/0ykdcjc9rs4c1v704i9zdfhy89dcqf2h-bootstrap-stage3-stdenv-darwin.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/9j9sabnb199hv8zzl2qn940r3h43ivrl-bootstrap-stage3-stdenv-darwin.drv': 1 dependencies couldn't be built
building '/nix/store/51ypnbfgkzavfxb7vy1zrm5vvwbdmss0-c-ares-1.17.1.drv'...
cannot build derivation '/nix/store/8c83x986by46g1zcnaddn618yrlk9p0a-clang-wrapper-7.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/if61idhrb1qyrrs6178n5pn3lhhgn03h-clang-wrapper-7.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/0pddc1klap22v7ry13jkk65vih3gg7k5-perl-5.32.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/5pyqwhz45k89jwk80hpywx3g9sr5xiz3-stdenv-darwin.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/2wsmcf7xdcd5wv39xvlkpd2736nd6w77-bash-4.4-p23.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/s7n5dm941pcfs1d50hjxr6kck4j4fr9d-cc-wrapper-test.drv': 1 dependencies couldn't be built
error: build of '/nix/store/bw2221k52bn5qivb7kv5wgyvq82a9zps-cc-wrapper-test.drv', '/nix/store/s7n5dm941pcfs1d50hjxr6kck4j4fr9d-cc-wrapper-test.drv' failed
[1]    11276 exit 100   nix-build -A tests.cc-wrapper -A tests.cc-wrapper-clang

👍🏼

@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. labels Dec 25, 2020
@ofborg ofborg bot requested review from Ericson2314 and matthewbauer December 25, 2020 22:36
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Dec 25, 2020
@Mic92 Mic92 force-pushed the fix-static-pie-take2 branch 2 times, most recently from f348af4 to 6f452b2 Compare December 26, 2020 09:04
@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Dec 26, 2020

ryazs91-xnu-osx-10.12.6/include /private/var/folders/r4/k85s52jx3555ckj0wty615s00000gp/T/nix-build-xnu-osx-10.12.6.drv-0/xnu-3789.70.16/libsyscall/mach/vm_map.defs                         post-installation fixup                                                                                                                                                                     rewriting symlink /nix/store/ccbz5jm10abnl2qac6lyv7y2iryazs91-xnu-osx-10.12.6/Library/Frameworks/System.framework/Versions/Current to be relative to /nix/store/ccbz5jm10abnl2qac6lyv7y2iryazs91-xnu-osx-10.12.6                                                                                                                                                                        rewriting symlink /nix/store/ccbz5jm10abnl2qac6lyv7y2iryazs91-xnu-osx-10.12.6/Library/Frameworks/System.framework/Headers to be relative to /nix/store/ccbz5jm10abnl2qac6lyv7y2iryazs91-xnu-osx-10.12.6                                                                                                                                                                                 strip is /nix/store/x9mh477dvw0929zgbpkvpxqy4ifdh5qj-bootstrap-tools/bin/strip                                                                                                              building '/nix/store/5dds2grivw41y3x6l5qnzfssyfmy90bv-swift-corefoundation.drv'...                                                                                                          unpacking sources                                                                                                                                                                           unpacking source archive /nix/store/q19wpy2aylv4a6z5c6p52ih8pi2kcbpq-source                                                                                                                 source root is source/CoreFoundation                                                                                                                                                        patching sources                                                                                                                                                                            substituteStream(): WARNING: pattern '#if defined(__GNU__) ||' doesn't match anything in file 'Base.subproj/CFAsmMacros.h'                                                                  configuring                                                                                                                                                                                 /nix/store/jfq0n06qfdwmwgq19643z7fr1g5inbsr-bootstrap-stage1-stdenv-darwin/setup: ../configure: /usr/bin/env: bad interpreter: Operation not permitted                                      builder for '/nix/store/5dds2grivw41y3x6l5qnzfssyfmy90bv-swift-corefoundation.drv' failed with exit code 126

image

I think this is unrelated to this PR.

@Mic92
Copy link
Member Author

Mic92 commented Dec 27, 2020

@SuperSandro2000 what did you try to build? Can you disable the sandbox just for:

$ nix-build -A tests.cc-wrapper -A tests.cc-wrapper-clang

@dasJ
Copy link
Member

dasJ commented Dec 27, 2020

@Mic92 since others seem to do the build stuff, I'll unsubscribe here. Feel free to ping me if you need me again

@SuperSandro2000
Copy link
Member

@SuperSandro2000 what did you try to build? Can you disable the sandbox just for:

$ nix-build -A tests.cc-wrapper -A tests.cc-wrapper-clang

Works without sandbox 👍🏼

@Mic92 Mic92 marked this pull request as ready for review December 27, 2020 15:24
@Mic92 Mic92 force-pushed the fix-static-pie-take2 branch from 6f452b2 to 61bbbcd Compare December 27, 2020 15:42
@Mic92 Mic92 merged commit c417247 into NixOS:staging Dec 30, 2020
@Mic92 Mic92 deleted the fix-static-pie-take2 branch December 30, 2020 06:23
hypevhs pushed a commit to hypevhs/nixpkgs that referenced this pull request Oct 26, 2021
Package began failing after NixOS#107596

The `nix-support/libc-ldflags-before` file is no longer guaranteed to
exist, so this commit ensures the build continues without it.
@hypevhs hypevhs mentioned this pull request Oct 26, 2021
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants