From 48f63c2f2e3752df2a0b73cad9b9bba9eda8ac60 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Fri, 9 Jan 2015 11:22:12 -0800 Subject: rename gcc-wrapper to cc-wrapper. also makes cc-wrapper compatible with clang in the darwin fork. --- pkgs/applications/editors/vim/configurable.nix | 2 +- pkgs/applications/editors/vim/qvim.nix | 2 +- pkgs/build-support/cc-wrapper/add-flags | 28 +++ pkgs/build-support/cc-wrapper/cc-wrapper.sh | 158 +++++++++++++ pkgs/build-support/cc-wrapper/default.nix | 251 +++++++++++++++++++++ pkgs/build-support/cc-wrapper/gnat-wrapper.sh | 103 +++++++++ pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh | 33 +++ .../build-support/cc-wrapper/ld-solaris-wrapper.sh | 40 ++++ pkgs/build-support/cc-wrapper/ld-wrapper.sh | 166 ++++++++++++++ pkgs/build-support/cc-wrapper/setup-hook.sh | 38 ++++ pkgs/build-support/cc-wrapper/utils.sh | 24 ++ pkgs/build-support/gcc-wrapper/add-flags | 28 --- pkgs/build-support/gcc-wrapper/default.nix | 251 --------------------- pkgs/build-support/gcc-wrapper/gcc-wrapper.sh | 146 ------------ pkgs/build-support/gcc-wrapper/gnat-wrapper.sh | 103 --------- pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh | 33 --- .../gcc-wrapper/ld-solaris-wrapper.sh | 40 ---- pkgs/build-support/gcc-wrapper/ld-wrapper.sh | 166 -------------- pkgs/build-support/gcc-wrapper/setup-hook.sh | 38 ---- pkgs/build-support/gcc-wrapper/utils.sh | 24 -- pkgs/stdenv/adapters.nix | 2 +- pkgs/stdenv/darwin/default.nix | 4 +- pkgs/stdenv/linux/default.nix | 10 +- pkgs/stdenv/native/default.nix | 4 +- pkgs/stdenv/nix/default.nix | 8 +- pkgs/top-level/all-packages.nix | 93 ++++---- 26 files changed, 907 insertions(+), 888 deletions(-) create mode 100644 pkgs/build-support/cc-wrapper/add-flags create mode 100644 pkgs/build-support/cc-wrapper/cc-wrapper.sh create mode 100644 pkgs/build-support/cc-wrapper/default.nix create mode 100644 pkgs/build-support/cc-wrapper/gnat-wrapper.sh create mode 100644 pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh create mode 100644 pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh create mode 100644 pkgs/build-support/cc-wrapper/ld-wrapper.sh create mode 100644 pkgs/build-support/cc-wrapper/setup-hook.sh create mode 100644 pkgs/build-support/cc-wrapper/utils.sh delete mode 100644 pkgs/build-support/gcc-wrapper/add-flags delete mode 100644 pkgs/build-support/gcc-wrapper/default.nix delete mode 100644 pkgs/build-support/gcc-wrapper/gcc-wrapper.sh delete mode 100644 pkgs/build-support/gcc-wrapper/gnat-wrapper.sh delete mode 100644 pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh delete mode 100644 pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh delete mode 100644 pkgs/build-support/gcc-wrapper/ld-wrapper.sh delete mode 100644 pkgs/build-support/gcc-wrapper/setup-hook.sh delete mode 100644 pkgs/build-support/gcc-wrapper/utils.sh diff --git a/pkgs/applications/editors/vim/configurable.nix b/pkgs/applications/editors/vim/configurable.nix index d5b7182c64a7..6910f13bb36a 100644 --- a/pkgs/applications/editors/vim/configurable.nix +++ b/pkgs/applications/editors/vim/configurable.nix @@ -33,7 +33,7 @@ in composableDerivation { # use gccApple to compile on darwin mkDerivation = ( if stdenv.isDarwin - then stdenvAdapters.overrideGCC stdenv gccApple + then stdenvAdapters.overrideCC stdenv gccApple else stdenv ).mkDerivation; } (fix: { diff --git a/pkgs/applications/editors/vim/qvim.nix b/pkgs/applications/editors/vim/qvim.nix index 5d1a8a6f1410..8c87d3c1e20c 100644 --- a/pkgs/applications/editors/vim/qvim.nix +++ b/pkgs/applications/editors/vim/qvim.nix @@ -8,7 +8,7 @@ let inherit (args.composableDerivation) composableDerivation edf; in composableDerivation { # use gccApple to compile on darwin mkDerivation = ( if stdenv.isDarwin - then stdenvAdapters.overrideGCC stdenv gccApple + then stdenvAdapters.overrideCC stdenv gccApple else stdenv ).mkDerivation; } (fix: { diff --git a/pkgs/build-support/cc-wrapper/add-flags b/pkgs/build-support/cc-wrapper/add-flags new file mode 100644 index 000000000000..d48361539047 --- /dev/null +++ b/pkgs/build-support/cc-wrapper/add-flags @@ -0,0 +1,28 @@ +# `-B@out@/bin' forces gcc to use ld-wrapper.sh when calling ld. +export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE" + +if [ -e @out@/nix-support/libc-cflags ]; then + export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE" +fi + +if [ -e @out@/nix-support/gcc-cflags ]; then + export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE" +fi + +if [ -e @out@/nix-support/gnat-cflags ]; then + export NIX_GNATFLAGS_COMPILE="$(cat @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE" +fi + +if [ -e @out@/nix-support/libc-ldflags ]; then + export NIX_LDFLAGS+=" $(cat @out@/nix-support/libc-ldflags)" +fi + +if [ -e @out@/nix-support/gcc-ldflags ]; then + export NIX_LDFLAGS+=" $(cat @out@/nix-support/cc-ldflags)" +fi + +if [ -e @out@/nix-support/libc-ldflags-before ]; then + export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE" +fi + +export NIX_CC_WRAPPER_FLAGS_SET=1 diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh new file mode 100644 index 000000000000..3a7e24dfcafb --- /dev/null +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -0,0 +1,158 @@ +#! @shell@ -e + +if [ -n "$NIX_CC_WRAPPER_START_HOOK" ]; then + source "$NIX_CC_WRAPPER_START_HOOK" +fi + +if [ -z "$NIX_CC_WRAPPER_FLAGS_SET" ]; then + source @out@/nix-support/add-flags.sh +fi + +source @out@/nix-support/utils.sh + + +# Figure out if linker flags should be passed. GCC prints annoying +# warnings when they are not needed. +dontLink=0 +getVersion=0 +nonFlagArgs=0 + +for i in "$@"; do + if [ "$i" = -c ]; then + dontLink=1 + elif [ "$i" = -S ]; then + dontLink=1 + elif [ "$i" = -E ]; then + dontLink=1 + elif [ "$i" = -E ]; then + dontLink=1 + elif [ "$i" = -M ]; then + dontLink=1 + elif [ "$i" = -MM ]; then + dontLink=1 + elif [ "$i" = -x ]; then + # At least for the cases c-header or c++-header we should set dontLink. + # I expect no one use -x other than making precompiled headers. + dontLink=1 + elif [ "${i:0:1}" != - ]; then + nonFlagArgs=1 + elif [ "$i" = -m32 ]; then + if [ -e @out@/nix-support/dynamic-linker-m32 ]; then + NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" + fi + fi +done + +# If we pass a flag like -Wl, then gcc will call the linker unless it +# can figure out that it has to do something else (e.g., because of a +# "-c" flag). So if no non-flag arguments are given, don't pass any +# linker flags. This catches cases like "gcc" (should just print +# "gcc: no input files") and "gcc -v" (should print the version). +if [ "$nonFlagArgs" = 0 ]; then + dontLink=1 +fi + + +# Optionally filter out paths not refering to the store. +params=("$@") +if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then + rest=() + n=0 + while [ $n -lt ${#params[*]} ]; do + p=${params[n]} + p2=${params[$((n+1))]} + if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then + skip $p + elif [ "$p" = -L ] && badPath "$p2"; then + n=$((n + 1)); skip $p2 + elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then + skip $p + elif [ "$p" = -I ] && badPath "$p2"; then + n=$((n + 1)); skip $p2 + elif [ "$p" = -isystem ] && badPath "$p2"; then + n=$((n + 1)); skip $p2 + else + rest=("${rest[@]}" "$p") + fi + n=$((n + 1)) + done + params=("${rest[@]}") +fi + +if test -n "@libcxx@"; then + NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem@libcxx@/include/c++/v1" + if [[ "@prog@" = *++ ]]; then + NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -stdlib=libc++" + if test -z "$NIX_SKIP_CXX"; then + NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -L@libcxx@/lib -stdlib=libc++" + fi + if test -z "$NIX_SKIP_CXXABI" && echo "$@" | grep -qvw -- -nostdlib; then + NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -L@libcxxabi@/lib -lc++abi" + fi + fi +fi + +# Add the flags for the C compiler proper. +extraAfter=($NIX_CFLAGS_COMPILE) +extraBefore=() + +# When enforcing purity, pretend gcc can't find the current date and +# time +if [ "$NIX_ENFORCE_PURITY" = 1 ]; then + extraAfter+=('-D__DATE__="Jan 01 1970"' + '-D__TIME__="00:00:01"' + -Wno-builtin-macro-redefined) +fi + + +if [ "$dontLink" != 1 ]; then + + # Add the flags that should only be passed to the compiler when + # linking. + extraAfter+=($NIX_CFLAGS_LINK) + + # Add the flags that should be passed to the linker (and prevent + # `ld-wrapper' from adding NIX_LDFLAGS again). + for i in $NIX_LDFLAGS_BEFORE; do + extraBefore=(${extraBefore[@]} "-Wl,$i") + done + for i in $NIX_LDFLAGS; do + if [ "${i:0:3}" = -L/ ]; then + extraAfter+=("$i") + else + extraAfter+=("-Wl,$i") + fi + done + export NIX_LDFLAGS_SET=1 +fi + +# As a very special hack, if the arguments are just `-v', then don't +# add anything. This is to prevent `gcc -v' (which normally prints +# out the version number and returns exit code 0) from printing out +# `No input files specified' and returning exit code 1. +if [ "$*" = -v ]; then + extraAfter=() + extraBefore=() +fi + +# Optionally print debug info. +if [ -n "$NIX_DEBUG" ]; then + echo "original flags to @prog@:" >&2 + for i in "${params[@]}"; do + echo " $i" >&2 + done + echo "extraBefore flags to @prog@:" >&2 + for i in ${extraBefore[@]}; do + echo " $i" >&2 + done + echo "extraAfter flags to @prog@:" >&2 + for i in ${extraAfter[@]}; do + echo " $i" >&2 + done +fi + +if [ -n "$NIX_CC_WRAPPER_EXEC_HOOK" ]; then + source "$NIX_CC_WRAPPER_EXEC_HOOK" +fi + +exec @prog@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix new file mode 100644 index 000000000000..abbba31641b3 --- /dev/null +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -0,0 +1,251 @@ +# The Nixpkgs CC is not directly usable, since it doesn't know where +# the C library and standard header files are. Therefore the compiler +# produced by that package cannot be installed directly in a user +# environment and used from the command line. So we use a wrapper +# script that sets up the right environment variables so that the +# compiler and the linker just "work". + +{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" +, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell +, zlib ? null, extraPackages ? [] +, libcxx ? null, libcxxabi ? null +}: + +with stdenv.lib; + +assert nativeTools -> nativePrefix != ""; +assert !nativeTools -> cc != null && binutils != null && coreutils != null; +assert !nativeLibc -> libc != null; + +# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. +assert cc.langVhdl or false -> zlib != null; + +let + + ccVersion = (builtins.parseDrvName cc.name).version; + ccName = (builtins.parseDrvName cc.name).name; + +in + +stdenv.mkDerivation { + name = + (if name != "" then name else ccName + "-wrapper") + + (if cc != null && ccVersion != "" then "-" + ccVersion else ""); + + preferLocalBuild = true; + + inherit cc shell libcxx libcxxabi; + libc = if nativeLibc then null else libc; + binutils = if nativeTools then null else binutils; + # The wrapper scripts use 'cat', so we may need coreutils. + coreutils = if nativeTools then null else coreutils; + + passthru = { inherit nativeTools nativeLibc nativePrefix; }; + + buildCommand = + '' + mkdir -p $out/bin $out/nix-support + + wrap() { + local dst="$1" + local wrapper="$2" + export prog="$3" + substituteAll "$wrapper" "$out/bin/$dst" + chmod +x "$out/bin/$dst" + } + '' + + + optionalString (!nativeLibc) '' + dynamicLinker="$libc/lib/$dynamicLinker" + echo $dynamicLinker > $out/nix-support/dynamic-linker + + if [ -e $libc/lib/32/ld-linux.so.2 ]; then + echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 + fi + + # The "-B$libc/lib/" flag is a quick hack to force gcc to link + # against the crt1.o from our own glibc, rather than the one in + # /usr/lib. (This is only an issue when using an `impure' + # compiler/linker, i.e., one that searches /usr/lib and so on.) + # + # Unfortunately, setting -B appears to override the default search + # path. Thus, the gcc-specific "../includes-fixed" directory is + # now longer searched and glibc's header fails to + # compile, because it uses "#include_next " to find the + # limits.h file in ../includes-fixed. To remedy the problem, + # another -idirafter is necessary to add that directory again. + echo "-B$libc/lib/ -idirafter $libc/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags + + echo "-L$libc/lib" > $out/nix-support/libc-ldflags + + # The dynamic linker is passed in `ldflagsBefore' to allow + # explicit overrides of the dynamic linker by callers to gcc/ld + # (the *last* value counts, so ours should come first). + echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before + + echo $libc > $out/nix-support/orig-libc + '' + + + (if nativeTools then '' + ccPath="${nativePrefix}/bin" + ldPath="${nativePrefix}/bin" + '' else '' + echo $cc > $out/nix-support/orig-cc + + # GCC shows $cc/lib in `gcc -print-search-dirs', but not + # $cc/lib64 (even though it does actually search there...).. + # This confuses libtool. So add it to the compiler tool search + # path explicitly. + if [ -e "$cc/lib64" -a ! -L "$cc/lib64" ]; then + ccLDFlags+=" -L$cc/lib64" + ccCFlags+=" -B$cc/lib64" + fi + ccLDFlags+=" -L$cc/lib" + + ${optionalString cc.langVhdl or false '' + ccLDFlags+=" -L${zlib}/lib" + ''} + + # Find the gcc libraries path (may work only without multilib). + ${optionalString cc.langAda or false '' + basePath=`echo $cc/lib/*/*/*` + ccCFlags+=" -B$basePath -I$basePath/adainclude" + gnatCFlags="-aI$basePath/adainclude -aO$basePath/adalib" + echo "$gnatCFlags" > $out/nix-support/gnat-cflags + ''} + + if [ -e $ccPath/clang ]; then + # Need files like crtbegin.o from gcc + # It's unclear if these will ever be provided by an LLVM project + ccCFlags="$ccCFlags -B$basePath" + ccCFlags="$ccCFlags -isystem$cc/lib/clang/$ccVersion/include" + fi + + echo "$ccLDFlags" > $out/nix-support/cc-ldflags + echo "$ccCFlags" > $out/nix-support/cc-cflags + + ccPath="$cc/bin" + ldPath="$binutils/bin" + + # Propagate the wrapped cc so that if you install the wrapper, + # you get tools like gcov, the manpages, etc. as well (including + # for binutils and Glibc). + echo $cc $binutils $libc > $out/nix-support/propagated-user-env-packages + + echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs + '' + + + optionalString (stdenv.isSunOS && nativePrefix != "") '' + # Solaris needs an additional ld wrapper. + ldPath="${nativePrefix}/bin" + ld="$out/bin/ld-solaris" + wrap ld-solaris ${./ld-solaris-wrapper.sh} + '') + + + '' + # Create a symlink to as (the assembler). This is useful when a + # cc-wrapper is installed in a user environment, as it ensures that + # the right assembler is called. + if [ -e $ldPath/as ]; then + ln -s $ldPath/as $out/bin/as + fi + + wrap ld ${./ld-wrapper.sh} ''${ld:-$ldPath/ld} + + if [ -e $binutils/bin/ld.gold ]; then + wrap ld.gold ${./ld-wrapper.sh} $binutils/bin/ld.gold + fi + + if [ -e $binutils/bin/ld.bfd ]; then + wrap ld.bfd ${./ld-wrapper.sh} $binutils/bin/ld.bfd + fi + + if [ -e $ccPath/gcc ]; then + wrap gcc ${./cc-wrapper.sh} $ccPath/gcc + ln -s gcc $out/bin/cc + elif [ -e $ccPath/clang ]; then + wrap clang ${./cc-wrapper.sh} $ccPath/clang + ln -s clang $out/bin/cc + fi + + if [ -e $ccPath/g++ ]; then + wrap g++ ${./cc-wrapper.sh} $ccPath/g++ + ln -s g++ $out/bin/c++ + elif [ -e $ccPath/clang++ ]; then + wrap clang++ ${./cc-wrapper.sh} $ccPath/clang++ + ln -s clang++ $out/bin/c++ + fi + + if [ -e $ccPath/cpp ]; then + wrap cpp ${./cc-wrapper.sh} $ccPath/cpp + fi + '' + + + optionalString cc.langFortran or false '' + wrap gfortran ${./cc-wrapper.sh} $ccPath/gfortran + ln -sv gfortran $out/bin/g77 + ln -sv gfortran $out/bin/f77 + '' + + + optionalString cc.langJava or false '' + wrap gcj ${./cc-wrapper.sh} $ccPath/gcj + '' + + + optionalString cc.langGo or false '' + wrap ccgo ${./cc-wrapper.sh} $ccPath/gccgo + '' + + + optionalString cc.langAda or false '' + wrap gnatgcc ${./cc-wrapper.sh} $ccPath/gnatgcc + wrap gnatmake ${./gnat-wrapper.sh} $ccPath/gnatmake + wrap gnatbind ${./gnat-wrapper.sh} $ccPath/gnatbind + wrap gnatlink ${./gnatlink-wrapper.sh} $ccPath/gnatlink + '' + + + optionalString cc.langVhdl or false '' + ln -s $ccPath/ghdl $out/bin/ghdl + '' + + + '' + substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook + substituteAll ${./add-flags} $out/nix-support/add-flags.sh + cp -p ${./utils.sh} $out/nix-support/utils.sh + ''; + + # The dynamic linker has different names on different Linux platforms. + dynamicLinker = + if !nativeLibc then + (if stdenv.system == "i686-linux" then "ld-linux.so.2" else + if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else + # ARM with a wildcard, which can be "" or "-armhf". + if stdenv.isArm then "ld-linux*.so.3" else + if stdenv.system == "powerpc-linux" then "ld.so.1" else + if stdenv.system == "mips64el-linux" then "ld.so.1" else + abort "Don't know the name of the dynamic linker for this platform.") + else ""; + + crossAttrs = { + shell = shell.crossDrv + shell.crossDrv.shellPath; + libc = stdenv.ccCross.libc; + coreutils = coreutils.crossDrv; + binutils = binutils.crossDrv; + cc = cc.crossDrv; + # + # This is not the best way to do this. I think the reference should be + # the style in the gcc-cross-wrapper, but to keep a stable stdenv now I + # do this sufficient if/else. + dynamicLinker = + (if stdenv.cross.arch == "arm" then "ld-linux.so.3" else + if stdenv.cross.arch == "mips" then "ld.so.1" else + if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else + abort "don't know the name of the dynamic linker for this platform"); + }; + + meta = + let cc_ = if cc != null then cc else {}; in + (if cc_ ? meta then removeAttrs cc.meta ["priority"] else {}) // + { description = + stdenv.lib.attrByPath ["meta" "description"] "System C compiler" cc_ + + " (wrapper script)"; + }; +} diff --git a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh new file mode 100644 index 000000000000..3514ccd67325 --- /dev/null +++ b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh @@ -0,0 +1,103 @@ +#! @shell@ -e + +if [ -n "$NIX_GNAT_WRAPPER_START_HOOK" ]; then + source "$NIX_GNAT_WRAPPER_START_HOOK" +fi + +if [ -z "$NIX_GNAT_WRAPPER_FLAGS_SET" ]; then + source @out@/nix-support/add-flags.sh +fi + +source @out@/nix-support/utils.sh + + +# Figure out if linker flags should be passed. GCC prints annoying +# warnings when they are not needed. +dontLink=0 +getVersion=0 +nonFlagArgs=0 + +for i in "$@"; do + if [ "$i" = -c ]; then + dontLink=1 + elif [ "$i" = -M ]; then + dontLink=1 + elif [ "${i:0:1}" != - ]; then + nonFlagArgs=1 + elif [ "$i" = -m32 ]; then + if [ -e @out@/nix-support/dynamic-linker-m32 ]; then + NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" + fi + fi +done + +# If we pass a flag like -Wl, then gcc will call the linker unless it +# can figure out that it has to do something else (e.g., because of a +# "-c" flag). So if no non-flag arguments are given, don't pass any +# linker flags. This catches cases like "gcc" (should just print +# "gcc: no input files") and "gcc -v" (should print the version). +if [ "$nonFlagArgs" = 0 ]; then + dontLink=1 +fi + + +# Optionally filter out paths not refering to the store. +params=("$@") +if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then + rest=() + n=0 + while [ $n -lt ${#params[*]} ]; do + p=${params[n]} + p2=${params[$((n+1))]} + if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then + skip $p + elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then + skip $p + elif [ "${p:0:4}" = -aI/ ] && badPath "${p:3}"; then + skip $p + elif [ "${p:0:4}" = -aO/ ] && badPath "${p:3}"; then + skip $p + else + rest=("${rest[@]}" "$p") + fi + n=$((n + 1)) + done + params=("${rest[@]}") +fi + + +# Add the flags for the GNAT compiler proper. +extraAfter=($NIX_GNATFLAGS_COMPILE) +extraBefore=() + +if [ "`basename $0`x" = "gnatmakex" ]; then + extraBefore=("--GNATBIND=@out@/bin/gnatbind --GNATLINK=@out@/bin/gnatlink ") +fi + +# Add the flags that should be passed to the linker (and prevent +# `ld-wrapper' from adding NIX_LDFLAGS again). +#for i in $NIX_LDFLAGS_BEFORE; do +# extraBefore=(${extraBefore[@]} "-largs $i") +#done + +# Optionally print debug info. +if [ -n "$NIX_DEBUG" ]; then + echo "original flags to @prog@:" >&2 + for i in "${params[@]}"; do + echo " $i" >&2 + done + echo "extraBefore flags to @prog@:" >&2 + for i in ${extraBefore[@]}; do + echo " $i" >&2 + done + echo "extraAfter flags to @prog@:" >&2 + for i in ${extraAfter[@]}; do + echo " $i" >&2 + done +fi + +if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then + source "$NIX_GNAT_WRAPPER_EXEC_HOOK" +fi + +exec @prog@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh b/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh new file mode 100644 index 000000000000..c9958dbbb413 --- /dev/null +++ b/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh @@ -0,0 +1,33 @@ +#! @shell@ -e + +# Add the flags for the GNAT compiler proper. +extraAfter="--GCC=@out@/bin/gcc" +extraBefore=() + +# Add the flags that should be passed to the linker (and prevent +# `ld-wrapper' from adding NIX_LDFLAGS again). +#for i in $NIX_LDFLAGS_BEFORE; do +# extraBefore=(${extraBefore[@]} "-largs $i") +#done + +# Optionally print debug info. +if [ -n "$NIX_DEBUG" ]; then + echo "original flags to @prog@:" >&2 + for i in "$@"; do + echo " $i" >&2 + done + echo "extraBefore flags to @prog@:" >&2 + for i in ${extraBefore[@]}; do + echo " $i" >&2 + done + echo "extraAfter flags to @prog@:" >&2 + for i in ${extraAfter[@]}; do + echo " $i" >&2 + done +fi + +if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then + source "$NIX_GNAT_WRAPPER_EXEC_HOOK" +fi + +exec @prog@ ${extraBefore[@]} "$@" ${extraAfter[@]} diff --git a/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh new file mode 100644 index 000000000000..9216ea3198dd --- /dev/null +++ b/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e +set -u + +# I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'( +# Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3 +# but still no success. +cmd="@prog@ -z ignore" + +args=("$@"); + +# This loop makes sure all -L arguments are before -l arguments, or ld may complain it cannot find a library. +# GNU binutils does not have this problem: +# http://stackoverflow.com/questions/5817269/does-the-order-of-l-and-l-options-in-the-gnu-linker-matter +i=0; +while [[ $i -lt $# ]]; do + case "${args[$i]}" in + -L) cmd="$cmd ${args[$i]} ${args[($i+1)]}"; i=($i+1); ;; + -L*) cmd="$cmd ${args[$i]}" ;; + *) ;; + esac + i=($i+1); +done + +i=0; +while [[ $i -lt $# ]]; do + case "${args[$i]}" in + -L) i=($i+1); ;; + -L*) ;; + *) cmd="$cmd ${args[$i]}" ;; + esac + i=($i+1); +done + +# Trace: +set -x +exec $cmd + +exit 0 diff --git a/pkgs/build-support/cc-wrapper/ld-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-wrapper.sh new file mode 100644 index 000000000000..30c531b76479 --- /dev/null +++ b/pkgs/build-support/cc-wrapper/ld-wrapper.sh @@ -0,0 +1,166 @@ +#! @shell@ -e + +if [ -n "$NIX_LD_WRAPPER_START_HOOK" ]; then + source "$NIX_LD_WRAPPER_START_HOOK" +fi + +if [ -z "$NIX_CC_WRAPPER_FLAGS_SET" ]; then + source @out@/nix-support/add-flags.sh +fi + +source @out@/nix-support/utils.sh + + +# Optionally filter out paths not refering to the store. +params=("$@") +if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" \ + -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \) ]; then + rest=() + n=0 + while [ $n -lt ${#params[*]} ]; do + p=${params[n]} + p2=${params[$((n+1))]} + if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then + skip $p + elif [ "$p" = -L ] && badPath "$p2"; then + n=$((n + 1)); skip $p2 + elif [ "$p" = -rpath ] && badPath "$p2"; then + n=$((n + 1)); skip $p2 + elif [ "$p" = -dynamic-linker ] && badPath "$p2"; then + n=$((n + 1)); skip $p2 + elif [ "${p:0:1}" = / ] && badPath "$p"; then + # We cannot skip this; barf. + echo "impure path \`$p' used in link" >&2 + exit 1 + elif [ "${p:0:9}" = --sysroot ]; then + # Our ld is not built with sysroot support (Can we fix that?) + : + else + rest=("${rest[@]}" "$p") + fi + n=$((n + 1)) + done + params=("${rest[@]}") +fi + + +extra=() +extraBefore=() + +if [ -z "$NIX_LDFLAGS_SET" ]; then + extra+=($NIX_LDFLAGS) + extraBefore+=($NIX_LDFLAGS_BEFORE) +fi + +extra+=($NIX_LDFLAGS_AFTER) + + +# Add all used dynamic libraries to the rpath. +if [ "$NIX_DONT_SET_RPATH" != 1 ]; then + + libPath="" + addToLibPath() { + local path="$1" + if [ "${path:0:1}" != / ]; then return 0; fi + case "$path" in + *..*|*./*|*/.*|*//*) + local path2 + if path2=$(readlink -f "$path"); then + path="$path2" + fi + ;; + esac + case $libPath in + *\ $path\ *) return 0 ;; + esac + libPath="$libPath $path " + } + + addToRPath() { + # If the path is not in the store, don't add it to the rpath. + # This typically happens for libraries in /tmp that are later + # copied to $out/lib. If not, we're screwed. + if [ "${1:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then return 0; fi + case $rpath in + *\ $1\ *) return 0 ;; + esac + rpath="$rpath $1 " + } + + libs="" + addToLibs() { + libs="$libs $1" + } + + rpath="" + + # First, find all -L... switches. + allParams=("${params[@]}" ${extra[@]}) + n=0 + while [ $n -lt ${#allParams[*]} ]; do + p=${allParams[n]} + p2=${allParams[$((n+1))]} + if [ "${p:0:3}" = -L/ ]; then + addToLibPath ${p:2} + elif [ "$p" = -L ]; then + addToLibPath ${p2} + n=$((n + 1)) + elif [ "$p" = -l ]; then + addToLibs ${p2} + n=$((n + 1)) + elif [ "${p:0:2}" = -l ]; then + addToLibs ${p:2} + elif [ "$p" = -dynamic-linker ]; then + # Ignore the dynamic linker argument, or it + # will get into the next 'elif'. We don't want + # the dynamic linker path rpath to go always first. + n=$((n + 1)) + elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then + # This is a direct reference to a shared library, so add + # its directory to the rpath. + path="$(dirname "$p")"; + addToRPath "${path}" + fi + n=$((n + 1)) + done + + # Second, for each directory in the library search path (-L...), + # see if it contains a dynamic library used by a -l... flag. If + # so, add the directory to the rpath. + # It's important to add the rpath in the order of -L..., so + # the link time chosen objects will be those of runtime linking. + + for i in $libPath; do + for j in $libs; do + if [ -f "$i/lib$j.so" ]; then + addToRPath $i + break + fi + done + done + + + # Finally, add `-rpath' switches. + for i in $rpath; do + extra=(${extra[@]} -rpath $i) + done +fi + + +# Optionally print debug info. +if [ -n "$NIX_DEBUG" ]; then + echo "original flags to @prog@:" >&2 + for i in "${params[@]}"; do + echo " $i" >&2 + done + echo "extra flags to @prog@:" >&2 + for i in ${extra[@]}; do + echo " $i" >&2 + done +fi + +if [ -n "$NIX_LD_WRAPPER_EXEC_HOOK" ]; then + source "$NIX_LD_WRAPPER_EXEC_HOOK" +fi + +exec @prog@ ${extraBefore[@]} "${params[@]}" ${extra[@]} diff --git a/pkgs/build-support/cc-wrapper/setup-hook.sh b/pkgs/build-support/cc-wrapper/setup-hook.sh new file mode 100644 index 000000000000..218899e9d8fc --- /dev/null +++ b/pkgs/build-support/cc-wrapper/setup-hook.sh @@ -0,0 +1,38 @@ +export NIX_CC=@out@ + +addCVars () { + if [ -d $1/include ]; then + export NIX_CFLAGS_COMPILE+=" -isystem $1/include" + fi + + if [ -d $1/lib64 -a ! -L $1/lib64 ]; then + export NIX_LDFLAGS+=" -L$1/lib64" + fi + + if [ -d $1/lib ]; then + export NIX_LDFLAGS+=" -L$1/lib" + fi +} + +envHooks+=(addCVars) + +# Note: these come *after* $out in the PATH (see setup.sh). + +if [ -n "@cc@" ]; then + addToSearchPath PATH @cc@/bin +fi + +if [ -n "@binutils@" ]; then + addToSearchPath PATH @binutils@/bin +fi + +if [ -n "@libc@" ]; then + addToSearchPath PATH @libc@/bin +fi + +if [ -n "@coreutils@" ]; then + addToSearchPath PATH @coreutils@/bin +fi + +export CC=cc +export CXX=c++ diff --git a/pkgs/build-support/cc-wrapper/utils.sh b/pkgs/build-support/cc-wrapper/utils.sh new file mode 100644 index 000000000000..3ab512d85c4e --- /dev/null +++ b/pkgs/build-support/cc-wrapper/utils.sh @@ -0,0 +1,24 @@ +skip () { + if [ -n "$NIX_DEBUG" ]; then + echo "skipping impure path $1" >&2 + fi +} + + +# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but +# `/nix/store/.../lib/foo.so' isn't. +badPath() { + local p=$1 + + # Relative paths are okay (since they're presumably relative to + # the temporary build directory). + if [ "${p:0:1}" != / ]; then return 1; fi + + # Otherwise, the path should refer to the store or some temporary + # directory (including the build directory). + test \ + "$p" != "/dev/null" -a \ + "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \ + "${p:0:4}" != "/tmp" -a \ + "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP" +} diff --git a/pkgs/build-support/gcc-wrapper/add-flags b/pkgs/build-support/gcc-wrapper/add-flags deleted file mode 100644 index be79fc370ec9..000000000000 --- a/pkgs/build-support/gcc-wrapper/add-flags +++ /dev/null @@ -1,28 +0,0 @@ -# `-B@out@/bin' forces gcc to use ld-wrapper.sh when calling ld. -export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE" - -if [ -e @out@/nix-support/libc-cflags ]; then - export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE" -fi - -if [ -e @out@/nix-support/gcc-cflags ]; then - export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/gcc-cflags) $NIX_CFLAGS_COMPILE" -fi - -if [ -e @out@/nix-support/gnat-cflags ]; then - export NIX_GNATFLAGS_COMPILE="$(cat @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE" -fi - -if [ -e @out@/nix-support/libc-ldflags ]; then - export NIX_LDFLAGS+=" $(cat @out@/nix-support/libc-ldflags)" -fi - -if [ -e @out@/nix-support/gcc-ldflags ]; then - export NIX_LDFLAGS+=" $(cat @out@/nix-support/gcc-ldflags)" -fi - -if [ -e @out@/nix-support/libc-ldflags-before ]; then - export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE" -fi - -export NIX_CC_WRAPPER_FLAGS_SET=1 diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix deleted file mode 100644 index aed1ab817aad..000000000000 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ /dev/null @@ -1,251 +0,0 @@ -# The Nixpkgs GCC is not directly usable, since it doesn't know where -# the C library and standard header files are. Therefore the compiler -# produced by that package cannot be installed directly in a user -# environment and used from the command line. So we use a wrapper -# script that sets up the right environment variables so that the -# compiler and the linker just "work". - -{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" -, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell -, zlib ? null, extraPackages ? [] -}: - -with stdenv.lib; - -assert nativeTools -> nativePrefix != ""; -assert !nativeTools -> gcc != null && binutils != null && coreutils != null; -assert !nativeLibc -> libc != null; - -# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. -assert gcc.langVhdl or false -> zlib != null; - -let - - gccVersion = (builtins.parseDrvName gcc.name).version; - gccName = (builtins.parseDrvName gcc.name).name; - -in - -stdenv.mkDerivation { - name = - (if name != "" then name else gccName + "-wrapper") + - (if gcc != null && gccVersion != "" then "-" + gccVersion else ""); - - preferLocalBuild = true; - - inherit gcc shell; - libc = if nativeLibc then null else libc; - binutils = if nativeTools then null else binutils; - # The wrapper scripts use 'cat', so we may need coreutils. - coreutils = if nativeTools then null else coreutils; - - passthru = { inherit nativeTools nativeLibc nativePrefix; }; - - buildCommand = - '' - mkdir -p $out/bin $out/nix-support - - wrap() { - local dst="$1" - local wrapper="$2" - export prog="$3" - substituteAll "$wrapper" "$out/bin/$dst" - chmod +x "$out/bin/$dst" - } - '' - - + optionalString (!nativeLibc) '' - dynamicLinker="$libc/lib/$dynamicLinker" - echo $dynamicLinker > $out/nix-support/dynamic-linker - - if [ -e $libc/lib/32/ld-linux.so.2 ]; then - echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 - fi - - # The "-B$libc/lib/" flag is a quick hack to force gcc to link - # against the crt1.o from our own glibc, rather than the one in - # /usr/lib. (This is only an issue when using an `impure' - # compiler/linker, i.e., one that searches /usr/lib and so on.) - # - # Unfortunately, setting -B appears to override the default search - # path. Thus, the gcc-specific "../includes-fixed" directory is - # now longer searched and glibc's header fails to - # compile, because it uses "#include_next " to find the - # limits.h file in ../includes-fixed. To remedy the problem, - # another -idirafter is necessary to add that directory again. - echo "-B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags - - echo "-L$libc/lib" > $out/nix-support/libc-ldflags - - # The dynamic linker is passed in `ldflagsBefore' to allow - # explicit overrides of the dynamic linker by callers to gcc/ld - # (the *last* value counts, so ours should come first). - echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before - - echo $libc > $out/nix-support/orig-libc - '' - - + (if nativeTools then '' - gccPath="${nativePrefix}/bin" - ldPath="${nativePrefix}/bin" - '' else '' - echo $gcc > $out/nix-support/orig-gcc - - # GCC shows $gcc/lib in `gcc -print-search-dirs', but not - # $gcc/lib64 (even though it does actually search there...).. - # This confuses libtool. So add it to the compiler tool search - # path explicitly. - if [ -e "$gcc/lib64" -a ! -L "$gcc/lib64" ]; then - gccLDFlags+=" -L$gcc/lib64" - gccCFlags+=" -B$gcc/lib64" - fi - gccLDFlags+=" -L$gcc/lib" - - ${optionalString gcc.langVhdl or false '' - gccLDFlags+=" -L${zlib}/lib" - ''} - - # Find the gcc libraries path (may work only without multilib). - ${optionalString gcc.langAda or false '' - basePath=`echo $gcc/lib/*/*/*` - gccCFlags+=" -B$basePath -I$basePath/adainclude" - gnatCFlags="-aI$basePath/adainclude -aO$basePath/adalib" - echo "$gnatCFlags" > $out/nix-support/gnat-cflags - ''} - - echo "$gccLDFlags" > $out/nix-support/gcc-ldflags - echo "$gccCFlags" > $out/nix-support/gcc-cflags - - gccPath="$gcc/bin" - ldPath="$binutils/bin" - - # Propagate the wrapped gcc so that if you install the wrapper, - # you get tools like gcov, the manpages, etc. as well (including - # for binutils and Glibc). - echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages - - echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs - '' - - + optionalString (stdenv.isSunOS && nativePrefix != "") '' - # Solaris needs an additional ld wrapper. - ldPath="${nativePrefix}/bin" - ld="$out/bin/ld-solaris" - wrap ld-solaris ${./ld-solaris-wrapper.sh} - '') - - + '' - # Create a symlink to as (the assembler). This is useful when a - # gcc-wrapper is installed in a user environment, as it ensures that - # the right assembler is called. - if [ -e $ldPath/as ]; then - ln -s $ldPath/as $out/bin/as - fi - - wrap ld ${./ld-wrapper.sh} ''${ld:-$ldPath/ld} - - if [ -e $binutils/bin/ld.gold ]; then - wrap ld.gold ${./ld-wrapper.sh} $binutils/bin/ld.gold - fi - - if [ -e $binutils/bin/ld.bfd ]; then - wrap ld.bfd ${./ld-wrapper.sh} $binutils/bin/ld.bfd - fi - - if [ -e $gccPath/gcc ]; then - wrap gcc ${./gcc-wrapper.sh} $gccPath/gcc - ln -s gcc $out/bin/cc - elif [ -e $gccPath/clang ]; then - wrap clang ${./gcc-wrapper.sh} $gccPath/clang - ln -s clang $out/bin/cc - fi - - if [ -e $gccPath/g++ ]; then - wrap g++ ${./gcc-wrapper.sh} $gccPath/g++ - ln -s g++ $out/bin/c++ - elif [ -e $gccPath/clang++ ]; then - wrap clang++ ${./gcc-wrapper.sh} $gccPath/clang++ - ln -s clang++ $out/bin/c++ - fi - - if [ -e $gccPath/cpp ]; then - wrap cpp ${./gcc-wrapper.sh} $gccPath/cpp - fi - '' - - + optionalString gcc.langFortran or false '' - wrap gfortran ${./gcc-wrapper.sh} $gccPath/gfortran - ln -sv gfortran $out/bin/g77 - ln -sv gfortran $out/bin/f77 - '' - - + optionalString gcc.langJava or false '' - wrap gcj ${./gcc-wrapper.sh} $gccPath/gcj - '' - - + optionalString gcc.langGo or false '' - wrap gccgo ${./gcc-wrapper.sh} $gccPath/gccgo - '' - - + optionalString gcc.langAda or false '' - wrap gnatgcc ${./gcc-wrapper.sh} $gccPath/gnatgcc - wrap gnatmake ${./gnat-wrapper.sh} $gccPath/gnatmake - wrap gnatbind ${./gnat-wrapper.sh} $gccPath/gnatbind - wrap gnatlink ${./gnatlink-wrapper.sh} $gccPath/gnatlink - '' - - + optionalString gcc.langVhdl or false '' - ln -s $gccPath/ghdl $out/bin/ghdl - '' - - + '' - substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook - substituteAll ${./add-flags} $out/nix-support/add-flags.sh - cp -p ${./utils.sh} $out/nix-support/utils.sh - - if [ -e $out/bin/clang ]; then - echo 'export CC; : ''${CC:=clang}' >> $out/nix-support/setup-hook - fi - - if [ -e $out/bin/clang++ ]; then - echo 'export CXX; : ''${CXX:=clang++}' >> $out/nix-support/setup-hook - fi - ''; - - # The dynamic linker has different names on different Linux platforms. - dynamicLinker = - if !nativeLibc then - (if stdenv.system == "i686-linux" then "ld-linux.so.2" else - if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else - # ARM with a wildcard, which can be "" or "-armhf". - if stdenv.isArm then "ld-linux*.so.3" else - if stdenv.system == "powerpc-linux" then "ld.so.1" else - if stdenv.system == "mips64el-linux" then "ld.so.1" else - abort "Don't know the name of the dynamic linker for this platform.") - else ""; - - crossAttrs = { - shell = shell.crossDrv + shell.crossDrv.shellPath; - libc = stdenv.ccCross.libc; - coreutils = coreutils.crossDrv; - binutils = binutils.crossDrv; - gcc = gcc.crossDrv; - # - # This is not the best way to do this. I think the reference should be - # the style in the gcc-cross-wrapper, but to keep a stable stdenv now I - # do this sufficient if/else. - dynamicLinker = - (if stdenv.cross.arch == "arm" then "ld-linux.so.3" else - if stdenv.cross.arch == "mips" then "ld.so.1" else - if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else - abort "don't know the name of the dynamic linker for this platform"); - }; - - meta = - let gcc_ = if gcc != null then gcc else {}; in - (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) // - { description = - stdenv.lib.attrByPath ["meta" "description"] "System C compiler" gcc_ - + " (wrapper script)"; - }; -} diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh deleted file mode 100644 index c918cc30d9ab..000000000000 --- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh +++ /dev/null @@ -1,146 +0,0 @@ -#! @shell@ -e - -if [ -n "$NIX_CC_WRAPPER_START_HOOK" ]; then - source "$NIX_CC_WRAPPER_START_HOOK" -fi - -if [ -z "$NIX_CC_WRAPPER_FLAGS_SET" ]; then - source @out@/nix-support/add-flags.sh -fi - -source @out@/nix-support/utils.sh - - -# Figure out if linker flags should be passed. GCC prints annoying -# warnings when they are not needed. -dontLink=0 -getVersion=0 -nonFlagArgs=0 - -for i in "$@"; do - if [ "$i" = -c ]; then - dontLink=1 - elif [ "$i" = -S ]; then - dontLink=1 - elif [ "$i" = -E ]; then - dontLink=1 - elif [ "$i" = -E ]; then - dontLink=1 - elif [ "$i" = -M ]; then - dontLink=1 - elif [ "$i" = -MM ]; then - dontLink=1 - elif [ "$i" = -x ]; then - # At least for the cases c-header or c++-header we should set dontLink. - # I expect no one use -x other than making precompiled headers. - dontLink=1 - elif [ "${i:0:1}" != - ]; then - nonFlagArgs=1 - elif [ "$i" = -m32 ]; then - if [ -e @out@/nix-support/dynamic-linker-m32 ]; then - NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" - fi - fi -done - -# If we pass a flag like -Wl, then gcc will call the linker unless it -# can figure out that it has to do something else (e.g., because of a -# "-c" flag). So if no non-flag arguments are given, don't pass any -# linker flags. This catches cases like "gcc" (should just print -# "gcc: no input files") and "gcc -v" (should print the version). -if [ "$nonFlagArgs" = 0 ]; then - dontLink=1 -fi - - -# Optionally filter out paths not refering to the store. -params=("$@") -if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then - rest=() - n=0 - while [ $n -lt ${#params[*]} ]; do - p=${params[n]} - p2=${params[$((n+1))]} - if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then - skip $p - elif [ "$p" = -L ] && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then - skip $p - elif [ "$p" = -I ] && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif [ "$p" = -isystem ] && badPath "$p2"; then - n=$((n + 1)); skip $p2 - else - rest=("${rest[@]}" "$p") - fi - n=$((n + 1)) - done - params=("${rest[@]}") -fi - - -# Add the flags for the C compiler proper. -extraAfter=($NIX_CFLAGS_COMPILE) -extraBefore=() - -# When enforcing purity, pretend gcc can't find the current date and -# time -if [ "$NIX_ENFORCE_PURITY" = 1 ]; then - extraAfter+=('-D__DATE__="Jan 01 1970"' - '-D__TIME__="00:00:01"' - -Wno-builtin-macro-redefined) -fi - - -if [ "$dontLink" != 1 ]; then - - # Add the flags that should only be passed to the compiler when - # linking. - extraAfter+=($NIX_CFLAGS_LINK) - - # Add the flags that should be passed to the linker (and prevent - # `ld-wrapper' from adding NIX_LDFLAGS again). - for i in $NIX_LDFLAGS_BEFORE; do - extraBefore=(${extraBefore[@]} "-Wl,$i") - done - for i in $NIX_LDFLAGS; do - if [ "${i:0:3}" = -L/ ]; then - extraAfter+=("$i") - else - extraAfter+=("-Wl,$i") - fi - done - export NIX_LDFLAGS_SET=1 -fi - -# As a very special hack, if the arguments are just `-v', then don't -# add anything. This is to prevent `gcc -v' (which normally prints -# out the version number and returns exit code 0) from printing out -# `No input files specified' and returning exit code 1. -if [ "$*" = -v ]; then - extraAfter=() - extraBefore=() -fi - -# Optionally print debug info. -if [ -n "$NIX_DEBUG" ]; then - echo "original flags to @prog@:" >&2 - for i in "${params[@]}"; do - echo " $i" >&2 - done - echo "extraBefore flags to @prog@:" >&2 - for i in ${extraBefore[@]}; do - echo " $i" >&2 - done - echo "extraAfter flags to @prog@:" >&2 - for i in ${extraAfter[@]}; do - echo " $i" >&2 - done -fi - -if [ -n "$NIX_CC_WRAPPER_EXEC_HOOK" ]; then - source "$NIX_CC_WRAPPER_EXEC_HOOK" -fi - -exec @prog@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" diff --git a/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh b/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh deleted file mode 100644 index 3514ccd67325..000000000000 --- a/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh +++ /dev/null @@ -1,103 +0,0 @@ -#! @shell@ -e - -if [ -n "$NIX_GNAT_WRAPPER_START_HOOK" ]; then - source "$NIX_GNAT_WRAPPER_START_HOOK" -fi - -if [ -z "$NIX_GNAT_WRAPPER_FLAGS_SET" ]; then - source @out@/nix-support/add-flags.sh -fi - -source @out@/nix-support/utils.sh - - -# Figure out if linker flags should be passed. GCC prints annoying -# warnings when they are not needed. -dontLink=0 -getVersion=0 -nonFlagArgs=0 - -for i in "$@"; do - if [ "$i" = -c ]; then - dontLink=1 - elif [ "$i" = -M ]; then - dontLink=1 - elif [ "${i:0:1}" != - ]; then - nonFlagArgs=1 - elif [ "$i" = -m32 ]; then - if [ -e @out@/nix-support/dynamic-linker-m32 ]; then - NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" - fi - fi -done - -# If we pass a flag like -Wl, then gcc will call the linker unless it -# can figure out that it has to do something else (e.g., because of a -# "-c" flag). So if no non-flag arguments are given, don't pass any -# linker flags. This catches cases like "gcc" (should just print -# "gcc: no input files") and "gcc -v" (should print the version). -if [ "$nonFlagArgs" = 0 ]; then - dontLink=1 -fi - - -# Optionally filter out paths not refering to the store. -params=("$@") -if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then - rest=() - n=0 - while [ $n -lt ${#params[*]} ]; do - p=${params[n]} - p2=${params[$((n+1))]} - if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then - skip $p - elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then - skip $p - elif [ "${p:0:4}" = -aI/ ] && badPath "${p:3}"; then - skip $p - elif [ "${p:0:4}" = -aO/ ] && badPath "${p:3}"; then - skip $p - else - rest=("${rest[@]}" "$p") - fi - n=$((n + 1)) - done - params=("${rest[@]}") -fi - - -# Add the flags for the GNAT compiler proper. -extraAfter=($NIX_GNATFLAGS_COMPILE) -extraBefore=() - -if [ "`basename $0`x" = "gnatmakex" ]; then - extraBefore=("--GNATBIND=@out@/bin/gnatbind --GNATLINK=@out@/bin/gnatlink ") -fi - -# Add the flags that should be passed to the linker (and prevent -# `ld-wrapper' from adding NIX_LDFLAGS again). -#for i in $NIX_LDFLAGS_BEFORE; do -# extraBefore=(${extraBefore[@]} "-largs $i") -#done - -# Optionally print debug info. -if [ -n "$NIX_DEBUG" ]; then - echo "original flags to @prog@:" >&2 - for i in "${params[@]}"; do - echo " $i" >&2 - done - echo "extraBefore flags to @prog@:" >&2 - for i in ${extraBefore[@]}; do - echo " $i" >&2 - done - echo "extraAfter flags to @prog@:" >&2 - for i in ${extraAfter[@]}; do - echo " $i" >&2 - done -fi - -if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then - source "$NIX_GNAT_WRAPPER_EXEC_HOOK" -fi - -exec @prog@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh b/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh deleted file mode 100644 index c9958dbbb413..000000000000 --- a/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh +++ /dev/null @@ -1,33 +0,0 @@ -#! @shell@ -e - -# Add the flags for the GNAT compiler proper. -extraAfter="--GCC=@out@/bin/gcc" -extraBefore=() - -# Add the flags that should be passed to the linker (and prevent -# `ld-wrapper' from adding NIX_LDFLAGS again). -#for i in $NIX_LDFLAGS_BEFORE; do -# extraBefore=(${extraBefore[@]} "-largs $i") -#done - -# Optionally print debug info. -if [ -n "$NIX_DEBUG" ]; then - echo "original flags to @prog@:" >&2 - for i in "$@"; do - echo " $i" >&2 - done - echo "extraBefore flags to @prog@:" >&2 - for i in ${extraBefore[@]}; do - echo " $i" >&2 - done - echo "extraAfter flags to @prog@:" >&2 - for i in ${extraAfter[@]}; do - echo " $i" >&2 - done -fi - -if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then - source "$NIX_GNAT_WRAPPER_EXEC_HOOK" -fi - -exec @prog@ ${extraBefore[@]} "$@" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh deleted file mode 100644 index 9216ea3198dd..000000000000 --- a/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -e -set -u - -# I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'( -# Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3 -# but still no success. -cmd="@prog@ -z ignore" - -args=("$@"); - -# This loop makes sure all -L arguments are before -l arguments, or ld may complain it cannot find a library. -# GNU binutils does not have this problem: -# http://stackoverflow.com/questions/5817269/does-the-order-of-l-and-l-options-in-the-gnu-linker-matter -i=0; -while [[ $i -lt $# ]]; do - case "${args[$i]}" in - -L) cmd="$cmd ${args[$i]} ${args[($i+1)]}"; i=($i+1); ;; - -L*) cmd="$cmd ${args[$i]}" ;; - *) ;; - esac - i=($i+1); -done - -i=0; -while [[ $i -lt $# ]]; do - case "${args[$i]}" in - -L) i=($i+1); ;; - -L*) ;; - *) cmd="$cmd ${args[$i]}" ;; - esac - i=($i+1); -done - -# Trace: -set -x -exec $cmd - -exit 0 diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh deleted file mode 100644 index 30c531b76479..000000000000 --- a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh +++ /dev/null @@ -1,166 +0,0 @@ -#! @shell@ -e - -if [ -n "$NIX_LD_WRAPPER_START_HOOK" ]; then - source "$NIX_LD_WRAPPER_START_HOOK" -fi - -if [ -z "$NIX_CC_WRAPPER_FLAGS_SET" ]; then - source @out@/nix-support/add-flags.sh -fi - -source @out@/nix-support/utils.sh - - -# Optionally filter out paths not refering to the store. -params=("$@") -if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" \ - -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \) ]; then - rest=() - n=0 - while [ $n -lt ${#params[*]} ]; do - p=${params[n]} - p2=${params[$((n+1))]} - if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then - skip $p - elif [ "$p" = -L ] && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif [ "$p" = -rpath ] && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif [ "$p" = -dynamic-linker ] && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif [ "${p:0:1}" = / ] && badPath "$p"; then - # We cannot skip this; barf. - echo "impure path \`$p' used in link" >&2 - exit 1 - elif [ "${p:0:9}" = --sysroot ]; then - # Our ld is not built with sysroot support (Can we fix that?) - : - else - rest=("${rest[@]}" "$p") - fi - n=$((n + 1)) - done - params=("${rest[@]}") -fi - - -extra=() -extraBefore=() - -if [ -z "$NIX_LDFLAGS_SET" ]; then - extra+=($NIX_LDFLAGS) - extraBefore+=($NIX_LDFLAGS_BEFORE) -fi - -extra+=($NIX_LDFLAGS_AFTER) - - -# Add all used dynamic libraries to the rpath. -if [ "$NIX_DONT_SET_RPATH" != 1 ]; then - - libPath="" - addToLibPath() { - local path="$1" - if [ "${path:0:1}" != / ]; then return 0; fi - case "$path" in - *..*|*./*|*/.*|*//*) - local path2 - if path2=$(readlink -f "$path"); then - path="$path2" - fi - ;; - esac - case $libPath in - *\ $path\ *) return 0 ;; - esac - libPath="$libPath $path " - } - - addToRPath() { - # If the path is not in the store, don't add it to the rpath. - # This typically happens for libraries in /tmp that are later - # copied to $out/lib. If not, we're screwed. - if [ "${1:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then return 0; fi - case $rpath in - *\ $1\ *) return 0 ;; - esac - rpath="$rpath $1 " - } - - libs="" - addToLibs() { - libs="$libs $1" - } - - rpath="" - - # First, find all -L... switches. - allParams=("${params[@]}" ${extra[@]}) - n=0 - while [ $n -lt ${#allParams[*]} ]; do - p=${allParams[n]} - p2=${allParams[$((n+1))]} - if [ "${p:0:3}" = -L/ ]; then - addToLibPath ${p:2} - elif [ "$p" = -L ]; then - addToLibPath ${p2} - n=$((n + 1)) - elif [ "$p" = -l ]; then - addToLibs ${p2} - n=$((n + 1)) - elif [ "${p:0:2}" = -l ]; then - addToLibs ${p:2} - elif [ "$p" = -dynamic-linker ]; then - # Ignore the dynamic linker argument, or it - # will get into the next 'elif'. We don't want - # the dynamic linker path rpath to go always first. - n=$((n + 1)) - elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then - # This is a direct reference to a shared library, so add - # its directory to the rpath. - path="$(dirname "$p")"; - addToRPath "${path}" - fi - n=$((n + 1)) - done - - # Second, for each directory in the library search path (-L...), - # see if it contains a dynamic library used by a -l... flag. If - # so, add the directory to the rpath. - # It's important to add the rpath in the order of -L..., so - # the link time chosen objects will be those of runtime linking. - - for i in $libPath; do - for j in $libs; do - if [ -f "$i/lib$j.so" ]; then - addToRPath $i - break - fi - done - done - - - # Finally, add `-rpath' switches. - for i in $rpath; do - extra=(${extra[@]} -rpath $i) - done -fi - - -# Optionally print debug info. -if [ -n "$NIX_DEBUG" ]; then - echo "original flags to @prog@:" >&2 - for i in "${params[@]}"; do - echo " $i" >&2 - done - echo "extra flags to @prog@:" >&2 - for i in ${extra[@]}; do - echo " $i" >&2 - done -fi - -if [ -n "$NIX_LD_WRAPPER_EXEC_HOOK" ]; then - source "$NIX_LD_WRAPPER_EXEC_HOOK" -fi - -exec @prog@ ${extraBefore[@]} "${params[@]}" ${extra[@]} diff --git a/pkgs/build-support/gcc-wrapper/setup-hook.sh b/pkgs/build-support/gcc-wrapper/setup-hook.sh deleted file mode 100644 index f0034fee1bed..000000000000 --- a/pkgs/build-support/gcc-wrapper/setup-hook.sh +++ /dev/null @@ -1,38 +0,0 @@ -export NIX_CC=@out@ - -addCVars () { - if [ -d $1/include ]; then - export NIX_CFLAGS_COMPILE+=" -isystem $1/include" - fi - - if [ -d $1/lib64 -a ! -L $1/lib64 ]; then - export NIX_LDFLAGS+=" -L$1/lib64" - fi - - if [ -d $1/lib ]; then - export NIX_LDFLAGS+=" -L$1/lib" - fi -} - -envHooks+=(addCVars) - -# Note: these come *after* $out in the PATH (see setup.sh). - -if [ -n "@gcc@" ]; then - addToSearchPath PATH @gcc@/bin -fi - -if [ -n "@binutils@" ]; then - addToSearchPath PATH @binutils@/bin -fi - -if [ -n "@libc@" ]; then - addToSearchPath PATH @libc@/bin -fi - -if [ -n "@coreutils@" ]; then - addToSearchPath PATH @coreutils@/bin -fi - -export CC=cc -export CXX=c++ diff --git a/pkgs/build-support/gcc-wrapper/utils.sh b/pkgs/build-support/gcc-wrapper/utils.sh deleted file mode 100644 index 3ab512d85c4e..000000000000 --- a/pkgs/build-support/gcc-wrapper/utils.sh +++ /dev/null @@ -1,24 +0,0 @@ -skip () { - if [ -n "$NIX_DEBUG" ]; then - echo "skipping impure path $1" >&2 - fi -} - - -# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but -# `/nix/store/.../lib/foo.so' isn't. -badPath() { - local p=$1 - - # Relative paths are okay (since they're presumably relative to - # the temporary build directory). - if [ "${p:0:1}" != / ]; then return 1; fi - - # Otherwise, the path should refer to the store or some temporary - # directory (including the build directory). - test \ - "$p" != "/dev/null" -a \ - "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \ - "${p:0:4}" != "/tmp" -a \ - "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP" -} diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 6d8ca55a0fcd..282d59d590a6 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -8,7 +8,7 @@ rec { # Override the compiler in stdenv for specific packages. - overrideGCC = stdenv: gcc: stdenv.override { allowedRequisites = null; cc = gcc; }; + overrideCC = stdenv: cc: stdenv.override { allowedRequisites = null; cc = cc; }; # Add some arbitrary packages to buildInputs for specific packages. diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index e7ee53178c77..15895956fd0f 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -18,13 +18,13 @@ import ../generic rec { system = stdenv.system; - cc = import ../../build-support/gcc-wrapper { + cc = import ../../build-support/cc-wrapper { nativeTools = false; nativeLibc = true; inherit stdenv; extraPackages = stdenv.lib.optional haveLibCxx pkgs.libcxx; binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; - gcc = if useClang33 then pkgs.clang_33.gcc else pkgs.clang.gcc; + cc = if useClang33 then pkgs.clang_33.cc else pkgs.clang.cc; coreutils = pkgs.coreutils; shell = pkgs.bash + "/bin/sh"; }; diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 6f35d5fc0c80..63b4c802c892 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -85,10 +85,10 @@ rec { cc = if isNull gccPlain then "/no-such-path" - else lib.makeOverridable (import ../../build-support/gcc-wrapper) { + else lib.makeOverridable (import ../../build-support/cc-wrapper) { nativeTools = false; nativeLibc = false; - gcc = gccPlain; + cc = gccPlain; libc = glibc; inherit binutils coreutils; name = name; @@ -209,7 +209,7 @@ rec { mpc = pkgs.mpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; isl = pkgs.isl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; cloog = pkgs.cloog.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; - gccPlain = pkgs.gcc.gcc; + gccPlain = pkgs.gcc.cc; }; extraBuildInputs = [ stage2.pkgs.patchelf stage2.pkgs.paxctl ]; }; @@ -229,10 +229,10 @@ rec { # other purposes (binutils and top-level pkgs) too. inherit (stage3.pkgs) gettext gnum4 gmp perl glibc zlib linuxHeaders; - gcc = lib.makeOverridable (import ../../build-support/gcc-wrapper) { + gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) { nativeTools = false; nativeLibc = false; - gcc = stage4.stdenv.cc.gcc; + cc = stage4.stdenv.cc.cc; libc = stage4.pkgs.glibc; inherit (stage4.pkgs) binutils coreutils; name = ""; diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index 45c8ebb70213..925b90c964f2 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -98,8 +98,8 @@ rec { }; - cc = import ../../build-support/gcc-wrapper { - name = "gcc-native"; + cc = import ../../build-support/cc-wrapper { + name = "cc-native"; nativeTools = true; nativeLibc = true; nativePrefix = if system == "i686-solaris" then "/usr/gnu" else if system == "x86_64-solaris" then "/opt/local/gcc47" else "/usr"; diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix index 476e0eae3970..79c9fb3a1378 100644 --- a/pkgs/stdenv/nix/default.nix +++ b/pkgs/stdenv/nix/default.nix @@ -13,13 +13,13 @@ import ../generic rec { system = stdenv.system; - gcc = import ../../build-support/gcc-wrapper { + cc = import ../../build-support/cc-wrapper { nativeTools = false; nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; nativeLibc = true; inherit stdenv; binutils = pkgs.binutils; - gcc = pkgs.gcc.gcc; + cc = pkgs.gcc.cc; coreutils = pkgs.coreutils; shell = pkgs.bash + "/bin/sh"; }; @@ -29,8 +29,8 @@ import ../generic rec { fetchurlBoot = stdenv.fetchurlBoot; overrides = pkgs_: { - inherit gcc; - inherit (gcc) binutils; + inherit cc; + inherit (cc) binutils; inherit (pkgs) gzip bzip2 xz bash coreutils diffutils findutils gawk gnumake gnused gnutar gnugrep gnupatch perl; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d0cb0c8901ca..78f7e0bbabef 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -239,7 +239,7 @@ let # just the plain stdenv. stdenv_32bit = lowPrio ( if system == "x86_64-linux" then - overrideGCC stdenv gcc48_multi + overrideCC stdenv gcc48_multi else stdenv); @@ -2624,7 +2624,7 @@ let torbutton = callPackage ../tools/security/torbutton { }; torbrowser = callPackage ../tools/security/tor/torbrowser.nix { - stdenv = overrideGCC stdenv gcc49; + stdenv = overrideCC stdenv gcc49; }; torsocks = callPackage ../tools/security/tor/torsocks.nix { }; @@ -3046,10 +3046,10 @@ let ccl = callPackage ../development/compilers/ccl { }; - clang = wrapGCC llvmPackages.clang; + clang = wrapCC llvmPackages.clang; - clang_34 = wrapGCC llvmPackages_34.clang; - clang_33 = wrapGCC (clangUnwrapped llvm_33 ../development/compilers/llvm/3.3/clang.nix); + clang_34 = wrapCC llvmPackages_34.clang; + clang_33 = wrapCC (clangUnwrapped llvm_33 ../development/compilers/llvm/3.3/clang.nix); clangAnalyzer = callPackage ../development/tools/analysis/clang-analyzer { clang = clang_34; @@ -3062,8 +3062,8 @@ let clangSelf = clangWrapSelf llvmPackagesSelf.clang; - clangWrapSelf = build: (import ../build-support/gcc-wrapper) { - gcc = build; + clangWrapSelf = build: (import ../build-support/cc-wrapper) { + cc = build; stdenv = clangStdenv; libc = glibc; binutils = binutils; @@ -3074,8 +3074,8 @@ let }; #Use this instead of stdenv to build with clang - clangStdenv = if stdenv.isDarwin then stdenv else lowPrio (stdenvAdapters.overrideGCC stdenv clang); - libcxxStdenv = stdenvAdapters.overrideGCC stdenv (clangWrapSelf llvmPackages.clang); + clangStdenv = if stdenv.isDarwin then stdenv else lowPrio (stdenvAdapters.overrideCC stdenv clang); + libcxxStdenv = stdenvAdapters.overrideCC stdenv (clangWrapSelf llvmPackages.clang); clean = callPackage ../development/compilers/clean { }; @@ -3115,7 +3115,7 @@ let gccApple = throw "gccApple is no longer supported"; - gcc34 = wrapGCC (import ../development/compilers/gcc/3.4 { + gcc34 = wrapCC (import ../development/compilers/gcc/3.4 { inherit fetchurl stdenv noSysDirs; }); @@ -3177,14 +3177,14 @@ let cross = assert crossSystem != null; crossSystem; }; - gcc44 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc/4.4) { + gcc44 = lowPrio (wrapCC (makeOverridable (import ../development/compilers/gcc/4.4) { inherit fetchurl stdenv gmp mpfr /* ppl cloogppl */ gettext which noSysDirs; texinfo = texinfo4; profiledCompiler = true; })); - gcc45 = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.5 { + gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 { inherit fetchurl stdenv gmp mpfr mpc libelf zlib perl gettext which noSysDirs; texinfo = texinfo4; @@ -3207,7 +3207,7 @@ let else null; })); - gcc46 = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.6 { + gcc46 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.6 { inherit noSysDirs; ppl = null; @@ -3229,7 +3229,7 @@ let texinfo = texinfo413; })); - gcc48 = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.8 { + gcc48 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.8 { inherit noSysDirs; # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion @@ -3248,14 +3248,14 @@ let gcc48_multi = if system == "x86_64-linux" then lowPrio ( - wrapGCCWith (import ../build-support/gcc-wrapper) glibc_multi (gcc48.gcc.override { - stdenv = overrideGCC stdenv (wrapGCCWith (import ../build-support/gcc-wrapper) glibc_multi gcc.gcc); + wrapCCWith (import ../build-support/cc-wrapper) glibc_multi (gcc48.gcc.override { + stdenv = overrideCC stdenv (wrapCCWith (import ../build-support/cc-wrapper) glibc_multi gcc.gcc); profiledCompiler = false; enableMultilib = true; })) else throw "Multilib gcc not supported on ‘${system}’"; - gcc48_debug = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.8 { + gcc48_debug = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.8 { stripped = false; inherit noSysDirs; @@ -3264,7 +3264,7 @@ let binutilsCross = null; })); - gcc49 = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.9 { + gcc49 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.9 { inherit noSysDirs; # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion @@ -3283,7 +3283,7 @@ let gfortran = gfortran48; - gfortran48 = wrapGCC (gcc48.gcc.override { + gfortran48 = wrapCC (gcc48.cc.override { name = "gfortran"; langFortran = true; langCC = false; @@ -3293,7 +3293,7 @@ let gcj = gcj48; - gcj48 = wrapGCC (gcc48.gcc.override { + gcj48 = wrapCC (gcc48.cc.override { name = "gcj"; langJava = true; langFortran = false; @@ -3309,7 +3309,7 @@ let gnat = gnat45; # failed to make 4.6 or 4.8 build - gnat45 = wrapGCC (gcc45.gcc.override { + gnat45 = wrapCC (gcc45.cc.override { name = "gnat"; langCC = false; langC = true; @@ -3328,14 +3328,14 @@ let gccgo = gccgo48; - gccgo48 = wrapGCC (gcc48.gcc.override { + gccgo48 = wrapCC (gcc48.cc.override { name = "gccgo"; langCC = true; #required for go. langC = true; langGo = true; }); - ghdl = wrapGCC (import ../development/compilers/gcc/4.3 { + ghdl = wrapCC (import ../development/compilers/gcc/4.3 { inherit stdenv fetchurl gmp mpfr noSysDirs gnat; texinfo = texinfo4; name = "ghdl"; @@ -4020,18 +4020,25 @@ let win32hello = callPackage ../development/compilers/visual-c++/test { }; - wrapGCCWith = gccWrapper: glibc: baseGCC: gccWrapper { + wrapCCWith = ccWrapper: libc: baseCC: ccWrapper { nativeTools = stdenv.cc.nativeTools or false; nativeLibc = stdenv.cc.nativeLibc or false; nativePrefix = stdenv.cc.nativePrefix or ""; - gcc = baseGCC; - libc = glibc; + cc = baseCC; + libc = libc; inherit stdenv binutils coreutils zlib; }; - wrapGCC = wrapGCCWith (makeOverridable (import ../build-support/gcc-wrapper)) glibc; + wrapCC = wrapCCWith (makeOverridable (import ../build-support/cc-wrapper)) glibc; # legacy version, used for gnat bootstrapping - wrapGCC-old = wrapGCCWith (makeOverridable (import ../build-support/gcc-wrapper-old)) glibc; + wrapGCC-old = baseGCC: (makeOverridable (import ../build-support/gcc-wrapper-old)) { + nativeTools = stdenv.cc.nativeTools or false; + nativeLibc = stdenv.cc.nativeLibc or false; + nativePrefix = stdenv.cc.nativePrefix or ""; + gcc = baseGCC; + libc = glibc; + inherit stdenv binutils coreutils zlib; + }; wrapGCCCross = {gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}: @@ -4361,7 +4368,7 @@ let avrgcclibc = callPackage ../development/misc/avr-gcc-with-avr-libc { gcc = gcc46; - stdenv = overrideGCC stdenv gcc46; + stdenv = overrideCC stdenv gcc46; }; avr8burnomat = callPackage ../development/misc/avr8-burn-omat { }; @@ -4517,8 +4524,8 @@ let # }; # ccacheWrapper = makeOverridable ({ extraConfig ? "" }: - wrapGCC (ccache.links extraConfig)) {}; - ccacheStdenv = lowPrio (overrideGCC stdenv ccacheWrapper); + wrapCC (ccache.links extraConfig)) {}; + ccacheStdenv = lowPrio (overrideCC stdenv ccacheWrapper); cccc = callPackage ../development/tools/analysis/cccc { }; @@ -4600,8 +4607,8 @@ let # }; # distccWrapper = makeOverridable ({ extraConfig ? "" }: - wrapGCC (distcc.links extraConfig)) {}; - distccStdenv = lowPrio (overrideGCC stdenv distccWrapper); + wrapCC (distcc.links extraConfig)) {}; + distccStdenv = lowPrio (overrideCC stdenv distccWrapper); distccMasquerade = if stdenv.isDarwin then null @@ -4772,7 +4779,7 @@ let phantomjs = callPackage ../development/tools/phantomjs { stdenv = if stdenv.isDarwin - then overrideGCC stdenv gccApple + then overrideCC stdenv gccApple else stdenv; }; @@ -4925,7 +4932,7 @@ let # On Darwin, Valgrind 3.7.0 expects Apple's GCC (for # `__private_extern'.) if stdenv.isDarwin - then overrideGCC stdenv gccApple + then overrideCC stdenv gccApple else stdenv; }; @@ -5243,7 +5250,7 @@ let vpxSupport = !stdenv.isMips; stdenv = if stdenv.isDarwin - then overrideGCC stdenv gccApple + then overrideCC stdenv gccApple else stdenv; }; @@ -6141,7 +6148,7 @@ let libmikmod = callPackage ../development/libraries/libmikmod { # resolve the "stray '@' in program" errors stdenv = if stdenv.isDarwin - then overrideGCC stdenv gccApple + then overrideCC stdenv gccApple else stdenv; }; @@ -6250,7 +6257,7 @@ let libproxy = callPackage ../development/libraries/libproxy { stdenv = if stdenv.isDarwin - then overrideGCC stdenv gcc + then overrideCC stdenv gcc else stdenv; }; @@ -7072,7 +7079,7 @@ let stfl = callPackage ../development/libraries/stfl { stdenv = if stdenv.isDarwin - then overrideGCC stdenv gccApple + then overrideCC stdenv gccApple else stdenv; }; @@ -10213,7 +10220,7 @@ let irssi = callPackage ../applications/networking/irc/irssi { # compile with gccApple on darwin to support the -no-cpp-precompile flag stdenv = if stdenv.isDarwin - then stdenvAdapters.overrideGCC stdenv gccApple + then stdenvAdapters.overrideCC stdenv gccApple else stdenv; }; @@ -11542,7 +11549,7 @@ let xdotool = callPackage ../tools/X11/xdotool { }; xen = callPackage ../applications/virtualization/xen { - stdenv = overrideGCC stdenv gcc45; + stdenv = overrideCC stdenv gcc45; }; xfe = callPackage ../applications/misc/xfe { @@ -11661,7 +11668,7 @@ let (let callPackage = newScope pkgs.zathuraCollection; in import ../applications/misc/zathura { inherit callPackage pkgs fetchurl; - stdenv = overrideGCC stdenv gcc49; + stdenv = overrideCC stdenv gcc49; useMupdf = config.zathura.useMupdf or false; }); @@ -11673,7 +11680,7 @@ let girara = callPackage ../applications/misc/girara { gtk = gtk3; - stdenv = overrideGCC stdenv gcc49; + stdenv = overrideCC stdenv gcc49; }; girara-light = callPackage ../applications/misc/girara { -- cgit 1.4.1