git.iko.soy/typeable/nixpkgs
on master help sign in
gnat: make it build again (close #5307)

Problems are worked around by using older gcc wrapper for gnat bootstrap. (from ca441636f1^) I tried nicer solutions first, but I was unable to fix all problems for hours.

commit1a0a1619206f4a25d724bf04027980b45b15b16e authorVladimír Čunát <vcunat@gmail.com> dateSun 14 Dec 2014, 16:22 (12 years ago) parent9cdd231
12 files changed+1055−15
pkgs/build-support/gcc-wrapper-old/add-flags+28 pkgs/build-support/gcc-wrapper-old/builder.sh+214 pkgs/build-support/gcc-wrapper-old/default.nix+97 pkgs/build-support/gcc-wrapper-old/gcc-wrapper-old.sh+146 pkgs/build-support/gcc-wrapper-old/gcc-wrapper.sh+147 pkgs/build-support/gcc-wrapper-old/gnat-wrapper.sh+113 pkgs/build-support/gcc-wrapper-old/gnatlink-wrapper.sh+43 pkgs/build-support/gcc-wrapper-old/ld-solaris-wrapper.sh+40 pkgs/build-support/gcc-wrapper-old/ld-wrapper.sh+166 pkgs/build-support/gcc-wrapper-old/setup-hook.sh+33 pkgs/build-support/gcc-wrapper-old/utils.sh+24 pkgs/top-level/all-packages.nix+4−15
pkgs/build-support/gcc-wrapper-old/add-flagsnew file+28
@@ -0,0 +1,28 @@
1+# `-B@out@/bin' forces gcc to use ld-wrapper.sh when calling ld.
2+export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE"
3+
4+if test -e @out@/nix-support/libc-cflags; then
5+ export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE"
6+fi
7+
8+if test -e @out@/nix-support/gcc-cflags; then
9+ export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/gcc-cflags) $NIX_CFLAGS_COMPILE"
10+fi
11+
12+if test -e @out@/nix-support/gnat-cflags; then
13+ export NIX_GNATFLAGS_COMPILE="$(cat @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE"
14+fi
15+
16+if test -e @out@/nix-support/libc-ldflags; then
17+ export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)"
18+fi
19+
20+if test -e @out@/nix-support/gcc-ldflags; then
21+ export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/gcc-ldflags)"
22+fi
23+
24+if test -e @out@/nix-support/libc-ldflags-before; then
25+ export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE"
26+fi
27+
28+export NIX_GCC_WRAPPER_FLAGS_SET=1
pkgs/build-support/gcc-wrapper-old/builder.shnew file+214
@@ -0,0 +1,214 @@
1+source $stdenv/setup
2+
3+
4+mkdir -p $out/bin
5+mkdir -p $out/nix-support
6+
7+
8+if test -z "$nativeLibc"; then
9+ dynamicLinker="$libc/lib/$dynamicLinker"
10+ echo $dynamicLinker > $out/nix-support/dynamic-linker
11+
12+ if test -e $libc/lib/32/ld-linux.so.2; then
13+ echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
14+ fi
15+
16+ # The "-B$libc/lib/" flag is a quick hack to force gcc to link
17+ # against the crt1.o from our own glibc, rather than the one in
18+ # /usr/lib. (This is only an issue when using an `impure'
19+ # compiler/linker, i.e., one that searches /usr/lib and so on.)
20+ #
21+ # Unfortunately, setting -B appears to override the default search
22+ # path. Thus, the gcc-specific "../includes-fixed" directory is
23+ # now longer searched and glibc's <limits.h> header fails to
24+ # compile, because it uses "#include_next <limits.h>" to find the
25+ # limits.h file in ../includes-fixed. To remedy the problem,
26+ # another -idirafter is necessary to add that directory again.
27+ echo "-B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
28+
29+ echo "-L$libc/lib" > $out/nix-support/libc-ldflags
30+
31+ # The dynamic linker is passed in `ldflagsBefore' to allow
32+ # explicit overrides of the dynamic linker by callers to gcc/ld
33+ # (the *last* value counts, so ours should come first).
34+ echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before
35+fi
36+
37+if test -n "$nativeTools"; then
38+ gccPath="$nativePrefix/bin"
39+ ldPath="$nativePrefix/bin"
40+else
41+ if test -e "$gcc/lib64"; then
42+ gccLDFlags="$gccLDFlags -L$gcc/lib64"
43+ fi
44+ gccLDFlags="$gccLDFlags -L$gcc/lib"
45+ if [ -n "$langVhdl" ]; then
46+ gccLDFlags="$gccLDFlags -L$zlib/lib"
47+ fi
48+ echo "$gccLDFlags" > $out/nix-support/gcc-ldflags
49+
50+ # GCC shows $gcc/lib in `gcc -print-search-dirs', but not
51+ # $gcc/lib64 (even though it does actually search there...)..
52+ # This confuses libtool. So add it to the compiler tool search
53+ # path explicitly.
54+ if test -e "$gcc/lib64"; then
55+ gccCFlags="$gccCFlags -B$gcc/lib64"
56+ fi
57+
58+ # Find the gcc libraries path (may work only without multilib)
59+ if [ -n "$langAda" ]; then
60+ basePath=`echo $gcc/lib/*/*/*`
61+ gccCFlags="$gccCFlags -B$basePath -I$basePath/adainclude"
62+
63+ gnatCFlags="-aI$basePath/adainclude -aO$basePath/adalib"
64+ echo "$gnatCFlags" > $out/nix-support/gnat-cflags
65+ fi
66+ echo "$gccCFlags" > $out/nix-support/gcc-cflags
67+
68+ gccPath="$gcc/bin"
69+ # On Illumos/Solaris we might prefer native ld
70+ if test -n "$nativePrefix"; then
71+ ldPath="$nativePrefix/bin"
72+ else
73+ ldPath="$binutils/bin"
74+ fi;
75+fi
76+
77+
78+doSubstitute() {
79+ local src=$1
80+ local dst=$2
81+ local ld="$ldPath/ld"
82+ if $ld -V 2>&1 |grep Solaris; then
83+ # Use Solaris specific linker wrapper
84+ ld="$out/bin/ld-solaris"
85+ fi
86+ # Can't use substitute() here, because replace may not have been
87+ # built yet (in the bootstrap).
88+ sed \
89+ -e "s^@out@^$out^g" \
90+ -e "s^@shell@^$shell^g" \
91+ -e "s^@gcc@^$gcc^g" \
92+ -e "s^@gccProg@^$gccProg^g" \
93+ -e "s^@gnatProg@^$gnatProg^g" \
94+ -e "s^@gnatlinkProg@^$gnatlinkProg^g" \
95+ -e "s^@binutils@^$binutils^g" \
96+ -e "s^@coreutils@^$coreutils^g" \
97+ -e "s^@libc@^$libc^g" \
98+ -e "s^@ld@^$ld^g" \
99+ < "$src" > "$dst"
100+}
101+
102+
103+# Make wrapper scripts around gcc, g++, and gfortran. Also make symlinks
104+# cc, c++, and f77.
105+mkGccWrapper() {
106+ local dst=$1
107+ local src=$2
108+
109+ if ! test -f "$src"; then
110+ echo "$src does not exist (skipping)"
111+ return 1
112+ fi
113+
114+ gccProg="$src"
115+ doSubstitute "$gccWrapper" "$dst"
116+ chmod +x "$dst"
117+}
118+
119+mkGnatWrapper() {
120+ local dst=$1
121+ local src=$2
122+
123+ if ! test -f "$src"; then
124+ echo "$src does not exist (skipping)"
125+ return 1
126+ fi
127+
128+ gnatProg="$src"
129+ doSubstitute "$gnatWrapper" "$dst"
130+ chmod +x "$dst"
131+}
132+
133+mkGnatLinkWrapper() {
134+ local dst=$1
135+ local src=$2
136+
137+ if ! test -f "$src"; then
138+ echo "$src does not exist (skipping)"
139+ return 1
140+ fi
141+
142+ gnatlinkProg="$src"
143+ doSubstitute "$gnatlinkWrapper" "$dst"
144+ chmod +x "$dst"
145+}
146+
147+if mkGccWrapper $out/bin/gcc $gccPath/gcc
148+then
149+ ln -sv gcc $out/bin/cc
150+fi
151+
152+if mkGccWrapper $out/bin/g++ $gccPath/g++
153+then
154+ ln -sv g++ $out/bin/c++
155+fi
156+
157+mkGccWrapper $out/bin/cpp $gccPath/cpp || true
158+
159+if mkGccWrapper $out/bin/gfortran $gccPath/gfortran
160+then
161+ ln -sv gfortran $out/bin/g77
162+ ln -sv gfortran $out/bin/f77
163+fi
164+
165+mkGccWrapper $out/bin/gcj $gccPath/gcj || true
166+
167+mkGccWrapper $out/bin/gccgo $gccPath/gccgo || true
168+
169+mkGccWrapper $out/bin/gnatgcc $gccPath/gnatgcc || true
170+mkGnatWrapper $out/bin/gnatmake $gccPath/gnatmake || true
171+mkGnatWrapper $out/bin/gnatbind $gccPath/gnatbind || true
172+mkGnatLinkWrapper $out/bin/gnatlink $gccPath/gnatlink || true
173+
174+if [ -f $gccPath/ghdl ]; then
175+ ln -sf $gccPath/ghdl $out/bin/ghdl
176+fi
177+
178+
179+# Create a symlink to as (the assembler). This is useful when a
180+# gcc-wrapper is installed in a user environment, as it ensures that
181+# the right assembler is called.
182+ln -s $ldPath/as $out/bin/as
183+
184+
185+# Make a wrapper around the linker.
186+doSubstitute "$ldWrapper" "$out/bin/ld"
187+chmod +x "$out/bin/ld"
188+
189+# Copy solaris ld wrapper if needed
190+if $ldPath/ld -V 2>&1 |grep Solaris; then
191+ # Use Solaris specific linker wrapper
192+ sed -e "s^@ld@^$ldPath/ld^g" < "$ldSolarisWrapper" > "$out/bin/ld-solaris"
193+ chmod +x "$out/bin/ld-solaris"
194+fi
195+
196+
197+# Emit a setup hook. Also store the path to the original GCC and
198+# Glibc.
199+test -n "$gcc" && echo $gcc > $out/nix-support/orig-gcc
200+test -n "$libc" && echo $libc > $out/nix-support/orig-libc
201+
202+doSubstitute "$addFlags" "$out/nix-support/add-flags.sh"
203+
204+doSubstitute "$setupHook" "$out/nix-support/setup-hook"
205+
206+cp -p $utils $out/nix-support/utils.sh
207+
208+
209+# Propagate the wrapped gcc so that if you install the wrapper, you get
210+# tools like gcov, the manpages, etc. as well (including for binutils
211+# and Glibc).
212+if test -z "$nativeTools"; then
213+ echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages
214+fi
pkgs/build-support/gcc-wrapper-old/default.nixnew file+97
@@ -0,0 +1,97 @@
1+# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
2+# know where the C library and standard header files are. Therefore
3+# the compiler produced by that package cannot be installed directly
4+# in a user environment and used from the command line. This
5+# stdenv.mkDerivation provides a wrapper that sets up the right environment
6+# variables so that the compiler and the linker just "work".
7+
8+{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
9+, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? ""
10+, zlib ? null
11+}:
12+
13+assert nativeTools -> nativePrefix != "";
14+assert !nativeTools -> gcc != null && binutils != null && coreutils != null;
15+assert !nativeLibc -> libc != null;
16+
17+# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper
18+assert (gcc != null && gcc ? langVhdl && gcc.langVhdl) -> zlib != null;
19+
20+let
21+
22+ gccVersion = (builtins.parseDrvName gcc.name).version;
23+ gccName = (builtins.parseDrvName gcc.name).name;
24+
25+ langGo = if nativeTools then false else gcc ? langGo && gcc.langGo;
26+in
27+
28+stdenv.mkDerivation {
29+ name =
30+ (if name != "" then name else gccName + "-wrapper") +
31+ (if gcc != null && gccVersion != "" then "-" + gccVersion else "");
32+
33+ builder = ./builder.sh;
34+ setupHook = ./setup-hook.sh;
35+ gccWrapper = ./gcc-wrapper.sh;
36+ gnatWrapper = ./gnat-wrapper.sh;
37+ gnatlinkWrapper = ./gnatlink-wrapper.sh;
38+ ldWrapper = ./ld-wrapper.sh;
39+ ldSolarisWrapper = ./ld-solaris-wrapper.sh;
40+ utils = ./utils.sh;
41+ addFlags = ./add-flags;
42+
43+ inherit nativeTools nativeLibc nativePrefix gcc;
44+ libc = if nativeLibc then null else libc;
45+ binutils = if nativeTools then null else binutils;
46+ # The wrapper scripts use 'cat', so we may need coreutils
47+ coreutils = if nativeTools then null else coreutils;
48+
49+ langC = if nativeTools then true else gcc.langC;
50+ langCC = if nativeTools then true else gcc.langCC;
51+ langFortran = if nativeTools then false else gcc ? langFortran;
52+ langAda = if nativeTools then false else gcc ? langAda && gcc.langAda;
53+ langVhdl = if nativeTools then false else gcc ? langVhdl && gcc.langVhdl;
54+ zlib = if gcc != null && gcc ? langVhdl then zlib else null;
55+ shell = if shell == "" then stdenv.shell else
56+ if builtins.isAttrs shell then (shell + shell.shellPath)
57+ else shell;
58+
59+ crossAttrs = {
60+ shell = shell.crossDrv + shell.crossDrv.shellPath;
61+ libc = stdenv.gccCross.libc;
62+ coreutils = coreutils.crossDrv;
63+ binutils = binutils.crossDrv;
64+ gcc = gcc.crossDrv;
65+ #
66+ # This is not the best way to do this. I think the reference should be
67+ # the style in the gcc-cross-wrapper, but to keep a stable stdenv now I
68+ # do this sufficient if/else.
69+ dynamicLinker =
70+ (if stdenv.cross.arch == "arm" then "ld-linux.so.3" else
71+ if stdenv.cross.arch == "mips" then "ld.so.1" else
72+ if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else
73+ abort "don't know the name of the dynamic linker for this platform");
74+ };
75+
76+ preferLocalBuild = true;
77+
78+ meta =
79+ let gcc_ = if gcc != null then gcc else {}; in
80+ (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) //
81+ { description =
82+ stdenv.lib.attrByPath ["meta" "description"] "System C compiler" gcc_
83+ + " (wrapper script)";
84+ };
85+
86+ # The dynamic linker has different names on different Linux platforms.
87+ dynamicLinker =
88+ if !nativeLibc then
89+ (if stdenv.system == "i686-linux" then "ld-linux.so.2" else
90+ if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
91+ # ARM with a wildcard, which can be "" or "-armhf".
92+ if stdenv.isArm then "ld-linux*.so.3" else
93+ if stdenv.system == "powerpc-linux" then "ld.so.1" else
94+ if stdenv.system == "mips64el-linux" then "ld.so.1" else
95+ abort "don't know the name of the dynamic linker for this platform")
96+ else "";
97+}
pkgs/build-support/gcc-wrapper-old/gcc-wrapper-old.shnew file+146
@@ -0,0 +1,146 @@
1+#! @shell@ -e
2+
3+if [ -n "$NIX_GCC_WRAPPER_START_HOOK" ]; then
4+ source "$NIX_GCC_WRAPPER_START_HOOK"
5+fi
6+
7+if [ -z "$NIX_GCC_WRAPPER_FLAGS_SET" ]; then
8+ source @out@/nix-support/add-flags.sh
9+fi
10+
11+source @out@/nix-support/utils.sh
12+
13+
14+# Figure out if linker flags should be passed. GCC prints annoying
15+# warnings when they are not needed.
16+dontLink=0
17+getVersion=0
18+nonFlagArgs=0
19+
20+for i in "$@"; do
21+ if [ "$i" = -c ]; then
22+ dontLink=1
23+ elif [ "$i" = -S ]; then
24+ dontLink=1
25+ elif [ "$i" = -E ]; then
26+ dontLink=1
27+ elif [ "$i" = -E ]; then
28+ dontLink=1
29+ elif [ "$i" = -M ]; then
30+ dontLink=1
31+ elif [ "$i" = -MM ]; then
32+ dontLink=1
33+ elif [ "$i" = -x ]; then
34+ # At least for the cases c-header or c++-header we should set dontLink.
35+ # I expect no one use -x other than making precompiled headers.
36+ dontLink=1
37+ elif [ "${i:0:1}" != - ]; then
38+ nonFlagArgs=1
39+ elif [ "$i" = -m32 ]; then
40+ if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
41+ NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
42+ fi
43+ fi
44+done
45+
46+# If we pass a flag like -Wl, then gcc will call the linker unless it
47+# can figure out that it has to do something else (e.g., because of a
48+# "-c" flag). So if no non-flag arguments are given, don't pass any
49+# linker flags. This catches cases like "gcc" (should just print
50+# "gcc: no input files") and "gcc -v" (should print the version).
51+if [ "$nonFlagArgs" = 0 ]; then
52+ dontLink=1
53+fi
54+
55+
56+# Optionally filter out paths not refering to the store.
57+params=("$@")
58+if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then
59+ rest=()
60+ n=0
61+ while [ $n -lt ${#params[*]} ]; do
62+ p=${params[n]}
63+ p2=${params[$((n+1))]}
64+ if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
65+ skip $p
66+ elif [ "$p" = -L ] && badPath "$p2"; then
67+ n=$((n + 1)); skip $p2
68+ elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then
69+ skip $p
70+ elif [ "$p" = -I ] && badPath "$p2"; then
71+ n=$((n + 1)); skip $p2
72+ elif [ "$p" = -isystem ] && badPath "$p2"; then
73+ n=$((n + 1)); skip $p2
74+ else
75+ rest=("${rest[@]}" "$p")
76+ fi
77+ n=$((n + 1))
78+ done
79+ params=("${rest[@]}")
80+fi
81+
82+
83+# Add the flags for the C compiler proper.
84+extraAfter=($NIX_CFLAGS_COMPILE)
85+extraBefore=()
86+
87+# When enforcing purity, pretend gcc can't find the current date and
88+# time
89+if [ "$NIX_ENFORCE_PURITY" = 1 ]; then
90+ extraAfter+=('-D__DATE__="Jan 01 1970"'
91+ '-D__TIME__="00:00:01"'
92+ )
93+fi
94+
95+
96+if [ "$dontLink" != 1 ]; then
97+
98+ # Add the flags that should only be passed to the compiler when
99+ # linking.
100+ extraAfter+=($NIX_CFLAGS_LINK)
101+
102+ # Add the flags that should be passed to the linker (and prevent
103+ # `ld-wrapper' from adding NIX_LDFLAGS again).
104+ for i in $NIX_LDFLAGS_BEFORE; do
105+ extraBefore=(${extraBefore[@]} "-Wl,$i")
106+ done
107+ for i in $NIX_LDFLAGS; do
108+ if [ "${i:0:3}" = -L/ ]; then
109+ extraAfter+=("$i")
110+ else
111+ extraAfter+=("-Wl,$i")
112+ fi
113+ done
114+ export NIX_LDFLAGS_SET=1
115+fi
116+
117+# As a very special hack, if the arguments are just `-v', then don't
118+# add anything. This is to prevent `gcc -v' (which normally prints
119+# out the version number and returns exit code 0) from printing out
120+# `No input files specified' and returning exit code 1.
121+if [ "$*" = -v ]; then
122+ extraAfter=()
123+ extraBefore=()
124+fi
125+
126+# Optionally print debug info.
127+if [ -n "$NIX_DEBUG" ]; then
128+ echo "original flags to @prog@:" >&2
129+ for i in "${params[@]}"; do
130+ echo " $i" >&2
131+ done
132+ echo "extraBefore flags to @prog@:" >&2
133+ for i in ${extraBefore[@]}; do
134+ echo " $i" >&2
135+ done
136+ echo "extraAfter flags to @prog@:" >&2
137+ for i in ${extraAfter[@]}; do
138+ echo " $i" >&2
139+ done
140+fi
141+
142+if [ -n "$NIX_GCC_WRAPPER_EXEC_HOOK" ]; then
143+ source "$NIX_GCC_WRAPPER_EXEC_HOOK"
144+fi
145+
146+exec @prog@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}"
pkgs/build-support/gcc-wrapper-old/gcc-wrapper.shnew file+147
@@ -0,0 +1,147 @@
1+#! @shell@ -e
2+
3+if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
4+ source "$NIX_GCC_WRAPPER_START_HOOK"
5+fi
6+
7+if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then
8+ source @out@/nix-support/add-flags.sh
9+fi
10+
11+source @out@/nix-support/utils.sh
12+
13+
14+# Figure out if linker flags should be passed. GCC prints annoying
15+# warnings when they are not needed.
16+dontLink=0
17+getVersion=0
18+nonFlagArgs=0
19+
20+for i in "$@"; do
21+ if test "$i" = "-c"; then
22+ dontLink=1
23+ elif test "$i" = "-S"; then
24+ dontLink=1
25+ elif test "$i" = "-E"; then
26+ dontLink=1
27+ elif test "$i" = "-E"; then
28+ dontLink=1
29+ elif test "$i" = "-M"; then
30+ dontLink=1
31+ elif test "$i" = "-MM"; then
32+ dontLink=1
33+ elif test "$i" = "-x"; then
34+ # At least for the cases c-header or c++-header we should set dontLink.
35+ # I expect no one use -x other than making precompiled headers.
36+ dontLink=1
37+ elif test "${i:0:1}" != "-"; then
38+ nonFlagArgs=1
39+ elif test "$i" = "-m32"; then
40+ if test -e @out@/nix-support/dynamic-linker-m32; then
41+ NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
42+ fi
43+ fi
44+done
45+
46+# If we pass a flag like -Wl, then gcc will call the linker unless it
47+# can figure out that it has to do something else (e.g., because of a
48+# "-c" flag). So if no non-flag arguments are given, don't pass any
49+# linker flags. This catches cases like "gcc" (should just print
50+# "gcc: no input files") and "gcc -v" (should print the version).
51+if test "$nonFlagArgs" = "0"; then
52+ dontLink=1
53+fi
54+
55+
56+# Optionally filter out paths not refering to the store.
57+params=("$@")
58+if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
59+ rest=()
60+ n=0
61+ while test $n -lt ${#params[*]}; do
62+ p=${params[n]}
63+ p2=${params[$((n+1))]}
64+ if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
65+ skip $p
66+ elif test "$p" = "-L" && badPath "$p2"; then
67+ n=$((n + 1)); skip $p2
68+ elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
69+ skip $p
70+ elif test "$p" = "-I" && badPath "$p2"; then
71+ n=$((n + 1)); skip $p2
72+ elif test "$p" = "-isystem" && badPath "$p2"; then
73+ n=$((n + 1)); skip $p2
74+ else
75+ rest=("${rest[@]}" "$p")
76+ fi
77+ n=$((n + 1))
78+ done
79+ params=("${rest[@]}")
80+fi
81+
82+
83+# Add the flags for the C compiler proper.
84+extraAfter=($NIX_CFLAGS_COMPILE)
85+extraBefore=()
86+
87+if test "$dontLink" != "1"; then
88+
89+ # Add the flags that should only be passed to the compiler when
90+ # linking.
91+ extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK)
92+
93+ # Add the flags that should be passed to the linker (and prevent
94+ # `ld-wrapper' from adding NIX_LDFLAGS again).
95+ for i in $NIX_LDFLAGS_BEFORE; do
96+ extraBefore=(${extraBefore[@]} "-Wl,$i")
97+ done
98+ for i in $NIX_LDFLAGS; do
99+ if test "${i:0:3}" = "-L/"; then
100+ extraAfter=(${extraAfter[@]} "$i")
101+ else
102+ extraAfter=(${extraAfter[@]} "-Wl,$i")
103+ fi
104+ done
105+ export NIX_LDFLAGS_SET=1
106+fi
107+
108+# As a very special hack, if the arguments are just `-v', then don't
109+# add anything. This is to prevent `gcc -v' (which normally prints
110+# out the version number and returns exit code 0) from printing out
111+# `No input files specified' and returning exit code 1.
112+if test "$*" = "-v"; then
113+ extraAfter=()
114+ extraBefore=()
115+fi
116+
117+# Optionally print debug info.
118+if test "$NIX_DEBUG" = "1"; then
119+ echo "original flags to @gccProg@:" >&2
120+ for i in "${params[@]}"; do
121+ echo " $i" >&2
122+ done
123+ echo "extraBefore flags to @gccProg@:" >&2
124+ for i in ${extraBefore[@]}; do
125+ echo " $i" >&2
126+ done
127+ echo "extraAfter flags to @gccProg@:" >&2
128+ for i in ${extraAfter[@]}; do
129+ echo " $i" >&2
130+ done
131+fi
132+
133+if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then
134+ source "$NIX_GCC_WRAPPER_EXEC_HOOK"
135+fi
136+
137+
138+# Call the real `gcc'. Filter out warnings from stderr about unused
139+# `-B' flags, since they confuse some programs. Deep bash magic to
140+# apply grep to stderr (by swapping stdin/stderr twice).
141+if test -z "$NIX_GCC_NEEDS_GREP"; then
142+ @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
143+else
144+ (@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
145+ | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
146+ exit $?
147+fi
pkgs/build-support/gcc-wrapper-old/gnat-wrapper.shnew file+113
@@ -0,0 +1,113 @@
1+#! @shell@ -e
2+
3+if test -n "$NIX_GNAT_WRAPPER_START_HOOK"; then
4+ source "$NIX_GNAT_WRAPPER_START_HOOK"
5+fi
6+
7+if test -z "$NIX_GNAT_WRAPPER_FLAGS_SET"; then
8+ source @out@/nix-support/add-flags.sh
9+fi
10+
11+source @out@/nix-support/utils.sh
12+
13+
14+# Figure out if linker flags should be passed. GCC prints annoying
15+# warnings when they are not needed.
16+dontLink=0
17+getVersion=0
18+nonFlagArgs=0
19+
20+for i in "$@"; do
21+ if test "$i" = "-c"; then
22+ dontLink=1
23+ elif test "$i" = "-M"; then
24+ dontLink=1
25+ elif test "${i:0:1}" != "-"; then
26+ nonFlagArgs=1
27+ elif test "$i" = "-m32"; then
28+ if test -e @out@/nix-support/dynamic-linker-m32; then
29+ NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
30+ fi
31+ fi
32+done
33+
34+# If we pass a flag like -Wl, then gcc will call the linker unless it
35+# can figure out that it has to do something else (e.g., because of a
36+# "-c" flag). So if no non-flag arguments are given, don't pass any
37+# linker flags. This catches cases like "gcc" (should just print
38+# "gcc: no input files") and "gcc -v" (should print the version).
39+if test "$nonFlagArgs" = "0"; then
40+ dontLink=1
41+fi
42+
43+
44+# Optionally filter out paths not refering to the store.
45+params=("$@")
46+if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
47+ rest=()
48+ n=0
49+ while test $n -lt ${#params[*]}; do
50+ p=${params[n]}
51+ p2=${params[$((n+1))]}
52+ if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
53+ skip $p
54+ elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
55+ skip $p
56+ elif test "${p:0:4}" = "-aI/" && badPath "${p:3}"; then
57+ skip $p
58+ elif test "${p:0:4}" = "-aO/" && badPath "${p:3}"; then
59+ skip $p
60+ else
61+ rest=("${rest[@]}" "$p")
62+ fi
63+ n=$((n + 1))
64+ done
65+ params=("${rest[@]}")
66+fi
67+
68+
69+# Add the flags for the GNAT compiler proper.
70+extraAfter=($NIX_GNATFLAGS_COMPILE)
71+extraBefore=()
72+
73+if [ "`basename $0`x" = "gnatmakex" ]; then
74+ extraBefore=("--GNATBIND=@out@/bin/gnatbind --GNATLINK=@out@/bin/gnatlink ")
75+fi
76+
77+# Add the flags that should be passed to the linker (and prevent
78+# `ld-wrapper' from adding NIX_LDFLAGS again).
79+#for i in $NIX_LDFLAGS_BEFORE; do
80+# extraBefore=(${extraBefore[@]} "-largs $i")
81+#done
82+
83+# Optionally print debug info.
84+if test "$NIX_DEBUG" = "1"; then
85+ echo "original flags to @gnatProg@:" >&2
86+ for i in "${params[@]}"; do
87+ echo " $i" >&2
88+ done
89+ echo "extraBefore flags to @gnatProg@:" >&2
90+ for i in ${extraBefore[@]}; do
91+ echo " $i" >&2
92+ done
93+ echo "extraAfter flags to @gnatProg@:" >&2
94+ for i in ${extraAfter[@]}; do
95+ echo " $i" >&2
96+ done
97+fi
98+
99+if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then
100+ source "$NIX_GNAT_WRAPPER_EXEC_HOOK"
101+fi
102+
103+
104+# Call the real `gcc'. Filter out warnings from stderr about unused
105+# `-B' flags, since they confuse some programs. Deep bash magic to
106+# apply grep to stderr (by swapping stdin/stderr twice).
107+if test -z "$NIX_GNAT_NEEDS_GREP"; then
108+ @gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
109+else
110+ (@gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
111+ | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
112+ exit $?
113+fi
pkgs/build-support/gcc-wrapper-old/gnatlink-wrapper.shnew file+43
@@ -0,0 +1,43 @@
1+#! @shell@ -e
2+
3+# Add the flags for the GNAT compiler proper.
4+extraAfter="--GCC=@out@/bin/gcc"
5+extraBefore=()
6+
7+# Add the flags that should be passed to the linker (and prevent
8+# `ld-wrapper' from adding NIX_LDFLAGS again).
9+#for i in $NIX_LDFLAGS_BEFORE; do
10+# extraBefore=(${extraBefore[@]} "-largs $i")
11+#done
12+
13+# Optionally print debug info.
14+if test "$NIX_DEBUG" = "1"; then
15+ echo "original flags to @gnatlinkProg@:" >&2
16+ for i in "$@"; do
17+ echo " $i" >&2
18+ done
19+ echo "extraBefore flags to @gnatlinkProg@:" >&2
20+ for i in ${extraBefore[@]}; do
21+ echo " $i" >&2
22+ done
23+ echo "extraAfter flags to @gnatlinkProg@:" >&2
24+ for i in ${extraAfter[@]}; do
25+ echo " $i" >&2
26+ done
27+fi
28+
29+if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then
30+ source "$NIX_GNAT_WRAPPER_EXEC_HOOK"
31+fi
32+
33+
34+# Call the real `gcc'. Filter out warnings from stderr about unused
35+# `-B' flags, since they confuse some programs. Deep bash magic to
36+# apply grep to stderr (by swapping stdin/stderr twice).
37+if test -z "$NIX_GNAT_NEEDS_GREP"; then
38+ @gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]}
39+else
40+ (@gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
41+ | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
42+ exit $?
43+fi
pkgs/build-support/gcc-wrapper-old/ld-solaris-wrapper.shnew file+40
@@ -0,0 +1,40 @@
1+#!/bin/bash
2+
3+set -e
4+set -u
5+
6+# I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'(
7+# Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3
8+# but still no success.
9+cmd="@ld@ -z ignore"
10+
11+args=("$@");
12+
13+# This loop makes sure all -L arguments are before -l arguments, or ld may complain it cannot find a library.
14+# GNU binutils does not have this problem:
15+# http://stackoverflow.com/questions/5817269/does-the-order-of-l-and-l-options-in-the-gnu-linker-matter
16+i=0;
17+while [[ $i -lt $# ]]; do
18+ case "${args[$i]}" in
19+ -L) cmd="$cmd ${args[$i]} ${args[($i+1)]}"; i=($i+1); ;;
20+ -L*) cmd="$cmd ${args[$i]}" ;;
21+ *) ;;
22+ esac
23+ i=($i+1);
24+done
25+
26+i=0;
27+while [[ $i -lt $# ]]; do
28+ case "${args[$i]}" in
29+ -L) i=($i+1); ;;
30+ -L*) ;;
31+ *) cmd="$cmd ${args[$i]}" ;;
32+ esac
33+ i=($i+1);
34+done
35+
36+# Trace:
37+set -x
38+exec $cmd
39+
40+exit 0
pkgs/build-support/gcc-wrapper-old/ld-wrapper.shnew file+166
@@ -0,0 +1,166 @@
1+#! @shell@ -e
2+
3+if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
4+ source "$NIX_LD_WRAPPER_START_HOOK"
5+fi
6+
7+if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then
8+ source @out@/nix-support/add-flags.sh
9+fi
10+
11+source @out@/nix-support/utils.sh
12+
13+
14+# Optionally filter out paths not refering to the store.
15+params=("$@")
16+if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
17+ -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then
18+ rest=()
19+ n=0
20+ while test $n -lt ${#params[*]}; do
21+ p=${params[n]}
22+ p2=${params[$((n+1))]}
23+ if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
24+ skip $p
25+ elif test "$p" = "-L" && badPath "$p2"; then
26+ n=$((n + 1)); skip $p2
27+ elif test "$p" = "-rpath" && badPath "$p2"; then
28+ n=$((n + 1)); skip $p2
29+ elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
30+ n=$((n + 1)); skip $p2
31+ elif test "${p:0:1}" = "/" && badPath "$p"; then
32+ # We cannot skip this; barf.
33+ echo "impure path \`$p' used in link" >&2
34+ exit 1
35+ elif test "${p:0:9}" = "--sysroot"; then
36+ # Our ld is not built with sysroot support (Can we fix that?)
37+ :
38+ else
39+ rest=("${rest[@]}" "$p")
40+ fi
41+ n=$((n + 1))
42+ done
43+ params=("${rest[@]}")
44+fi
45+
46+
47+extra=()
48+extraBefore=()
49+
50+if test -z "$NIX_LDFLAGS_SET"; then
51+ extra+=($NIX_LDFLAGS)
52+ extraBefore+=($NIX_LDFLAGS_BEFORE)
53+fi
54+
55+extra+=($NIX_LDFLAGS_AFTER)
56+
57+
58+# Add all used dynamic libraries to the rpath.
59+if test "$NIX_DONT_SET_RPATH" != "1"; then
60+
61+ libPath=""
62+ addToLibPath() {
63+ local path="$1"
64+ if test "${path:0:1}" != "/"; then return 0; fi
65+ case "$path" in
66+ *..*|*./*|*/.*|*//*)
67+ local path2
68+ if path2=$(readlink -f "$path"); then
69+ path="$path2"
70+ fi
71+ ;;
72+ esac
73+ case $libPath in
74+ *\ $path\ *) return 0 ;;
75+ esac
76+ libPath="$libPath $path "
77+ }
78+
79+ addToRPath() {
80+ # If the path is not in the store, don't add it to the rpath.
81+ # This typically happens for libraries in /tmp that are later
82+ # copied to $out/lib. If not, we're screwed.
83+ if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
84+ case $rpath in
85+ *\ $1\ *) return 0 ;;
86+ esac
87+ rpath="$rpath $1 "
88+ }
89+
90+ libs=""
91+ addToLibs() {
92+ libs="$libs $1"
93+ }
94+
95+ rpath=""
96+
97+ # First, find all -L... switches.
98+ allParams=("${params[@]}" ${extra[@]})
99+ n=0
100+ while test $n -lt ${#allParams[*]}; do
101+ p=${allParams[n]}
102+ p2=${allParams[$((n+1))]}
103+ if test "${p:0:3}" = "-L/"; then
104+ addToLibPath ${p:2}
105+ elif test "$p" = "-L"; then
106+ addToLibPath ${p2}
107+ n=$((n + 1))
108+ elif test "$p" = "-l"; then
109+ addToLibs ${p2}
110+ n=$((n + 1))
111+ elif test "${p:0:2}" = "-l"; then
112+ addToLibs ${p:2}
113+ elif test "$p" = "-dynamic-linker"; then
114+ # Ignore the dynamic linker argument, or it
115+ # will get into the next 'elif'. We don't want
116+ # the dynamic linker path rpath to go always first.
117+ n=$((n + 1))
118+ elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
119+ # This is a direct reference to a shared library, so add
120+ # its directory to the rpath.
121+ path="$(dirname "$p")";
122+ addToRPath "${path}"
123+ fi
124+ n=$((n + 1))
125+ done
126+
127+ # Second, for each directory in the library search path (-L...),
128+ # see if it contains a dynamic library used by a -l... flag. If
129+ # so, add the directory to the rpath.
130+ # It's important to add the rpath in the order of -L..., so
131+ # the link time chosen objects will be those of runtime linking.
132+
133+ for i in $libPath; do
134+ for j in $libs; do
135+ if test -f "$i/lib$j.so"; then
136+ addToRPath $i
137+ break
138+ fi
139+ done
140+ done
141+
142+
143+ # Finally, add `-rpath' switches.
144+ for i in $rpath; do
145+ extra=(${extra[@]} -rpath $i)
146+ done
147+fi
148+
149+
150+# Optionally print debug info.
151+if test "$NIX_DEBUG" = "1"; then
152+ echo "original flags to @ld@:" >&2
153+ for i in "${params[@]}"; do
154+ echo " $i" >&2
155+ done
156+ echo "extra flags to @ld@:" >&2
157+ for i in ${extra[@]}; do
158+ echo " $i" >&2
159+ done
160+fi
161+
162+if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
163+ source "$NIX_LD_WRAPPER_EXEC_HOOK"
164+fi
165+
166+exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}
pkgs/build-support/gcc-wrapper-old/setup-hook.shnew file+33
@@ -0,0 +1,33 @@
1+addCVars () {
2+ if test -d $1/include; then
3+ export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include"
4+ fi
5+
6+ if test -d $1/lib64; then
7+ export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64"
8+ fi
9+
10+ if test -d $1/lib; then
11+ export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib"
12+ fi
13+}
14+
15+envHooks=(${envHooks[@]} addCVars)
16+
17+# Note: these come *after* $out in the PATH (see setup.sh).
18+
19+if test -n "@gcc@"; then
20+ addToSearchPath PATH @gcc@/bin
21+fi
22+
23+if test -n "@binutils@"; then
24+ addToSearchPath PATH @binutils@/bin
25+fi
26+
27+if test -n "@libc@"; then
28+ addToSearchPath PATH @libc@/bin
29+fi
30+
31+if test -n "@coreutils@"; then
32+ addToSearchPath PATH @coreutils@/bin
33+fi
pkgs/build-support/gcc-wrapper-old/utils.shnew file+24
@@ -0,0 +1,24 @@
1+skip () {
2+ if test "$NIX_DEBUG" = "1"; then
3+ echo "skipping impure path $1" >&2
4+ fi
5+}
6+
7+
8+# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but
9+# `/nix/store/.../lib/foo.so' isn't.
10+badPath() {
11+ local p=$1
12+
13+ # Relative paths are okay (since they're presumably relative to
14+ # the temporary build directory).
15+ if test "${p:0:1}" != "/"; then return 1; fi
16+
17+ # Otherwise, the path should refer to the store or some temporary
18+ # directory (including the build directory).
19+ test \
20+ "$p" != "/dev/null" -a \
21+ "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
22+ "${p:0:4}" != "/tmp" -a \
23+ "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
24+}
pkgs/top-level/all-packages.nix+4−15
@@ -3237,7 +3237,7 @@ let
32373237 libXrandr xproto renderproto xextproto inputproto randrproto;
32383238 });
32393239
3240− gnat = gnat45;
3240+ gnat = gnat45; # failed to make 4.6 or 4.8 build
32413241
32423242 gnat45 = wrapGCC (gcc45.gcc.override {
32433243 name = "gnat";
@@ -3252,20 +3252,7 @@ let
32523252 ppl = null;
32533253 });
32543254
3255− gnat46 = wrapGCC (gcc46.gcc.override {
3256− name = "gnat";
3257− langCC = false;
3258− langC = true;
3259− langAda = true;
3260− profiledCompiler = false;
3261− gnatboot = gnat45;
3262− # We can't use the ppl stuff, because we would have
3263− # libstdc++ problems.
3264− ppl = null;
3265− cloog = null;
3266− });
3267−
3268− gnatboot = wrapGCC (import ../development/compilers/gnatboot {
3255+ gnatboot = wrapGCC-old (import ../development/compilers/gnatboot {
32693256 inherit fetchurl stdenv;
32703257 });
32713258
@@ -3928,6 +3915,8 @@ let
39283915 };
39293916
39303917 wrapGCC = wrapGCCWith (makeOverridable (import ../build-support/gcc-wrapper)) glibc;
3918+ # legacy version, used for gnat bootstrapping
3919+ wrapGCC-old = wrapGCCWith (makeOverridable (import ../build-support/gcc-wrapper-old)) glibc;
39313920
39323921 wrapGCCCross =
39333922 {gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}: