Skip to content

Commit

Permalink
make-bootstrap-tools: fix test to include libstdc++ -rpath
Browse files Browse the repository at this point in the history
After NixOS#209054 we started moving
libstdc++.so out of default glibc's paths. This exposed bootstrap
tools build failure as:

    $ nix build --no-link -f ./pkgs/stdenv/linux/make-bootstrap-tools.nix
    ...
    >
    .../bin/bar: error while loading shared libraries: libstdc++.so.6:
       cannot open shared object file: No such file or directory

Note that bootstrap itself did not break. The change only expands
handcrafted `-rpath` entries.
  • Loading branch information
trofi committed Jan 14, 2023
1 parent d4d82a6 commit 4970334
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pkgs/stdenv/linux/make-bootstrap-tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,17 @@ in with pkgs; rec {
gcc --version
'' + lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
ldlinux=$(echo ${bootstrapTools}/lib/${builtins.baseNameOf binutils.dynamicLinker})
export CPP="cpp -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools}"
export CC="gcc -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
export CXX="g++ -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
rtld=$(echo ${bootstrapTools}/lib/${builtins.baseNameOf binutils.dynamicLinker})
libc_includes=${bootstrapTools}/include-glibc
'' + lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
ldmusl=$(echo ${bootstrapTools}/lib/ld-musl*.so.?)
export CPP="cpp -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools}"
export CC="gcc -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib"
export CXX="g++ -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib"
rtld=$(echo ${bootstrapTools}/lib/ld-musl*.so.?)
libc_includes=${bootstrapTools}/include-libc
'' + ''
# path to version-specific libraries, like libstdc++.so
cxx_libs=$(echo ${bootstrapTools}/lib/gcc/*/*)
export CPP="cpp -idirafter $libc_includes -B${bootstrapTools}"
export CC="gcc -idirafter $libc_includes -B${bootstrapTools} -Wl,-dynamic-linker,$rtld -Wl,-rpath,${bootstrapTools}/lib -Wl,-rpath,$cxx_libs"
export CXX="g++ -idirafter $libc_includes -B${bootstrapTools} -Wl,-dynamic-linker,$rtld -Wl,-rpath,${bootstrapTools}/lib -Wl,-rpath,$cxx_libs"
echo '#include <stdio.h>' >> foo.c
echo '#include <limits.h>' >> foo.c
Expand Down

0 comments on commit 4970334

Please sign in to comment.