I took away the patch about the -Bxxx not being passed to target libraries
through libtool.
I found a make variable holding flags that will not be trimmed by libtool:
FLAGS_FOR_TARGET.
···10export CPP="gcc -E"
1112if test "$staticCompiler" = "1"; then
13- NIX_EXTRA_LDFLAGS="-static"
14else
15- NIX_EXTRA_LDFLAGS=""
16fi
1718if test "$noSysDirs" = "1"; then
···2122 # Figure out what extra flags to pass to the gcc compilers
23 # being generated to make sure that they use our glibc.
24- extraCFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
25 extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
2627 # Use *real* header files, otherwise a limits.h is generated
···3435 else
36 # Hack: support impure environments.
37- extraCFlags="-isystem /usr/include"
38 extraLDFlags="-L/usr/lib64 -L/usr/lib"
39 glibc_libdir="/usr/lib"
40 export NIX_FIXINC_DUMMY=/usr/include
41 fi
4243- extraCFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY $extraCFlags"
44 extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
4546- export NIX_EXTRA_CFLAGS="$extraCFlags"
47 for i in $extraLDFlags; do
48- export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i"
49 done
5051 if test -n "$targetConfig"; then
···57 unset LIBRARY_PATH
58 unset CPATH
59 if test -z "$crossStageStatic"; then
60- export NIX_EXTRA_CFLAGS_TARGET="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include"
61- export NIX_EXTRA_LDFLAGS_TARGET="-Wl,-L${libcCross}/lib"
62 fi
63 else
64- # To be read by configure scripts (libtool-glibc.patch)
65- export NIX_EXTRA_CFLAGS_TARGET="$NIX_EXTRA_CFLAGS"
66- export NIX_EXTRA_LDFLAGS_TARGET="$NIX_EXTRA_LDFLAGS"
67 fi
68000069 makeFlagsArray=( \
70 "${makeFlagsArray[@]}" \
71 NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
72 SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
73- CFLAGS_FOR_BUILD="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
74- CFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET" \
75- LDFLAGS_FOR_BUILD="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
76- LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET" \
077 )
7879 if test -z "$targetConfig"; then
80 makeFlagsArray=( \
81 "${makeFlagsArray[@]}" \
82- BOOT_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
83- BOOT_LDFLAGS="$NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET" \
84 )
85 fi
86
···10export CPP="gcc -E"
1112if test "$staticCompiler" = "1"; then
13+ EXTRA_LDFLAGS="-static"
14else
15+ EXTRA_LDFLAGS=""
16fi
1718if test "$noSysDirs" = "1"; then
···2122 # Figure out what extra flags to pass to the gcc compilers
23 # being generated to make sure that they use our glibc.
24+ extraFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
25 extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
2627 # Use *real* header files, otherwise a limits.h is generated
···3435 else
36 # Hack: support impure environments.
37+ extraFlags="-isystem /usr/include"
38 extraLDFlags="-L/usr/lib64 -L/usr/lib"
39 glibc_libdir="/usr/lib"
40 export NIX_FIXINC_DUMMY=/usr/include
41 fi
4243+ extraFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY $extraFlags"
44 extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
4546+ EXTRA_FLAGS="$extraFlags"
47 for i in $extraLDFlags; do
48+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i"
49 done
5051 if test -n "$targetConfig"; then
···57 unset LIBRARY_PATH
58 unset CPATH
59 if test -z "$crossStageStatic"; then
60+ EXTRA_FLAGS_TARGET="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include"
61+ EXTRA_LDFLAGS_TARGET="-Wl,-L${libcCross}/lib"
62 fi
63 else
64+ EXTRA_FLAGS_TARGET="$EXTRA_FLAGS"
65+ EXTRA_LDFLAGS_TARGET="$EXTRA_LDFLAGS"
066 fi
6768+ # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
69+ # the startfiles.
70+ # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
71+ # for the startfiles.
72 makeFlagsArray=( \
73 "${makeFlagsArray[@]}" \
74 NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
75 SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
76+ CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
77+ CFLAGS_FOR_TARGET="$EXTRA_FLAGS_TARGET $EXTRA_LDFLAGS_TARGET" \
78+ FLAGS_FOR_TARGET="$EXTRA_FLAGS_TARGET $EXTRA_LDFLAGS_TARGET" \
79+ LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
80+ LDFLAGS_FOR_TARGET="$EXTRA_FLAGS_TARGET $EXTRA_LDFLAGS_TARGET" \
81 )
8283 if test -z "$targetConfig"; then
84 makeFlagsArray=( \
85 "${makeFlagsArray[@]}" \
86+ BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
87+ BOOT_LDFLAGS="$EXTRA_FLAGS_TARGET $EXTRA_LDFLAGS_TARGET" \
88 )
89 fi
90
+1-1
pkgs/development/compilers/gcc-4.4/default.nix
···8889 patches =
90 [./pass-cxxcpp.patch
91- ./libtool-glibc.patch # some libraries don't let the proper -Btargetglibcpath pass
92 ./libstdc++-target.patch # (fixed in gcc 4.4.3) bad mixture of build/target flags
93 ]
94 ++ optional noSysDirs ./no-sys-dirs.patch;
···8889 patches =
90 [./pass-cxxcpp.patch
91+# ./libtool-glibc.patch # some libraries don't let the proper -Btargetglibcpath pass
92 ./libstdc++-target.patch # (fixed in gcc 4.4.3) bad mixture of build/target flags
93 ]
94 ++ optional noSysDirs ./no-sys-dirs.patch;
···1-diff --git a/libgomp/configure b/libgomp/configure
2-index deef673..9e4a790 100755
3---- a/libgomp/configure
4-+++ b/libgomp/configure
5-@@ -23848,6 +23848,11 @@ old_archive_cmds=$lt_old_archive_cmds
6- # A language specific compiler.
7- CC=$lt_compiler
8-9-+# Ugly hack to get libmudflap (and other libraries) to build.
10-+# Libtool filters out \`-B' flags when linking (why?), so the \`-B' flag
11-+# to Glibc gets lost. Here we forcibly add it to any invocation.
12-+CC="\$CC $NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET"
13-+
14- # Is the compiler the GNU compiler?
15- with_gcc=$GCC
16-17-diff --git a/libmudflap/configure b/libmudflap/configure
18-index ae1be92..4ee1e18 100755
19---- a/libmudflap/configure
20-+++ b/libmudflap/configure
21-@@ -15044,6 +15044,11 @@ old_archive_cmds=$lt_old_archive_cmds
22- # A language specific compiler.
23- CC=$lt_compiler
24-25-+# Ugly hack to get libmudflap (and other libraries) to build.
26-+# Libtool filters out \`-B' flags when linking (why?), so the \`-B' flag
27-+# to Glibc gets lost. Here we forcibly add it to any invocation.
28-+CC="\$CC $NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET"
29-+
30- # Is the compiler the GNU compiler?
31- with_gcc=$GCC
32-33-diff --git a/libssp/configure b/libssp/configure
34-index ee2a41f..7f3e1fd 100755
35---- a/libssp/configure
36-+++ b/libssp/configure
37-@@ -12926,6 +12926,11 @@ old_archive_cmds=$lt_old_archive_cmds
38- # A language specific compiler.
39- CC=$lt_compiler
40-41-+# Ugly hack to get libmudflap (and other libraries) to build.
42-+# Libtool filters out \`-B' flags when linking (why?), so the \`-B' flag
43-+# to Glibc gets lost. Here we forcibly add it to any invocation.
44-+CC="\$CC $NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET"
45-+
46- # Is the compiler the GNU compiler?
47- with_gcc=$GCC
48-