Skip to content
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

treewide: Get rid of cc.gcc #91293

Merged
merged 1 commit into from
Aug 3, 2020

Conversation

Ericson2314
Copy link
Member

Motivation for this change

Instead, we have a new gccForLibs, which has the appropriate definition for e.g. avoiding x86_32 linking problems.

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.

@Ericson2314 Ericson2314 changed the title treewide: Get rid of cc.gcc WIP: treewide: Get rid of cc.gcc Jun 22, 2020
@Ericson2314 Ericson2314 force-pushed the cxx-wrapper-debt-part-2 branch 2 times, most recently from ad418c0 to 4228bc9 Compare August 2, 2020 15:35
@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Aug 2, 2020
@Ericson2314
Copy link
Member Author

Oh nice, the eval problems just went away!

Instead, we have a new `gccForLibs`, which has the appropriate
definition for e.g. avoiding `x86_32` linking problems.
@Ericson2314 Ericson2314 force-pushed the cxx-wrapper-debt-part-2 branch from 0b0dcd3 to 92f96f4 Compare August 2, 2020 17:12
@Ericson2314 Ericson2314 changed the title WIP: treewide: Get rid of cc.gcc treewide: Get rid of cc.gcc Aug 2, 2020
@Ericson2314
Copy link
Member Author

OK ofborg passes, and manually tested some obscure things like wasi zlib.

@Ericson2314 Ericson2314 merged commit b5f7ed6 into NixOS:staging Aug 3, 2020
@Ericson2314 Ericson2314 deleted the cxx-wrapper-debt-part-2 branch August 3, 2020 00:42
worldofpeace added a commit to worldofpeace/nixpkgs that referenced this pull request Aug 30, 2020
Ughhhh this was terrible but it seems to now be fixed by [0].
Though it doesn't seem the issue is entirely resolved NixOS#36947.

[0]: NixOS#91293
@bkchr
Copy link
Contributor

bkchr commented Sep 3, 2020

@Ericson2314 Hey, I think this broke the "aarch64-android-prebuilt" pkgs.

Just try with:

nix-build -p pkgsCross.aarch64-android-prebuilt.hello

@Ericson2314
Copy link
Member Author

Ericson2314 commented Sep 6, 2020

@bkchr Can you reproduce this without -p. I can't yet, and -p isn't normally used with nix-build. Very odd.

@bkchr
Copy link
Contributor

bkchr commented Sep 6, 2020

@Ericson2314

When I use without -p I get the following error:

nix-build pkgsCross.aarch64-android-prebuilt.hello 
error: getting status of '/home/bastian/projects/nixos/nixos-config/nixpkgs/pkgsCross.aarch64-android-prebuilt.hello': No such file or directory

But you can also use nix-shell -p pkgsCross.aarch64-android-prebuilt.hello, in the end it just needs to compile this package.

@matthewbauer
Copy link
Member

NIX_PATH=./dir nix-shell -p pkgsCross.aarch64-android-prebuilt.hello

and

nix-build ./dir -A pkgsCross.aarch64-android-prebuilt.hello

should be equivalent.

@bkchr Could you include the logs / derivation it fails at? I bet it's having trouble with the Android toolchain?

@bkchr
Copy link
Contributor

bkchr commented Sep 7, 2020

aarch64-unknown-linux-android-ar  rc libgcc_eh.a $objects
aarch64-unknown-linux-android-ar: libz.so.1: cannot open shared object file: No such file or directory

aarch64-unknown-linux-android-ranlib libgcc_eh.a
aarch64-unknown-linux-android-ranlib libgcc.a
aarch64-unknown-linux-android-ranlib: libz.so.1: cannot open shared object file: No such file or directory

aarch64-unknown-linux-android-ar: libz.so.1: cannot open shared object file: No such file or directory

aarch64-unknown-linux-android-ranlib: libz.so.1: cannot open shared object file: No such file or directory

aarch64-unknown-linux-android-ranlib libgcov.a
aarch64-unknown-linux-android-ranlib: libz.so.1: cannot open shared object file: No such file or directory

# Early copyback; see "all" above for the rationale.  The
# early copy is necessary so that the gcc -B options find
# the right startup files when linking shared libgcc.
/nix/store/j206pskg2yzyla1cnfrb9kb5n5bfvjgm-bash-4.4-p23/bin/bash ../../../gcc-9.3.0/libgcc/../mkinstalldirs ../.././gcc
parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o crtfastmath.o";                                    \
for file in $parts; do                                  \
  rm -f ../.././gcc/$file;              \
  /nix/store/fihsm8cs5hiw14kxhfmas3rf37c7dxn4-coreutils-8.31/bin/install -c -m 644 $file ../.././gcc/;  \
  case $file in                                         \
    *.a)                                                \
      aarch64-unknown-linux-android-ranlib ../.././gcc/$file ;; \
  esac;                                                 \
done
libtool: link: (cd ".libs" && rm -f "libcc1.so.0" && ln -s "libcc1.so.0.0.0" "libcc1.so.0")
libtool: link: (cd ".libs" && rm -f "libcc1.so" && ln -s "libcc1.so.0.0.0" "libcc1.so")
libtool: link: ar rc .libs/libcc1.a  findcomp.o libcc1.o libcp1.o names.o callbacks.o connection.o marshall.o
libtool: link: ranlib .libs/libcc1.a
libtool: link: ( cd ".libs" && rm -f "libcc1.la" && ln -s "../libcc1.la" "libcc1.la" )
{ /build/build/./gcc/nm -pg  _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulhc3_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divhc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o sync-cache_s.o sfp-exceptions_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o extendsftf2_s.o extenddftf2_s.o extendhftf2_s.o trunctfsf2_s.o trunctfdf2_s.o trunctfhf2_s.o fixhfti_s.o fixunshfti_s.o floattihf_s.o floatuntihf_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-dip_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o emutls_s.o; echo %%; \
  cat libgcc.map.in; \
} | gawk -f ../../../gcc-9.3.0/libgcc/mkmap-symver.awk  > tmp-libgcc.map
/nix/store/qilaiypqrly822jxra30v0ia8j23mbb7-ndk-gcc-binutils/bin/aarch64-unknown-linux-android-nm: libz.so.1: cannot open shared object file: No such file or directory

mv tmp-libgcc.map libgcc.map
# @multilib_flags@ is still needed because this may use
# /build/build/./gcc/xgcc -B/build/build/./gcc/ -O2 -idirafter /nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/include -B/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-L/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath-link,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib    and -O2  -O2 -idirafter /nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/include -B/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-L/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath-link,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector  directly.
# @multilib_dir@ is not really necessary, but sometimes it has
# more uses than just a directory name.
/nix/store/j206pskg2yzyla1cnfrb9kb5n5bfvjgm-bash-4.4-p23/bin/bash ../../../gcc-9.3.0/libgcc/../mkinstalldirs .
/build/build/./gcc/xgcc -B/build/build/./gcc/ -O2 -idirafter /nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/include -B/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-L/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath-link,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib    -O2  -O2 -idirafter /nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/include -B/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-L/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath-link,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector  -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -Wl,--version-script=libgcc.map -o ./libgcc_s.so.1.tmp -O2 -idirafter /nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/include -B/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-L/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -Wl,-rpath-link,/nix/store/22p2ngxh9jyqqcgk1l092j6nig3qzy81-bionic-prebuilt/lib -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulhc3_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divhc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o sync-cache_s.o sfp-exceptions_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o extendsftf2_s.o extenddftf2_s.o extendhftf2_s.o trunctfsf2_s.o trunctfdf2_s.o trunctfhf2_s.o fixhfti_s.o fixunshfti_s.o floattihf_s.o floatuntihf_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-dip_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc && rm -f ./libgcc_s.so && if [ -f ./libgcc_s.so.1 ]; then mv -f ./libgcc_s.so.1 ./libgcc_s.so.1.backup; else true; fi && mv ./libgcc_s.so.1.tmp ./libgcc_s.so.1 && ln -s libgcc_s.so.1 ./libgcc_s.so
/nix/store/qilaiypqrly822jxra30v0ia8j23mbb7-ndk-gcc-binutils/bin/aarch64-unknown-linux-android-ld: cannot find crti.o: No such file or directory
/nix/store/qilaiypqrly822jxra30v0ia8j23mbb7-ndk-gcc-binutils/bin/aarch64-unknown-linux-android-ld: cannot find -lc
/nix/store/qilaiypqrly822jxra30v0ia8j23mbb7-ndk-gcc-binutils/bin/aarch64-unknown-linux-android-ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:992: libgcc_s.so] Error 1
make[2]: Leaving directory '/build/build/aarch64-unknown-linux-android/libgcc'
make[1]: *** [Makefile:12332: all-target-libgcc] Error 2
make[1]: *** Waiting for unfinished jobs....
mv -f .deps/libcp1plugin.Tpo .deps/libcp1plugin.Plo
/nix/store/j206pskg2yzyla1cnfrb9kb5n5bfvjgm-bash-4.4-p23/bin/bash ./libtool --tag=CXX   --mode=link g++ -W -Wall  -fvisibility=hidden -g -O2 -module -export-symbols ../../gcc-9.3.0/libcc1/libcp1plugin.sym  -Xcompiler '-static-libstdc++' -Xcompiler '-static-libgcc' -o libcp1plugin.la -rpath /nix/store/012jg0d6lhldir0ajksksai43i8w1hjq-aarch64-unknown-linux-android-stage-final-gcc-debug-9.3.0/lib/gcc/aarch64-unknown-linux-android/9.3.0/plugin libcp1plugin.lo callbacks.lo connection.lo marshall.lo   -Wc,../libiberty/pic/libiberty.a
libtool: link: g++  -fPIC -DPIC -shared -nostdlib /nix/store/2pi6zgkwnr3zdslvlv16nixpzvbyjx1n-glibc-2.31/lib/crti.o /nix/store/wx4igg3f77x58zbwc9w420r50nx3nd72-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/crtbeginS.o  .libs/libcp1plugin.o .libs/callbacks.o .libs/connection.o .libs/marshall.o   -Wl,-rpath -Wl,/nix/store/0zsq4j8syam2g7i642dqspq7bbjflwyp-gcc-9.3.0-lib/lib/../lib64 -Wl,-rpath -Wl,/nix/store/0zsq4j8syam2g7i642dqspq7bbjflwyp-gcc-9.3.0-lib/lib/../lib64 -L/nix/store/9rq2v4faiibz0d7fs42gqzdn99ldf9pj-gettext-0.21/lib -L/nix/store/i79h2zhdmnbk987smm46zpwxxp4l5jxj-gmp-6.2.0/lib -L/nix/store/kzsiwwb5gsknxp9c6hahy8fhlal0jdb7-mpfr-4.1.0/lib -L/nix/store/b3i08q1cvkw91fdb6czr8a1mxqfjk412-libmpc-1.1.0/lib -L/nix/store/ndk5pibvzmngcna5jhfnl30wp7yjv2wj-libelf-0.8.13/lib -L/nix/store/mglgnxq2pb6lr5zpwvqyv7k6gwy1ni3w-isl-0.17.1/lib -L/nix/store/synxrw09w934ld6mnx0d9cndf51ak99b-zlib-1.2.11/lib -L/nix/store/2pi6zgkwnr3zdslvlv16nixpzvbyjx1n-glibc-2.31/lib -L/nix/store/0zsq4j8syam2g7i642dqspq7bbjflwyp-gcc-9.3.0-lib/lib -L/nix/store/jgcv40jcr1v9bmnj070mgvyi6m7r7w5r-gcc-wrapper-9.3.0/bin -L/nix/store/wx4igg3f77x58zbwc9w420r50nx3nd72-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0 -L/nix/store/wx4igg3f77x58zbwc9w420r50nx3nd72-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../lib64 -L/nix/store/wx4igg3f77x58zbwc9w420r50nx3nd72-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../.. /nix/store/0zsq4j8syam2g7i642dqspq7bbjflwyp-gcc-9.3.0-lib/lib/../lib64/libstdc++.so -lm -lc -lgcc_s /nix/store/wx4igg3f77x58zbwc9w420r50nx3nd72-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/crtendS.o /nix/store/2pi6zgkwnr3zdslvlv16nixpzvbyjx1n-glibc-2.31/lib/crtn.o  -static-libstdc++ -static-libgcc ../libiberty/pic/libiberty.a   -Wl,-soname -Wl,libcp1plugin.so.0 -Wl,-retain-symbols-file -Wl,../../gcc-9.3.0/libcc1/libcp1plugin.sym -o .libs/libcp1plugin.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libcp1plugin.so.0" && ln -s "libcp1plugin.so.0.0.0" "libcp1plugin.so.0")
libtool: link: (cd ".libs" && rm -f "libcp1plugin.so" && ln -s "libcp1plugin.so.0.0.0" "libcp1plugin.so")
libtool: link: ar rc .libs/libcp1plugin.a  libcp1plugin.o callbacks.o connection.o marshall.o
libtool: link: ranlib .libs/libcp1plugin.a
libtool: link: ( cd ".libs" && rm -f "libcp1plugin.la" && ln -s "../libcp1plugin.la" "libcp1plugin.la" )
make[3]: Leaving directory '/build/build/libcc1'
make[2]: Leaving directory '/build/build/libcc1'
make[1]: Leaving directory '/build/build'
make: *** [Makefile:956: all] Error 2
builder for '/nix/store/29zk1xxqgfcy4gzyjm0dwzybvvyq5mbp-aarch64-unknown-linux-android-stage-final-gcc-debug-9.3.0.drv' failed with exit code 2
cannot build derivation '/nix/store/i6dw6xj4d9klb5km5sy6msz9pv19zg1x-aarch64-unknown-linux-android-ndk-gcc-binutils-wrapper-.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/9k5rac09yjrh0py4gf80l8vfi6pa4x6y-stdenv-linux.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/98x11x05cmijz3fwk6vzakwfd0j5wxri-hello-2.10-aarch64-unknown-linux-android.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/423sd1zqrr8h0sp9lm739rxvf9s2s028-shell.drv': 1 dependencies couldn't be built
error: build of '/nix/store/423sd1zqrr8h0sp9lm739rxvf9s2s028-shell.drv' failed

@Ericson2314
Copy link
Member Author

Oh this isn't an eval error, which I what I was seeing.

@Ericson2314
Copy link
Member Author

Ah, it's because it's trying to use nix-built gcc via gccForLibs. Will post fix in a moment. Thanks!!

ggreif added a commit to ggreif/nixpkgs that referenced this pull request Oct 15, 2020
primeos added a commit that referenced this pull request Oct 16, 2020
llvmPackages_11: 11.0.0rc5 -> 11.0.0 and various fixes/improvements:
- llvmPackages_11 now compiles on Darwin
- libcxx now compiles on Linux
- Ported #91293 to 11.0.0
- Try to anticipate #100388
primeos pushed a commit to primeos/nixpkgs that referenced this pull request Nov 4, 2020
(cherry picked from commit 7a30df9)
rvem pushed a commit to serokell/nixpkgs that referenced this pull request Nov 8, 2022
(cherry picked from commit 7a30df9)
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request Apr 21, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request Apr 21, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request Apr 21, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request May 7, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request Sep 4, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request Sep 20, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request Sep 20, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request Sep 20, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
PetarKirov added a commit to PetarKirov/dlang.nix that referenced this pull request Sep 21, 2023
…so.1`

After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke
with the following error:

    ...
    auto-patchelf: 6 dependencies could not be satisfied
    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle

    error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by
    /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd

    auto-patchelf failed to find all the required dependencies.
    ...

After investigation, it turned out that the cuase was a recent [change in
Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package:

Before (nixpkgs @ 2022-03-30):

    > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1
    /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so

After (nixpkgs @ 2023-04-18):

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \
        | jq -r '.[0].outputs.out' \
        | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    (no output)

Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need:

    > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \
       | jq -r '.[0].outputs.libgcc' \
       | xargs  -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*'

    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1
    /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so

    This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc`
    instead of `glibc.out`.

[`gccForLibs`][1] is essentially `gcc.lib`:
* an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or
* an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would
  refer to clang and the `lib` output point to libclang libs, which are very
  different from what we need.

[0]: NixOS/nixpkgs#209870
[1]: NixOS/nixpkgs#91293
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants