···11-#! @shell@
22-set -eu -o pipefail +o posix
33-shopt -s nullglob
44-55-if (( "${NIX_DEBUG:-0}" >= 7 )); then
66- set -x
77-fi
88-99-# N.B. Gnat is not used during bootstrapping, so we don't need to
1010-# worry about the old bash empty array `set -u` workarounds.
1111-1212-path_backup="$PATH"
1313-1414-# phase separation makes this look useless
1515-# shellcheck disable=SC2157
1616-if [ -n "@coreutils_bin@" ]; then
1717- PATH="@coreutils_bin@/bin"
1818-fi
1919-2020-source @out@/nix-support/utils.sh
2121-2222-if [ -z "${NIX_@infixSalt@_GNAT_WRAPPER_FLAGS_SET:-}" ]; then
2323- source @out@/nix-support/add-flags.sh
2424-fi
2525-2626-2727-# Figure out if linker flags should be passed. GCC prints annoying
2828-# warnings when they are not needed.
2929-dontLink=0
3030-nonFlagArgs=0
3131-3232-for i in "$@"; do
3333- if [ "$i" = -c ]; then
3434- dontLink=1
3535- elif [ "$i" = -M ]; then
3636- dontLink=1
3737- elif [ "${i:0:1}" != - ]; then
3838- nonFlagArgs=1
3939- fi
4040-done
4141-4242-# If we pass a flag like -Wl, then gcc will call the linker unless it
4343-# can figure out that it has to do something else (e.g., because of a
4444-# "-c" flag). So if no non-flag arguments are given, don't pass any
4545-# linker flags. This catches cases like "gcc" (should just print
4646-# "gcc: no input files") and "gcc -v" (should print the version).
4747-if [ "$nonFlagArgs" = 0 ]; then
4848- dontLink=1
4949-fi
5050-5151-5252-# Optionally filter out paths not refering to the store.
5353-params=("$@")
5454-if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "$NIX_STORE" ]]; then
5555- rest=()
5656- for p in "${params[@]}"; do
5757- if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
5858- skip "${p:2}"
5959- elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then
6060- skip "${p:2}"
6161- elif [ "${p:0:4}" = -aI/ ] && badPath "${p:3}"; then
6262- skip "${p:2}"
6363- elif [ "${p:0:4}" = -aO/ ] && badPath "${p:3}"; then
6464- skip "${p:2}"
6565- else
6666- rest+=("$p")
6767- fi
6868- done
6969- params=("${rest[@]}")
7070-fi
7171-7272-7373-# Clear march/mtune=native -- they bring impurity.
7474-if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then
7575- rest=()
7676- for p in "${params[@]}"; do
7777- if [[ "$p" = -m*=native ]]; then
7878- skip "$p"
7979- else
8080- rest+=("$p")
8181- fi
8282- done
8383- params=("${rest[@]}")
8484-fi
8585-8686-8787-# Add the flags for the GNAT compiler proper.
8888-extraAfter=($NIX_@infixSalt@_GNATFLAGS_COMPILE)
8989-extraBefore=()
9090-9191-if [ "$(basename "$0")x" = "gnatmakex" ]; then
9292- extraBefore=("--GNATBIND=@out@/bin/gnatbind" "--GNATLINK=@out@/bin/gnatlink ")
9393-fi
9494-9595-#if [ "$dontLink" != 1 ]; then
9696-# # Add the flags that should be passed to the linker (and prevent
9797-# # `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
9898-# for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
9999-# extraBefore+=("-largs" "$i")
100100-# done
101101-# for i in $NIX_@infixSalt@_LDFLAGS; do
102102-# if [ "${i:0:3}" = -L/ ]; then
103103-# extraAfter+=("$i")
104104-# else
105105-# extraAfter+=("-largs" "$i")
106106-# fi
107107-# done
108108-# export NIX_@infixSalt@_LDFLAGS_SET=1
109109-#fi
110110-111111-# Optionally print debug info.
112112-if (( "${NIX_DEBUG:-0}" >= 1 )); then
113113- echo "extra flags before to @prog@:" >&2
114114- printf " %q\n" "${extraBefore[@]}" >&2
115115- echo "original flags to @prog@:" >&2
116116- printf " %q\n" "${params[@]}" >&2
117117- echo "extra flags after to @prog@:" >&2
118118- printf " %q\n" "${extraAfter[@]}" >&2
119119-fi
120120-121121-PATH="$path_backup"
122122-exec @prog@ "${extraBefore[@]}" "${params[@]}" "${extraAfter[@]}"
-40
pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh
···11-#! @shell@
22-set -eu -o pipefail +o posix
33-shopt -s nullglob
44-55-if (( "${NIX_DEBUG:-0}" >= 7 )); then
66- set -x
77-fi
88-99-# N.B. Gnat is not used during bootstrapping, so we don't need to
1010-# worry about the old bash empty array `set -u` workarounds.
1111-1212-# Add the flags for the GNAT compiler proper.
1313-extraAfter=("--GCC=@out@/bin/gcc")
1414-extraBefore=()
1515-1616-## Add the flags that should be passed to the linker (and prevent
1717-## `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
1818-#for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
1919-# extraBefore+=("-largs" "$i")
2020-#done
2121-#for i in $NIX_@infixSalt@_LDFLAGS; do
2222-# if [ "${i:0:3}" = -L/ ]; then
2323-# extraAfter+=("$i")
2424-# else
2525-# extraAfter+=("-largs" "$i")
2626-# fi
2727-#done
2828-#export NIX_@infixSalt@_LDFLAGS_SET=1
2929-3030-# Optionally print debug info.
3131-if (( "${NIX_DEBUG:-0}" >= 1 )); then
3232- echo "extra flags before to @prog@:" >&2
3333- printf " %q\n" "${extraBefore[@]}" >&2
3434- echo "original flags to @prog@:" >&2
3535- printf " %q\n" "$@" >&2
3636- echo "extra flags after to @prog@:" >&2
3737- printf " %q\n" "${extraAfter[@]}" >&2
3838-fi
3939-4040-exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}"
-28
pkgs/build-support/gcc-wrapper-old/add-flags
···11-# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
22-export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE"
33-44-if test -e @out@/nix-support/libc-cflags; then
55- export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE"
66-fi
77-88-if test -e @out@/nix-support/cc-cflags; then
99- export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE"
1010-fi
1111-1212-if test -e @out@/nix-support/gnat-cflags; then
1313- export NIX_GNATFLAGS_COMPILE="$(cat @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE"
1414-fi
1515-1616-if test -e @out@/nix-support/libc-ldflags; then
1717- export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)"
1818-fi
1919-2020-if test -e @out@/nix-support/cc-ldflags; then
2121- export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/cc-ldflags)"
2222-fi
2323-2424-if test -e @out@/nix-support/libc-ldflags-before; then
2525- export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE"
2626-fi
2727-2828-export NIX_CC_WRAPPER_FLAGS_SET=1
-215
pkgs/build-support/gcc-wrapper-old/builder.sh
···11-source $stdenv/setup
22-33-44-mkdir -p $out/bin
55-mkdir -p $out/nix-support
66-77-88-if test -z "$nativeLibc"; then
99- dynamicLinker="$libc/lib/$dynamicLinker"
1010- echo $dynamicLinker > $out/nix-support/dynamic-linker
1111-1212- if test -e $libc/lib/32/ld-linux.so.2; then
1313- echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
1414- fi
1515-1616- # The "-B$libc/lib/" flag is a quick hack to force gcc to link
1717- # against the crt1.o from our own glibc, rather than the one in
1818- # /usr/lib. (This is only an issue when using an `impure'
1919- # compiler/linker, i.e., one that searches /usr/lib and so on.)
2020- #
2121- # Unfortunately, setting -B appears to override the default search
2222- # path. Thus, the gcc-specific "../includes-fixed" directory is
2323- # now longer searched and glibc's <limits.h> header fails to
2424- # compile, because it uses "#include_next <limits.h>" to find the
2525- # limits.h file in ../includes-fixed. To remedy the problem,
2626- # another -idirafter is necessary to add that directory again.
2727- echo "-B$libc/lib/ -idirafter $libc_dev/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
2828-2929- echo "-L$libc/lib" > $out/nix-support/libc-ldflags
3030-3131- # The dynamic linker is passed in `ldflagsBefore' to allow
3232- # explicit overrides of the dynamic linker by callers to gcc/ld
3333- # (the *last* value counts, so ours should come first).
3434- echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before
3535-fi
3636-3737-if test -n "$nativeTools"; then
3838- gccPath="$nativePrefix/bin"
3939- ldPath="$nativePrefix/bin"
4040-else
4141- if test -e "$gcc/lib64"; then
4242- gccLDFlags="$gccLDFlags -L$gcc_lib/lib64"
4343- fi
4444- gccLDFlags="$gccLDFlags -L$gcc_lib/lib"
4545- if [ -n "$langVhdl" ]; then
4646- gccLDFlags="$gccLDFlags -L$zlib/lib"
4747- fi
4848- echo "$gccLDFlags" > $out/nix-support/cc-ldflags
4949-5050- # GCC shows $gcc/lib in `gcc -print-search-dirs', but not
5151- # $gcc/lib64 (even though it does actually search there...)..
5252- # This confuses libtool. So add it to the compiler tool search
5353- # path explicitly.
5454- if test -e "$gcc/lib64"; then
5555- gccCFlags="$gccCFlags -B$gcc/lib64"
5656- fi
5757-5858- # Find the gcc libraries path (may work only without multilib)
5959- if [ -n "$langAda" ]; then
6060- basePath=`echo $gcc/lib/*/*/*`
6161- gccCFlags="$gccCFlags -B$basePath -I$basePath/adainclude"
6262-6363- gnatCFlags="-aI$basePath/adainclude -aO$basePath/adalib"
6464- echo "$gnatCFlags" > $out/nix-support/gnat-cflags
6565- fi
6666- echo "$gccCFlags" > $out/nix-support/cc-cflags
6767-6868- gccPath="$gcc/bin"
6969- # On Illumos/Solaris we might prefer native ld
7070- if test -n "$nativePrefix"; then
7171- ldPath="$nativePrefix/bin"
7272- else
7373- ldPath="$binutils/bin"
7474- fi;
7575-fi
7676-7777-7878-doSubstitute() {
7979- local src=$1
8080- local dst=$2
8181- local ld="$ldPath/ld"
8282- if $ld -V 2>&1 |grep Solaris; then
8383- # Use Solaris specific linker wrapper
8484- ld="$out/bin/ld-solaris"
8585- fi
8686- # Can't use substitute() here, because replace may not have been
8787- # built yet (in the bootstrap).
8888- sed \
8989- -e "s^@out@^$out^g" \
9090- -e "s^@shell@^$shell^g" \
9191- -e "s^@gcc@^$gcc^g" \
9292- -e "s^@gccProg@^$gccProg^g" \
9393- -e "s^@gnatProg@^$gnatProg^g" \
9494- -e "s^@gnatlinkProg@^$gnatlinkProg^g" \
9595- -e "s^@binutils@^$binutils^g" \
9696- -e "s^@coreutils@^$coreutils^g" \
9797- -e "s^@libc@^$libc^g" \
9898- -e "s^@libc_bin@^$libc_bin^g" \
9999- -e "s^@ld@^$ld^g" \
100100- < "$src" > "$dst"
101101-}
102102-103103-104104-# Make wrapper scripts around gcc, g++, and gfortran. Also make symlinks
105105-# cc, c++, and f77.
106106-mkGccWrapper() {
107107- local dst=$1
108108- local src=$2
109109-110110- if ! test -f "$src"; then
111111- echo "$src does not exist (skipping)"
112112- return 1
113113- fi
114114-115115- gccProg="$src"
116116- doSubstitute "$gccWrapper" "$dst"
117117- chmod +x "$dst"
118118-}
119119-120120-mkGnatWrapper() {
121121- local dst=$1
122122- local src=$2
123123-124124- if ! test -f "$src"; then
125125- echo "$src does not exist (skipping)"
126126- return 1
127127- fi
128128-129129- gnatProg="$src"
130130- doSubstitute "$gnatWrapper" "$dst"
131131- chmod +x "$dst"
132132-}
133133-134134-mkGnatLinkWrapper() {
135135- local dst=$1
136136- local src=$2
137137-138138- if ! test -f "$src"; then
139139- echo "$src does not exist (skipping)"
140140- return 1
141141- fi
142142-143143- gnatlinkProg="$src"
144144- doSubstitute "$gnatlinkWrapper" "$dst"
145145- chmod +x "$dst"
146146-}
147147-148148-if mkGccWrapper $out/bin/gcc $gccPath/gcc
149149-then
150150- ln -sv gcc $out/bin/cc
151151-fi
152152-153153-if mkGccWrapper $out/bin/g++ $gccPath/g++
154154-then
155155- ln -sv g++ $out/bin/c++
156156-fi
157157-158158-mkGccWrapper $out/bin/cpp $gccPath/cpp || true
159159-160160-if mkGccWrapper $out/bin/gfortran $gccPath/gfortran
161161-then
162162- ln -sv gfortran $out/bin/g77
163163- ln -sv gfortran $out/bin/f77
164164-fi
165165-166166-mkGccWrapper $out/bin/gcj $gccPath/gcj || true
167167-168168-mkGccWrapper $out/bin/gccgo $gccPath/gccgo || true
169169-170170-mkGccWrapper $out/bin/gnatgcc $gccPath/gnatgcc || true
171171-mkGnatWrapper $out/bin/gnatmake $gccPath/gnatmake || true
172172-mkGnatWrapper $out/bin/gnatbind $gccPath/gnatbind || true
173173-mkGnatLinkWrapper $out/bin/gnatlink $gccPath/gnatlink || true
174174-175175-if [ -f $gccPath/ghdl ]; then
176176- ln -sf $gccPath/ghdl $out/bin/ghdl
177177-fi
178178-179179-180180-# Create a symlink to as (the assembler). This is useful when a
181181-# gcc-wrapper is installed in a user environment, as it ensures that
182182-# the right assembler is called.
183183-ln -s $ldPath/as $out/bin/as
184184-185185-186186-# Make a wrapper around the linker.
187187-doSubstitute "$ldWrapper" "$out/bin/ld"
188188-chmod +x "$out/bin/ld"
189189-190190-# Copy solaris ld wrapper if needed
191191-if $ldPath/ld -V 2>&1 |grep Solaris; then
192192- # Use Solaris specific linker wrapper
193193- sed -e "s^@ld@^$ldPath/ld^g" < "$ldSolarisWrapper" > "$out/bin/ld-solaris"
194194- chmod +x "$out/bin/ld-solaris"
195195-fi
196196-197197-198198-# Emit a setup hook. Also store the path to the original GCC and
199199-# Glibc.
200200-test -n "$gcc" && echo $gcc > $out/nix-support/orig-cc
201201-test -n "$libc" && echo $libc > $out/nix-support/orig-libc
202202-203203-doSubstitute "$addFlags" "$out/nix-support/add-flags.sh"
204204-205205-doSubstitute "$setupHook" "$out/nix-support/setup-hook"
206206-207207-cp -p $utils $out/nix-support/utils.sh
208208-209209-210210-# Propagate the wrapped gcc so that if you install the wrapper, you get
211211-# tools like gcov, the manpages, etc. as well (including for binutils
212212-# and Glibc).
213213-if test -z "$nativeTools"; then
214214- printWords $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages
215215-fi
-76
pkgs/build-support/gcc-wrapper-old/default.nix
···11-# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
22-# know where the C library and standard header files are. Therefore
33-# the compiler produced by that package cannot be installed directly
44-# in a user environment and used from the command line. This
55-# stdenv.mkDerivation provides a wrapper that sets up the right environment
66-# variables so that the compiler and the linker just "work".
77-88-{ name ? "", stdenv, lib, nativeTools, nativeLibc, nativePrefix ? ""
99-, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell
1010-, zlib ? null
1111-, hostPlatform, targetPlatform, targetPackages
1212-}:
1313-1414-assert nativeTools -> nativePrefix != "";
1515-assert !nativeTools -> gcc != null && binutils != null && coreutils != null;
1616-assert !nativeLibc -> libc != null;
1717-1818-# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper
1919-assert (gcc != null && gcc ? langVhdl && gcc.langVhdl) -> zlib != null;
2020-2121-let
2222-2323- gccVersion = (builtins.parseDrvName gcc.name).version;
2424- gccName = (builtins.parseDrvName gcc.name).name;
2525-2626- langGo = if nativeTools then false else gcc ? langGo && gcc.langGo;
2727-in
2828-2929-stdenv.mkDerivation {
3030- name =
3131- (if name != "" then name else gccName + "-wrapper") +
3232- (if gcc != null && gccVersion != "" then "-" + gccVersion else "");
3333-3434- builder = ./builder.sh;
3535- setupHook = ./setup-hook.sh;
3636- gccWrapper = ./gcc-wrapper.sh;
3737- gnatWrapper = ./gnat-wrapper.sh;
3838- gnatlinkWrapper = ./gnatlink-wrapper.sh;
3939- ldWrapper = ./ld-wrapper.sh;
4040- ldSolarisWrapper = ./ld-solaris-wrapper.sh;
4141- utils = ./utils.sh;
4242- addFlags = ./add-flags;
4343-4444- inherit nativeTools nativeLibc nativePrefix gcc;
4545- gcc_lib = lib.getLib gcc;
4646- libc = if nativeLibc then null else libc;
4747- libc_dev = if nativeLibc then null else lib.getDev libc;
4848- libc_bin = if nativeLibc then null else lib.getBin libc;
4949- binutils = if nativeTools then null else lib.getBin binutils;
5050- # The wrapper scripts use 'cat', so we may need coreutils
5151- coreutils = if nativeTools then null else lib.getBin coreutils;
5252-5353- langC = if nativeTools then true else gcc.langC;
5454- langCC = if nativeTools then true else gcc.langCC;
5555- langFortran = if nativeTools then false else gcc ? langFortran;
5656- langAda = if nativeTools then false else gcc ? langAda && gcc.langAda;
5757- langVhdl = if nativeTools then false else gcc ? langVhdl && gcc.langVhdl;
5858- zlib = if gcc != null && gcc ? langVhdl then zlib else null;
5959- shell = shell + shell.shellPath or "";
6060-6161- preferLocalBuild = true;
6262-6363- meta =
6464- let gcc_ = if gcc != null then gcc else {}; in
6565- (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) //
6666- { description =
6767- stdenv.lib.attrByPath ["meta" "description"] "System C compiler" gcc_
6868- + " (wrapper script)";
6969- };
7070-7171- # The dynamic linker has different names on different platforms.
7272- dynamicLinker =
7373- if !nativeLibc then
7474- targetPackages.stdenv.cc.bintools.dynamicLinker
7575- else "";
7676-}
···11-#! @shell@ -e
22-33-if [ -n "$NIX_CC_WRAPPER_START_HOOK" ]; then
44- source "$NIX_CC_WRAPPER_START_HOOK"
55-fi
66-77-if [ -z "$NIX_CC_WRAPPER_FLAGS_SET" ]; then
88- source @out@/nix-support/add-flags.sh
99-fi
1010-1111-source @out@/nix-support/utils.sh
1212-1313-1414-# Figure out if linker flags should be passed. GCC prints annoying
1515-# warnings when they are not needed.
1616-dontLink=0
1717-getVersion=0
1818-nonFlagArgs=0
1919-2020-for i in "$@"; do
2121- if [ "$i" = -c ]; then
2222- dontLink=1
2323- elif [ "$i" = -S ]; then
2424- dontLink=1
2525- elif [ "$i" = -E ]; then
2626- dontLink=1
2727- elif [ "$i" = -E ]; then
2828- dontLink=1
2929- elif [ "$i" = -M ]; then
3030- dontLink=1
3131- elif [ "$i" = -MM ]; then
3232- dontLink=1
3333- elif [ "$i" = -x ]; then
3434- # At least for the cases c-header or c++-header we should set dontLink.
3535- # I expect no one use -x other than making precompiled headers.
3636- dontLink=1
3737- elif [ "${i:0:1}" != - ]; then
3838- nonFlagArgs=1
3939- elif [ "$i" = -m32 ]; then
4040- if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
4141- NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
4242- fi
4343- fi
4444-done
4545-4646-# If we pass a flag like -Wl, then gcc will call the linker unless it
4747-# can figure out that it has to do something else (e.g., because of a
4848-# "-c" flag). So if no non-flag arguments are given, don't pass any
4949-# linker flags. This catches cases like "gcc" (should just print
5050-# "gcc: no input files") and "gcc -v" (should print the version).
5151-if [ "$nonFlagArgs" = 0 ]; then
5252- dontLink=1
5353-fi
5454-5555-5656-# Optionally filter out paths not refering to the store.
5757-params=("$@")
5858-if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then
5959- rest=()
6060- n=0
6161- while [ $n -lt ${#params[*]} ]; do
6262- p=${params[n]}
6363- p2=${params[$((n+1))]}
6464- if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
6565- skip $p
6666- elif [ "$p" = -L ] && badPath "$p2"; then
6767- n=$((n + 1)); skip $p2
6868- elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then
6969- skip $p
7070- elif [ "$p" = -I ] && badPath "$p2"; then
7171- n=$((n + 1)); skip $p2
7272- elif [ "$p" = -isystem ] && badPath "$p2"; then
7373- n=$((n + 1)); skip $p2
7474- else
7575- rest=("${rest[@]}" "$p")
7676- fi
7777- n=$((n + 1))
7878- done
7979- params=("${rest[@]}")
8080-fi
8181-8282-8383-# Add the flags for the C compiler proper.
8484-extraAfter=($NIX_CFLAGS_COMPILE)
8585-extraBefore=()
8686-8787-# When enforcing purity, pretend gcc can't find the current date and
8888-# time
8989-if [ "$NIX_ENFORCE_PURITY" = 1 ]; then
9090- extraAfter+=('-D__DATE__="Jan 01 1970"'
9191- '-D__TIME__="00:00:01"'
9292- )
9393-fi
9494-9595-9696-if [ "$dontLink" != 1 ]; then
9797-9898- # Add the flags that should only be passed to the compiler when
9999- # linking.
100100- extraAfter+=($NIX_CFLAGS_LINK)
101101-102102- # Add the flags that should be passed to the linker (and prevent
103103- # `ld-wrapper' from adding NIX_LDFLAGS again).
104104- for i in $NIX_LDFLAGS_BEFORE; do
105105- extraBefore=(${extraBefore[@]} "-Wl,$i")
106106- done
107107- for i in $NIX_LDFLAGS; do
108108- if [ "${i:0:3}" = -L/ ]; then
109109- extraAfter+=("$i")
110110- else
111111- extraAfter+=("-Wl,$i")
112112- fi
113113- done
114114- export NIX_LDFLAGS_SET=1
115115-fi
116116-117117-# As a very special hack, if the arguments are just `-v', then don't
118118-# add anything. This is to prevent `gcc -v' (which normally prints
119119-# out the version number and returns exit code 0) from printing out
120120-# `No input files specified' and returning exit code 1.
121121-if [ "$*" = -v ]; then
122122- extraAfter=()
123123- extraBefore=()
124124-fi
125125-126126-# Optionally print debug info.
127127-if [ -n "$NIX_DEBUG" ]; then
128128- echo "original flags to @prog@:" >&2
129129- for i in "${params[@]}"; do
130130- echo " $i" >&2
131131- done
132132- echo "extraBefore flags to @prog@:" >&2
133133- for i in ${extraBefore[@]}; do
134134- echo " $i" >&2
135135- done
136136- echo "extraAfter flags to @prog@:" >&2
137137- for i in ${extraAfter[@]}; do
138138- echo " $i" >&2
139139- done
140140-fi
141141-142142-if [ -n "$NIX_CC_WRAPPER_EXEC_HOOK" ]; then
143143- source "$NIX_CC_WRAPPER_EXEC_HOOK"
144144-fi
145145-146146-exec @prog@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}"
-147
pkgs/build-support/gcc-wrapper-old/gcc-wrapper.sh
···11-#! @shell@ -e
22-33-if test -n "$NIX_CC_WRAPPER_START_HOOK"; then
44- source "$NIX_CC_WRAPPER_START_HOOK"
55-fi
66-77-if test -z "$NIX_CC_WRAPPER_FLAGS_SET"; then
88- source @out@/nix-support/add-flags.sh
99-fi
1010-1111-source @out@/nix-support/utils.sh
1212-1313-1414-# Figure out if linker flags should be passed. GCC prints annoying
1515-# warnings when they are not needed.
1616-dontLink=0
1717-getVersion=0
1818-nonFlagArgs=0
1919-2020-for i in "$@"; do
2121- if test "$i" = "-c"; then
2222- dontLink=1
2323- elif test "$i" = "-S"; then
2424- dontLink=1
2525- elif test "$i" = "-E"; then
2626- dontLink=1
2727- elif test "$i" = "-E"; then
2828- dontLink=1
2929- elif test "$i" = "-M"; then
3030- dontLink=1
3131- elif test "$i" = "-MM"; then
3232- dontLink=1
3333- elif test "$i" = "-x"; then
3434- # At least for the cases c-header or c++-header we should set dontLink.
3535- # I expect no one use -x other than making precompiled headers.
3636- dontLink=1
3737- elif test "${i:0:1}" != "-"; then
3838- nonFlagArgs=1
3939- elif test "$i" = "-m32"; then
4040- if test -e @out@/nix-support/dynamic-linker-m32; then
4141- NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
4242- fi
4343- fi
4444-done
4545-4646-# If we pass a flag like -Wl, then gcc will call the linker unless it
4747-# can figure out that it has to do something else (e.g., because of a
4848-# "-c" flag). So if no non-flag arguments are given, don't pass any
4949-# linker flags. This catches cases like "gcc" (should just print
5050-# "gcc: no input files") and "gcc -v" (should print the version).
5151-if test "$nonFlagArgs" = "0"; then
5252- dontLink=1
5353-fi
5454-5555-5656-# Optionally filter out paths not refering to the store.
5757-params=("$@")
5858-if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
5959- rest=()
6060- n=0
6161- while test $n -lt ${#params[*]}; do
6262- p=${params[n]}
6363- p2=${params[$((n+1))]}
6464- if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
6565- skip $p
6666- elif test "$p" = "-L" && badPath "$p2"; then
6767- n=$((n + 1)); skip $p2
6868- elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
6969- skip $p
7070- elif test "$p" = "-I" && badPath "$p2"; then
7171- n=$((n + 1)); skip $p2
7272- elif test "$p" = "-isystem" && badPath "$p2"; then
7373- n=$((n + 1)); skip $p2
7474- else
7575- rest=("${rest[@]}" "$p")
7676- fi
7777- n=$((n + 1))
7878- done
7979- params=("${rest[@]}")
8080-fi
8181-8282-8383-# Add the flags for the C compiler proper.
8484-extraAfter=($NIX_CFLAGS_COMPILE)
8585-extraBefore=()
8686-8787-if test "$dontLink" != "1"; then
8888-8989- # Add the flags that should only be passed to the compiler when
9090- # linking.
9191- extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK)
9292-9393- # Add the flags that should be passed to the linker (and prevent
9494- # `ld-wrapper' from adding NIX_LDFLAGS again).
9595- for i in $NIX_LDFLAGS_BEFORE; do
9696- extraBefore=(${extraBefore[@]} "-Wl,$i")
9797- done
9898- for i in $NIX_LDFLAGS; do
9999- if test "${i:0:3}" = "-L/"; then
100100- extraAfter=(${extraAfter[@]} "$i")
101101- else
102102- extraAfter=(${extraAfter[@]} "-Wl,$i")
103103- fi
104104- done
105105- export NIX_LDFLAGS_SET=1
106106-fi
107107-108108-# As a very special hack, if the arguments are just `-v', then don't
109109-# add anything. This is to prevent `gcc -v' (which normally prints
110110-# out the version number and returns exit code 0) from printing out
111111-# `No input files specified' and returning exit code 1.
112112-if test "$*" = "-v"; then
113113- extraAfter=()
114114- extraBefore=()
115115-fi
116116-117117-# Optionally print debug info.
118118-if test "$NIX_DEBUG" = "1"; then
119119- echo "original flags to @gccProg@:" >&2
120120- for i in "${params[@]}"; do
121121- echo " $i" >&2
122122- done
123123- echo "extraBefore flags to @gccProg@:" >&2
124124- for i in ${extraBefore[@]}; do
125125- echo " $i" >&2
126126- done
127127- echo "extraAfter flags to @gccProg@:" >&2
128128- for i in ${extraAfter[@]}; do
129129- echo " $i" >&2
130130- done
131131-fi
132132-133133-if test -n "$NIX_CC_WRAPPER_EXEC_HOOK"; then
134134- source "$NIX_CC_WRAPPER_EXEC_HOOK"
135135-fi
136136-137137-138138-# Call the real `gcc'. Filter out warnings from stderr about unused
139139-# `-B' flags, since they confuse some programs. Deep bash magic to
140140-# apply grep to stderr (by swapping stdin/stderr twice).
141141-if test -z "$NIX_CC_NEEDS_GREP"; then
142142- @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
143143-else
144144- (@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
145145- | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
146146- exit $?
147147-fi
···11-#! @shell@ -e
22-33-if test -n "$NIX_GNAT_WRAPPER_START_HOOK"; then
44- source "$NIX_GNAT_WRAPPER_START_HOOK"
55-fi
66-77-if test -z "$NIX_GNAT_WRAPPER_FLAGS_SET"; then
88- source @out@/nix-support/add-flags.sh
99-fi
1010-1111-source @out@/nix-support/utils.sh
1212-1313-1414-# Figure out if linker flags should be passed. GCC prints annoying
1515-# warnings when they are not needed.
1616-dontLink=0
1717-getVersion=0
1818-nonFlagArgs=0
1919-2020-for i in "$@"; do
2121- if test "$i" = "-c"; then
2222- dontLink=1
2323- elif test "$i" = "-M"; then
2424- dontLink=1
2525- elif test "${i:0:1}" != "-"; then
2626- nonFlagArgs=1
2727- elif test "$i" = "-m32"; then
2828- if test -e @out@/nix-support/dynamic-linker-m32; then
2929- NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)"
3030- fi
3131- fi
3232-done
3333-3434-# If we pass a flag like -Wl, then gcc will call the linker unless it
3535-# can figure out that it has to do something else (e.g., because of a
3636-# "-c" flag). So if no non-flag arguments are given, don't pass any
3737-# linker flags. This catches cases like "gcc" (should just print
3838-# "gcc: no input files") and "gcc -v" (should print the version).
3939-if test "$nonFlagArgs" = "0"; then
4040- dontLink=1
4141-fi
4242-4343-4444-# Optionally filter out paths not refering to the store.
4545-params=("$@")
4646-if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
4747- rest=()
4848- n=0
4949- while test $n -lt ${#params[*]}; do
5050- p=${params[n]}
5151- p2=${params[$((n+1))]}
5252- if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
5353- skip $p
5454- elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
5555- skip $p
5656- elif test "${p:0:4}" = "-aI/" && badPath "${p:3}"; then
5757- skip $p
5858- elif test "${p:0:4}" = "-aO/" && badPath "${p:3}"; then
5959- skip $p
6060- else
6161- rest=("${rest[@]}" "$p")
6262- fi
6363- n=$((n + 1))
6464- done
6565- params=("${rest[@]}")
6666-fi
6767-6868-6969-# Add the flags for the GNAT compiler proper.
7070-extraAfter=($NIX_GNATFLAGS_COMPILE)
7171-extraBefore=()
7272-7373-if [ "`basename $0`x" = "gnatmakex" ]; then
7474- extraBefore=("--GNATBIND=@out@/bin/gnatbind --GNATLINK=@out@/bin/gnatlink ")
7575-fi
7676-7777-# Add the flags that should be passed to the linker (and prevent
7878-# `ld-wrapper' from adding NIX_LDFLAGS again).
7979-#for i in $NIX_LDFLAGS_BEFORE; do
8080-# extraBefore=(${extraBefore[@]} "-largs $i")
8181-#done
8282-8383-# Optionally print debug info.
8484-if test "$NIX_DEBUG" = "1"; then
8585- echo "original flags to @gnatProg@:" >&2
8686- for i in "${params[@]}"; do
8787- echo " $i" >&2
8888- done
8989- echo "extraBefore flags to @gnatProg@:" >&2
9090- for i in ${extraBefore[@]}; do
9191- echo " $i" >&2
9292- done
9393- echo "extraAfter flags to @gnatProg@:" >&2
9494- for i in ${extraAfter[@]}; do
9595- echo " $i" >&2
9696- done
9797-fi
9898-9999-if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then
100100- source "$NIX_GNAT_WRAPPER_EXEC_HOOK"
101101-fi
102102-103103-104104-# Call the real `gcc'. Filter out warnings from stderr about unused
105105-# `-B' flags, since they confuse some programs. Deep bash magic to
106106-# apply grep to stderr (by swapping stdin/stderr twice).
107107-if test -z "$NIX_GNAT_NEEDS_GREP"; then
108108- @gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
109109-else
110110- (@gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
111111- | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
112112- exit $?
113113-fi
···11-#! @shell@ -e
22-33-# Add the flags for the GNAT compiler proper.
44-extraAfter="--GCC=@out@/bin/gcc"
55-extraBefore=()
66-77-# Add the flags that should be passed to the linker (and prevent
88-# `ld-wrapper' from adding NIX_LDFLAGS again).
99-#for i in $NIX_LDFLAGS_BEFORE; do
1010-# extraBefore=(${extraBefore[@]} "-largs $i")
1111-#done
1212-1313-# Optionally print debug info.
1414-if test "$NIX_DEBUG" = "1"; then
1515- echo "original flags to @gnatlinkProg@:" >&2
1616- for i in "$@"; do
1717- echo " $i" >&2
1818- done
1919- echo "extraBefore flags to @gnatlinkProg@:" >&2
2020- for i in ${extraBefore[@]}; do
2121- echo " $i" >&2
2222- done
2323- echo "extraAfter flags to @gnatlinkProg@:" >&2
2424- for i in ${extraAfter[@]}; do
2525- echo " $i" >&2
2626- done
2727-fi
2828-2929-if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then
3030- source "$NIX_GNAT_WRAPPER_EXEC_HOOK"
3131-fi
3232-3333-3434-# Call the real `gcc'. Filter out warnings from stderr about unused
3535-# `-B' flags, since they confuse some programs. Deep bash magic to
3636-# apply grep to stderr (by swapping stdin/stderr twice).
3737-if test -z "$NIX_GNAT_NEEDS_GREP"; then
3838- @gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]}
3939-else
4040- (@gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
4141- | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
4242- exit $?
4343-fi
···11-#!@shell@
22-33-set -e
44-set -u
55-66-# I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'(
77-# Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3
88-# but still no success.
99-cmd="@ld@ -z ignore"
1010-1111-args=("$@");
1212-1313-# This loop makes sure all -L arguments are before -l arguments, or ld may complain it cannot find a library.
1414-# GNU binutils does not have this problem:
1515-# http://stackoverflow.com/questions/5817269/does-the-order-of-l-and-l-options-in-the-gnu-linker-matter
1616-i=0;
1717-while [[ $i -lt $# ]]; do
1818- case "${args[$i]}" in
1919- -L) cmd="$cmd ${args[$i]} ${args[($i+1)]}"; i=($i+1); ;;
2020- -L*) cmd="$cmd ${args[$i]}" ;;
2121- *) ;;
2222- esac
2323- i=($i+1);
2424-done
2525-2626-i=0;
2727-while [[ $i -lt $# ]]; do
2828- case "${args[$i]}" in
2929- -L) i=($i+1); ;;
3030- -L*) ;;
3131- *) cmd="$cmd ${args[$i]}" ;;
3232- esac
3333- i=($i+1);
3434-done
3535-3636-# Trace:
3737-set -x
3838-exec $cmd
3939-4040-exit 0
-166
pkgs/build-support/gcc-wrapper-old/ld-wrapper.sh
···11-#! @shell@ -e
22-33-if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
44- source "$NIX_LD_WRAPPER_START_HOOK"
55-fi
66-77-if test -z "$NIX_CC_WRAPPER_FLAGS_SET"; then
88- source @out@/nix-support/add-flags.sh
99-fi
1010-1111-source @out@/nix-support/utils.sh
1212-1313-1414-# Optionally filter out paths not refering to the store.
1515-params=("$@")
1616-if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
1717- -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then
1818- rest=()
1919- n=0
2020- while test $n -lt ${#params[*]}; do
2121- p=${params[n]}
2222- p2=${params[$((n+1))]}
2323- if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
2424- skip $p
2525- elif test "$p" = "-L" && badPath "$p2"; then
2626- n=$((n + 1)); skip $p2
2727- elif test "$p" = "-rpath" && badPath "$p2"; then
2828- n=$((n + 1)); skip $p2
2929- elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
3030- n=$((n + 1)); skip $p2
3131- elif test "${p:0:1}" = "/" && badPath "$p"; then
3232- # We cannot skip this; barf.
3333- echo "impure path \`$p' used in link" >&2
3434- exit 1
3535- elif test "${p:0:9}" = "--sysroot"; then
3636- # Our ld is not built with sysroot support (Can we fix that?)
3737- :
3838- else
3939- rest=("${rest[@]}" "$p")
4040- fi
4141- n=$((n + 1))
4242- done
4343- params=("${rest[@]}")
4444-fi
4545-4646-4747-extra=()
4848-extraBefore=()
4949-5050-if test -z "$NIX_LDFLAGS_SET"; then
5151- extra+=($NIX_LDFLAGS)
5252- extraBefore+=($NIX_LDFLAGS_BEFORE)
5353-fi
5454-5555-extra+=($NIX_LDFLAGS_AFTER)
5656-5757-5858-# Add all used dynamic libraries to the rpath.
5959-if test "$NIX_DONT_SET_RPATH" != "1"; then
6060-6161- libPath=""
6262- addToLibPath() {
6363- local path="$1"
6464- if test "${path:0:1}" != "/"; then return 0; fi
6565- case "$path" in
6666- *..*|*./*|*/.*|*//*)
6767- local path2
6868- if path2=$(readlink -f "$path"); then
6969- path="$path2"
7070- fi
7171- ;;
7272- esac
7373- case $libPath in
7474- *\ $path\ *) return 0 ;;
7575- esac
7676- libPath="$libPath $path "
7777- }
7878-7979- addToRPath() {
8080- # If the path is not in the store, don't add it to the rpath.
8181- # This typically happens for libraries in /tmp that are later
8282- # copied to $out/lib. If not, we're screwed.
8383- if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
8484- case $rpath in
8585- *\ $1\ *) return 0 ;;
8686- esac
8787- rpath="$rpath $1 "
8888- }
8989-9090- libs=""
9191- addToLibs() {
9292- libs="$libs $1"
9393- }
9494-9595- rpath=""
9696-9797- # First, find all -L... switches.
9898- allParams=("${params[@]}" ${extra[@]})
9999- n=0
100100- while test $n -lt ${#allParams[*]}; do
101101- p=${allParams[n]}
102102- p2=${allParams[$((n+1))]}
103103- if test "${p:0:3}" = "-L/"; then
104104- addToLibPath ${p:2}
105105- elif test "$p" = "-L"; then
106106- addToLibPath ${p2}
107107- n=$((n + 1))
108108- elif test "$p" = "-l"; then
109109- addToLibs ${p2}
110110- n=$((n + 1))
111111- elif test "${p:0:2}" = "-l"; then
112112- addToLibs ${p:2}
113113- elif test "$p" = "-dynamic-linker"; then
114114- # Ignore the dynamic linker argument, or it
115115- # will get into the next 'elif'. We don't want
116116- # the dynamic linker path rpath to go always first.
117117- n=$((n + 1))
118118- elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
119119- # This is a direct reference to a shared library, so add
120120- # its directory to the rpath.
121121- path="$(dirname "$p")";
122122- addToRPath "${path}"
123123- fi
124124- n=$((n + 1))
125125- done
126126-127127- # Second, for each directory in the library search path (-L...),
128128- # see if it contains a dynamic library used by a -l... flag. If
129129- # so, add the directory to the rpath.
130130- # It's important to add the rpath in the order of -L..., so
131131- # the link time chosen objects will be those of runtime linking.
132132-133133- for i in $libPath; do
134134- for j in $libs; do
135135- if test -f "$i/lib$j.so"; then
136136- addToRPath $i
137137- break
138138- fi
139139- done
140140- done
141141-142142-143143- # Finally, add `-rpath' switches.
144144- for i in $rpath; do
145145- extra=(${extra[@]} -rpath $i)
146146- done
147147-fi
148148-149149-150150-# Optionally print debug info.
151151-if test "$NIX_DEBUG" = "1"; then
152152- echo "original flags to @ld@:" >&2
153153- for i in "${params[@]}"; do
154154- echo " $i" >&2
155155- done
156156- echo "extra flags to @ld@:" >&2
157157- for i in ${extra[@]}; do
158158- echo " $i" >&2
159159- done
160160-fi
161161-162162-if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
163163- source "$NIX_LD_WRAPPER_EXEC_HOOK"
164164-fi
165165-166166-exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}
-33
pkgs/build-support/gcc-wrapper-old/setup-hook.sh
···11-gccWrapperOld_addCVars () {
22- if test -d $1/include; then
33- export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include"
44- fi
55-66- if test -d $1/lib64; then
77- export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64"
88- fi
99-1010- if test -d $1/lib; then
1111- export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib"
1212- fi
1313-}
1414-1515-envBuildBuildHooks+=(gccWrapperOld_addCVars)
1616-1717-# Note: these come *after* $out in the PATH (see setup.sh).
1818-1919-if test -n "@gcc@"; then
2020- addToSearchPath PATH @gcc@/bin
2121-fi
2222-2323-if test -n "@binutils@"; then
2424- addToSearchPath PATH @binutils@/bin
2525-fi
2626-2727-if test -n "@libc@"; then
2828- addToSearchPath PATH @libc_bin@/bin
2929-fi
3030-3131-if test -n "@coreutils@"; then
3232- addToSearchPath PATH @coreutils@/bin
3333-fi
-26
pkgs/build-support/gcc-wrapper-old/utils.sh
···11-skip () {
22- if test "$NIX_DEBUG" = "1"; then
33- echo "skipping impure path $1" >&2
44- fi
55-}
66-77-88-# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but
99-# `/nix/store/.../lib/foo.so' isn't.
1010-badPath() {
1111- local p=$1
1212-1313- # Relative paths are okay (since they're presumably relative to
1414- # the temporary build directory).
1515- if test "${p:0:1}" != "/"; then return 1; fi
1616-1717- @extraPathTests@
1818-1919- # Otherwise, the path should refer to the store or some temporary
2020- # directory (including the build directory).
2121- test \
2222- "$p" != "/dev/null" -a \
2323- "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
2424- "${p:0:4}" != "/tmp" -a \
2525- "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
2626-}
-472
pkgs/development/compilers/gcc/4.5/default.nix
···11-{ stdenv, targetPackages, fetchurl, noSysDirs
22-, langC ? true, langCC ? true, langFortran ? false
33-, langJava ? false
44-, langAda ? false
55-, langVhdl ? false
66-, profiledCompiler ? false
77-, staticCompiler ? false
88-, enableShared ? true
99-, texinfo ? null
1010-, perl ? null # optional, for texi2pod (then pod2man); required for Java
1111-, gmp, mpfr, libmpc, gettext, which
1212-, libelf # optional, for link-time optimizations (LTO)
1313-, ppl ? null, cloogppl ? null # optional, for the Graphite optimization framework
1414-, zlib ? null, boehmgc ? null
1515-, zip ? null, unzip ? null, pkgconfig ? null, gtk2 ? null, libart_lgpl ? null
1616-, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
1717-, libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
1818-, libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
1919-, gnatboot ? null
2020-, enableMultilib ? false
2121-, name ? "gcc"
2222-, libcCross ? null
2323-, crossStageStatic ? false
2424-, gnat ? null
2525-, libpthread ? null, libpthreadCross ? null # required for GNU/Hurd
2626-, stripped ? true
2727-, buildPlatform, hostPlatform, targetPlatform
2828-, buildPackages
2929-}:
3030-3131-assert langJava -> zip != null && unzip != null
3232- && zlib != null && boehmgc != null
3333- && perl != null; # for `--enable-java-home'
3434-assert langAda -> gnatboot != null;
3535-assert langVhdl -> gnat != null;
3636-3737-# LTO needs libelf and zlib.
3838-assert libelf != null -> zlib != null;
3939-4040-with stdenv.lib;
4141-with builtins;
4242-4343-let version = "4.5.4";
4444- javaEcj = fetchurl {
4545- # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
4646- # `configure' time.
4747-4848- # XXX: Eventually we might want to take it from upstream.
4949- url = "ftp://sourceware.org/pub/java/ecj-4.3.jar";
5050- sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx";
5151- };
5252-5353- # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a
5454- # binary distribution here to allow the whole chain to be bootstrapped.
5555- javaAntlr = fetchurl {
5656- url = http://www.antlr.org/download/antlr-3.1.3.jar;
5757- sha256 = "1f41j0y4kjydl71lqlvr73yagrs2jsg1fjymzjz66mjy7al5lh09";
5858- };
5959-6060- xlibs = [
6161- libX11 libXt libSM libICE libXtst libXrender libXrandr libXi
6262- xproto renderproto xextproto inputproto randrproto
6363- ];
6464-6565- javaAwtGtk = langJava && gtk2 != null;
6666-6767- /* Platform flags */
6868- platformFlags = let
6969- gccArch = targetPlatform.platform.gcc.arch or null;
7070- gccCpu = targetPlatform.platform.gcc.cpu or null;
7171- gccAbi = targetPlatform.platform.gcc.abi or null;
7272- gccFpu = targetPlatform.platform.gcc.fpu or null;
7373- gccFloat = targetPlatform.platform.gcc.float or null;
7474- gccMode = targetPlatform.platform.gcc.mode or null;
7575- in
7676- optional (gccArch != null) "--with-arch=${gccArch}" ++
7777- optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
7878- optional (gccAbi != null) "--with-abi=${gccAbi}" ++
7979- optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
8080- optional (gccFloat != null) "--with-float=${gccFloat}" ++
8181- optional (gccMode != null) "--with-mode=${gccMode}";
8282-8383- /* Cross-gcc settings */
8484- crossMingw = (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt");
8585-8686- crossConfigureFlags =
8787- # Ensure that -print-prog-name is able to find the correct programs.
8888- [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
8989- "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
9090- (if crossMingw && crossStageStatic then [
9191- "--with-headers=${libcCross}/include"
9292- "--with-gcc"
9393- "--with-gnu-as"
9494- "--with-gnu-ld"
9595- "--with-gnu-ld"
9696- "--disable-shared"
9797- "--disable-nls"
9898- "--disable-debug"
9999- "--enable-sjlj-exceptions"
100100- "--enable-threads=win32"
101101- "--disable-win32-registry"
102102- ] else if crossStageStatic then [
103103- "--disable-libssp"
104104- "--disable-nls"
105105- "--without-headers"
106106- "--disable-threads"
107107- "--disable-libmudflap"
108108- "--disable-libgomp"
109109- "--disable-shared"
110110- "--disable-decimal-float" # libdecnumber requires libc
111111- ] else [
112112- "--with-headers=${libcCross}/include"
113113- "--enable-__cxa_atexit"
114114- "--enable-long-long"
115115- ] ++
116116- (if crossMingw then [
117117- "--enable-threads=win32"
118118- "--enable-sjlj-exceptions"
119119- "--enable-hash-synchronization"
120120- "--enable-version-specific-runtime-libs"
121121- "--enable-libssp"
122122- "--disable-nls"
123123- "--with-dwarf2"
124124- ] else [
125125- "--enable-threads=posix"
126126- "--enable-nls"
127127- "--disable-decimal-float" # No final libdecnumber (it may work only in 386)
128128- ]));
129129- stageNameAddon = if crossStageStatic then "-stage-static" else
130130- "-stage-final";
131131- crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
132132-133133-in
134134-135135-# We need all these X libraries when building AWT with GTK+.
136136-assert gtk2 != null -> (filter (x: x == null) xlibs) == [];
137137-138138-stdenv.mkDerivation ({
139139- name = "${name}-${version}" + crossNameAddon;
140140-141141- builder = ../builder.sh;
142142-143143- src = (import ./sources.nix) {
144144- inherit fetchurl optional version;
145145- inherit langC langCC langFortran langJava langAda;
146146- };
147147-148148- hardeningDisable = [ "format" ] ++ optional (name != "gnat") "all";
149149-150150- outputs = [ "out" "man" "info" ]
151151- ++ optional (!(hostPlatform.is64bit && langAda)) "lib";
152152-153153- setOutputFlags = false;
154154- NIX_NO_SELF_RPATH = true;
155155-156156- libc_dev = stdenv.cc.libc_dev;
157157-158158- patches =
159159- [ ]
160160- ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
161161- ++ optional noSysDirs ./no-sys-dirs.patch
162162- # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
163163- # target libraries and tools.
164164- ++ optional langAda ../gnat-cflags.patch
165165- ++ optional langVhdl ./ghdl-ortho-cflags.patch
166166- ++ [ ../struct-ucontext-4.5.patch ] # glibc-2.26
167167- ;
168168-169169- postPatch =
170170- if (stdenv.system == "i586-pc-gnu"
171171- || (libcCross != null # e.g., building `gcc.crossDrv'
172172- && libcCross ? crossConfig
173173- && libcCross.crossConfig == "i586-pc-gnu")
174174- || (targetPlatform != hostPlatform && targetPlatform.config == "i586-pc-gnu"
175175- && libcCross != null))
176176- then
177177- # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
178178- # in glibc, so add the right `-I' flags to the default spec string.
179179- assert libcCross != null -> libpthreadCross != null;
180180- let
181181- libc = if libcCross != null then libcCross else stdenv.glibc;
182182- gnu_h = "gcc/config/gnu.h";
183183- i386_gnu_h = "gcc/config/i386/gnu.h";
184184- extraCPPDeps =
185185- libc.propagatedBuildInputs
186186- ++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross
187187- ++ stdenv.lib.optional (libpthread != null) libpthread;
188188- extraCPPSpec =
189189- concatStrings (intersperse " "
190190- (map (x: "-I${x.dev or x}/include") extraCPPDeps));
191191- extraLibSpec =
192192- if libpthreadCross != null
193193- then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}"
194194- else "-L${libpthread}/lib";
195195- in
196196- '' echo "augmenting \`CPP_SPEC' in \`${i386_gnu_h}' with \`${extraCPPSpec}'..."
197197- sed -i "${i386_gnu_h}" \
198198- -es'|CPP_SPEC *"\(.*\)$|CPP_SPEC "${extraCPPSpec} \1|g'
199199-200200- echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..."
201201- sed -i "${gnu_h}" \
202202- -es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
203203-204204- echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..."
205205- sed -i "${gnu_h}" \
206206- -es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
207207- sed -i gcc/config/t-gnu \
208208- -es'|NATIVE_SYSTEM_HEADER_DIR.*$|NATIVE_SYSTEM_HEADER_DIR = ${libc.dev}/include|g'
209209- ''
210210- else if targetPlatform != hostPlatform || stdenv.cc.libc != null then
211211- # On NixOS, use the right path to the dynamic linker instead of
212212- # `/lib/ld*.so'.
213213- let
214214- libc = if libcCross != null then libcCross else stdenv.cc.libc;
215215- in
216216- '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..."
217217- for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
218218- do
219219- grep -q LIBC_DYNAMIC_LINKER "$header" || continue
220220- echo " fixing \`$header'..."
221221- sed -i "$header" \
222222- -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g'
223223- done
224224- ''
225225- else null;
226226-227227- # TODO(@Ericson2314): Make passthru instead. Weird to avoid mass rebuild,
228228- crossStageStatic = targetPlatform == hostPlatform || crossStageStatic;
229229- inherit noSysDirs profiledCompiler staticCompiler langJava
230230- libcCross crossMingw;
231231-232232- depsBuildBuild = [ buildPackages.stdenv.cc ];
233233- nativeBuildInputs = [ texinfo which gettext ]
234234- ++ optional (perl != null) perl;
235235-236236- # For building runtime libs
237237- depsBuildTarget =
238238- if hostPlatform == buildPlatform then [
239239- targetPackages.stdenv.cc.bintools # newly-built gcc will be used
240240- ] else assert targetPlatform == hostPlatform; [ # build != host == target
241241- stdenv.cc
242242- ];
243243-244244- buildInputs = [
245245- gmp mpfr libmpc libelf
246246- targetPackages.stdenv.cc.bintools # For linking code at run-time
247247- ] ++ (optional (ppl != null) ppl)
248248- ++ (optional (cloogppl != null) cloogppl)
249249- ++ (optional (zlib != null) zlib)
250250- ++ (optional langJava boehmgc)
251251- ++ (optionals langJava [zip unzip])
252252- ++ (optionals javaAwtGtk ([gtk2 pkgconfig libart_lgpl] ++ xlibs))
253253- ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
254254- ++ (optionals langAda [gnatboot])
255255- ++ (optionals langVhdl [gnat])
256256- ;
257257-258258- # TODO(@Ericson2314): Always pass "--target" and always prefix.
259259- configurePlatforms =
260260- # TODO(@Ericson2314): Figure out what's going wrong with Arm
261261- if buildPlatform == hostPlatform && hostPlatform == targetPlatform && targetPlatform.isArm
262262- then []
263263- else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
264264-265265- configureFlags =
266266- # Basic dependencies
267267- [
268268- "--with-gmp=${gmp.dev}"
269269- "--with-mpfr=${mpfr.dev}"
270270- "--with-mpc=${libmpc}"
271271- ] ++
272272- optional (libelf != null) "--with-libelf=${libelf}" ++
273273- optional (!(crossMingw && crossStageStatic))
274274- "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++
275275-276276- # Basic configuration
277277- [
278278- "--disable-libstdcxx-pch"
279279- "--without-included-gettext"
280280- "--with-system-zlib"
281281- "--enable-languages=${
282282- concatStrings (intersperse ","
283283- ( optional langC "c"
284284- ++ optional langCC "c++"
285285- ++ optional langFortran "fortran"
286286- ++ optional langJava "java"
287287- ++ optional langAda "ada"
288288- ++ optional langVhdl "vhdl"
289289- )
290290- )
291291- }"
292292- ] ++
293293- optional (!enableMultilib) "--disable-multilib" ++
294294- optional (!enableShared) "--disable-shared" ++
295295-296296- # Optional features
297297- optional (cloogppl != null) "--with-cloog=${cloogppl}" ++
298298- optional (ppl != null) "--with-ppl=${ppl}" ++
299299-300300- # Java options
301301- optionals langJava [
302302- "--with-ecj-jar=${javaEcj}"
303303-304304- # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
305305- # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
306306- "--enable-java-home"
307307- "--with-java-home=\${prefix}/lib/jvm/jre"
308308- ] ++
309309- optional javaAwtGtk "--enable-java-awt=gtk" ++
310310- optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
311311-312312- # Ada
313313- optional langAda "--enable-libada" ++
314314-315315- platformFlags ++
316316- optional (targetPlatform != hostPlatform) crossConfigureFlags ++
317317-318318- # Platform-specific flags
319319- optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
320320- # Trick that should be taken out once we have a mipsel-linux not loongson2f
321321- optional (targetPlatform == hostPlatform && stdenv.system == "mipsel-linux") "--with-arch=loongson2f"
322322- ;
323323-324324- targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
325325-326326- /* For cross-built gcc (build != host == target) */
327327- crossAttrs = {
328328- dontStrip = true;
329329- };
330330-331331- # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
332332- # library headers and binaries, regarless of the language being compiled.
333333- #
334334- # Note: When building the Java AWT GTK+ peer, the build system doesn't honor
335335- # `--with-gmp' et al., e.g., when building
336336- # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add
337337- # them to $CPATH and $LIBRARY_PATH in this case.
338338- #
339339- # Likewise, the LTO code doesn't find zlib.
340340- #
341341- # Cross-compiling, we need gcc not to read ./specs in order to build the g++
342342- # compiler (after the specs for the cross-gcc are created). Having
343343- # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks.
344344-345345- CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
346346- ++ optional (zlib != null) zlib
347347- ++ optional langJava boehmgc
348348- ++ optionals javaAwtGtk xlibs
349349- ++ optionals javaAwtGtk [ gmp mpfr ]
350350- ++ optional (libpthread != null) libpthread
351351- ++ optional (libpthreadCross != null) libpthreadCross
352352-353353- # On GNU/Hurd glibc refers to Mach & Hurd
354354- # headers.
355355- ++ optionals (libcCross != null && libcCross ? propagatedBuildInputs)
356356- libcCross.propagatedBuildInputs
357357- ));
358358-359359- LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
360360- ++ optional (zlib != null) zlib
361361- ++ optional langJava boehmgc
362362- ++ optionals javaAwtGtk xlibs
363363- ++ optionals javaAwtGtk [ gmp mpfr ]
364364- ++ optional (libpthread != null) libpthread)
365365- );
366366-367367- EXTRA_TARGET_FLAGS = optionals
368368- (targetPlatform != hostPlatform && libcCross != null)
369369- ([
370370- "-idirafter ${libcCross.dev}/include"
371371- ] ++ optionals (! crossStageStatic) [
372372- "-B${libcCross.out}/lib"
373373- ]);
374374-375375- EXTRA_TARGET_LDFLAGS = optionals
376376- (targetPlatform != hostPlatform && libcCross != null)
377377- ([
378378- "-Wl,-L${libcCross.out}/lib"
379379- ] ++ (if crossStageStatic then [
380380- "-B${libcCross.out}/lib"
381381- ] else [
382382- "-Wl,-rpath,${libcCross.out}/lib"
383383- "-Wl,-rpath-link,${libcCross.out}/lib"
384384- ]) ++ optionals (libpthreadCross != null) [
385385- "-L${libpthreadCross}/lib"
386386- "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
387387- ]);
388388-389389- passthru = {
390390- inherit langC langCC langAda langFortran langVhdl enableMultilib version;
391391- isGNU = true;
392392- hardeningUnsupportedFlags = [ "stackprotector" ];
393393- };
394394-395395- enableParallelBuilding = !langAda;
396396-397397- meta = {
398398- homepage = http://gcc.gnu.org/;
399399- license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+
400400- description = "GNU Compiler Collection, version ${version}"
401401- + (if stripped then "" else " (with debugging info)");
402402-403403- longDescription = ''
404404- The GNU Compiler Collection includes compiler front ends for C, C++,
405405- Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well
406406- as libraries for these languages (libstdc++, libgcj, libgomp,...).
407407-408408- GCC development is a part of the GNU Project, aiming to improve the
409409- compiler used in the GNU system including the GNU/Linux variant.
410410- '';
411411-412412- maintainers = [
413413- stdenv.lib.maintainers.viric
414414- ];
415415-416416- # Volunteers needed for the {Cyg,Dar}win ports of *PPL.
417417- # gnatboot is not available out of linux platforms, so we disable the darwin build
418418- # for the gnat (ada compiler).
419419- platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false) [ "i686-darwin" ];
420420- };
421421-}
422422-423423-// optionalAttrs (targetPlatform != hostPlatform || libcCross != null) {
424424- # `builder.sh' sets $CPP, which leads configure to use "gcc -E" instead of,
425425- # say, "i586-pc-gnu-gcc -E" when building `gcc.crossDrv'.
426426- # FIXME: Fix `builder.sh' directly in the next stdenv-update.
427427- postUnpack = "unset CPP";
428428-}
429429-430430-// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
431431- makeFlags = [ "all-gcc" "all-target-libgcc" ];
432432- installTargets = "install-gcc install-target-libgcc";
433433-}
434434-435435-# GCC 4.5.2 doesn't support the `install-strip' target, so let `stdenv' do
436436-# the stripping by default.
437437-// optionalAttrs (!stripped) { dontStrip = true; }
438438-439439-// optionalAttrs langVhdl rec {
440440- name = "ghdl-0.29";
441441-442442- ghdlSrc = fetchurl {
443443- url = "http://ghdl.free.fr/ghdl-0.29.tar.bz2";
444444- sha256 = "15mlinr1lwljwll9ampzcfcrk9bk0qpdks1kxlvb70xf9zhh2jva";
445445- };
446446-447447- # Ghdl has some timestamps checks, storing file timestamps in '.cf' files.
448448- # As we will change the timestamps to 1970-01-01 00:00:01, we also set the
449449- # content of that .cf to that value. This way ghdl does not complain on
450450- # the installed object files from the basic libraries (ieee, ...)
451451- postInstallGhdl = ''
452452- pushd $out
453453- find . -name "*.cf" -exec \
454454- sed 's/[0-9]*\.000" /19700101000001.000" /g' -i {} \;
455455- popd
456456- '';
457457-458458- postUnpack = ''
459459- tar xvf ${ghdlSrc}
460460- mv ghdl-*/vhdl gcc*/gcc
461461- rm -Rf ghdl-*
462462- '';
463463-464464- meta = {
465465- homepage = http://ghdl.free.fr/;
466466- license = stdenv.lib.licenses.gpl2Plus;
467467- description = "Complete VHDL simulator, using the GCC technology (gcc ${version})";
468468- maintainers = with stdenv.lib.maintainers; [viric];
469469- platforms = with stdenv.lib.platforms; linux;
470470- };
471471-472472-})
···287287 # See https://bugs.gentoo.org/show_bug.cgi?id=301299#c31
288288 paxmark r $out/libexec/gcc/*/*/{cc1,cc1plus}
289289290290- eval "$postInstallGhdl"
291291-292290 # Two identical man pages are shipped (moving and compressing is done later)
293291 ln -sf gcc.1 "$out"/share/man/man1/g++.1
294292}
-33
pkgs/development/compilers/gcc/gnat-cflags.patch
···11-diff --git a/libada/Makefile.in b/libada/Makefile.in
22-index f5057a0..337e0c6 100644
33---- a/libada/Makefile.in
44-+++ b/libada/Makefile.in
55-@@ -55,7 +55,7 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN)
66- WARN_CFLAGS = @warn_cflags@
77-88- TARGET_LIBGCC2_CFLAGS=
99--GNATLIBCFLAGS= -g -O2
1010-+GNATLIBCFLAGS= -g -O2 $(CFLAGS)
1111- GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \
1212- -DIN_RTS @have_getipinfo@
1313-1414---- a/gcc/ada/gcc-interface/Makefile.in
1515-+++ b/gcc/ada/gcc-interface/Makefile.in
1616-@@ -105,7 +105,7 @@ ADAFLAGS = -W -Wall -gnatpg -gnata
1717- SOME_ADAFLAGS =-gnata
1818- FORCE_DEBUG_ADAFLAGS = -g
1919- GNATLIBFLAGS = -gnatpg -nostdinc
2020--GNATLIBCFLAGS = -g -O2
2121-+GNATLIBCFLAGS = -g -O2 $(CFLAGS_FOR_TARGET)
2222- # Pretend that _Unwind_GetIPInfo is available for the target by default. This
2323- # should be autodetected during the configuration of libada and passed down to
2424- # here, but we need something for --disable-libada and hope for the best.
2525-@@ -193,7 +193,7 @@ RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
2626- # Link flags used to build gnat tools. By default we prefer to statically
2727- # link with libgcc to avoid a dependency on shared libgcc (which is tricky
2828- # to deal with as it may conflict with the libgcc provided by the system).
2929--GCC_LINK_FLAGS=-static-libgcc
3030-+GCC_LINK_FLAGS=-static-libgcc $(CFLAGS_FOR_TARGET)
3131-3232- # End of variables for you to override.
3333-