Skip to content

Commit 5f9c8af

Browse files
authored
Fix libgcc.a linkage when linking libgcc_s.so (#317)
libgcc_s.so is normally a linker script that adds -lgcc for static functions. However due to bootstrapping requirements, libgcc_s is also added to the glibc library directory. Unfortunately, here it is a symlink to libgcc_s.so.1. Fix it by replacing the symlink by a linker script.
1 parent cc4997d commit 5f9c8af

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkgs/stdenv-glibc-2_27/default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ let
3333

3434
postInstall = prevAttrs.postInstall + ''
3535
install -Dm755 $bin/bin/getent -t $getent/bin
36+
37+
# libgcc_s.so is normally a linker script that adds -lgcc for static
38+
# functions. However due to bootstrapping requirements, libgcc_s is
39+
# also added to the glibc library directory. Unfortunately, here it
40+
# is a symlink to libgcc_s.so.1. This breaks linkage with g++, since
41+
# the static library is not used. Newer glibc versions allow fixing
42+
# this easily by setting up the libgcc as a user-trusted directory.
43+
# We'll fix it here by replacing libgcc_s.so by a linker script.
44+
rm -f $out/lib/libgcc_s.so
45+
echo "GROUP ( libgcc_s.so.1 -lgcc )" > $out/lib/libgcc_s.so
3646
'';
3747

3848
passthru = prevAttrs.passthru // {

0 commit comments

Comments
 (0)