Skip to content

Commit 86be433

Browse files
authored
Merge pull request #158047 from trofi/fix-cc-wrapper-lookup-paths
cc-wrapper: pass always -B and -L together to avoid mixing parts of libc
2 parents 3a2427b + 649ebfb commit 86be433

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pkgs/build-support/cc-wrapper/add-flags.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ NIX_CFLAGS_COMPILE_@suffixSalt@="-B@out@/bin/ $NIX_CFLAGS_COMPILE_@suffixSalt@"
3333
# Export and assign separately in order that a failing $(..) will fail
3434
# the script.
3535

36+
# Currently bootstrap-tools does not split glibc, and gcc files into
37+
# separate directories. As a workaround we want resulting cflags to be
38+
# ordered as: crt1-cflags libc-cflags cc-cflags. Otherwise we mix crt/libc.so
39+
# from different libc as seen in
40+
# https://github.com/NixOS/nixpkgs/issues/158042
41+
#
42+
# Note that below has reverse ordering as we prepend flags one-by-one.
43+
# Once bootstrap-tools is split into different directories we can stop
44+
# relying on flag ordering below.
45+
46+
if [ -e @out@/nix-support/cc-cflags ]; then
47+
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
48+
fi
49+
3650
if [[ "$cInclude" = 1 ]] && [ -e @out@/nix-support/libc-cflags ]; then
3751
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
3852
fi
@@ -49,10 +63,6 @@ if [ -e @out@/nix-support/libcxx-ldflags ]; then
4963
NIX_CXXSTDLIB_LINK_@suffixSalt@+=" $(< @out@/nix-support/libcxx-ldflags)"
5064
fi
5165

52-
if [ -e @out@/nix-support/cc-cflags ]; then
53-
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
54-
fi
55-
5666
if [ -e @out@/nix-support/gnat-cflags ]; then
5767
NIX_GNATFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE_@suffixSalt@"
5868
fi

0 commit comments

Comments
 (0)