Adding a new version of the gcc-wrapper, named gcc-wrapper2, in order not to rebuild stdenv.

In this gcc-wrapper2 I made the ld-wrapper.sh to handle the linking with shared
objects through direct pass as ld command arguments of the absolute path to shared
objects, instead of using the -L/-l combinations.

cmake 'FindXXX.cmake' modules make a strong usage of the dynamic linking directly
passing the absolute path to the shared object to the linker, and as our wrapper did
not add any -rpath for those, writting the nix expressions for some cmake packages
resulted in a lot of tricks, compared to using this gcc-wrapper2.

This gcc-wrapper2/ld-wrapper.sh should become the gcc-wrapper/ld-wrapper in a
stdenv update.

I also updated some cmake expressions to use this gcc-wrapper2, and reduced its
tricks.

I also updated the cmake setup-hook for it to make cmake not touch any rpath decided
at build time, when running the 'make install' of makefiles created by cmake.

svn path=/nixpkgs/trunk/; revision=18885

+606 -136
-21
pkgs/applications/graphics/autopanosiftc/default.nix
··· 10 10 11 11 buildInputs = [ cmake libpng libtiff libjpeg panotools libxml2 ]; 12 12 13 - # I added these flags to get all the rpaths right, which I guess they are 14 - # taken from the qt4 sources. Not very nice. 15 - cmakeFlags = "-DCMAKE_SHARED_LINKER_FLAGS=\"-Wl,-rpath,$out/lib\"" + 16 - " -DCMAKE_EXE_LINKER_FLAGS=\"-Wl,-rpath,$out/lib" + 17 - " -lpng12 -lpano13 -ljpeg -ltiff -lz -lxml2 \"" + 18 - " -DCMAKE_SKIP_BUILD_RPATH=ON" + 19 - " -DCMAKE_BUILD_TYPE=Release" + 20 - " -DCMAKE_INSTALL_PREFIX=$out"; 21 - 22 - dontUseCmakeConfigure = true; 23 - 24 - # I rewrote the configure phase to get the $out references evaluated in 25 - # cmakeFlags 26 - configurePhase = '' 27 - set -x 28 - mkdir -p build; 29 - cd build 30 - eval -- "cmake .. $cmakeFlags" 31 - set +x 32 - ''; 33 - 34 13 meta = { 35 14 homepage = http://hugin.sourceforge.net/; 36 15 description = "Implementation in C of the autopano-sift algorithm for automatically stitching panoramas";
-20
pkgs/applications/graphics/freepv/default.nix
··· 17 17 sed -i -e '/mozilla/d' src/CMakeLists.txt 18 18 ''; 19 19 20 - # I added these flags to get all the rpaths right, which I guess they are 21 - # taken from the qt4 sources. Not very nice. 22 - cmakeFlags = " -DCMAKE_EXE_LINKER_FLAGS=\"" + 23 - " -lpng12 -lXxf86vm -ljpeg -lz -lglut -lGLU -lxml2 -lX11\"" + 24 - " -DCMAKE_SKIP_BUILD_RPATH=ON" + 25 - " -DCMAKE_BUILD_TYPE=Release" + 26 - " -DCMAKE_INSTALL_PREFIX=$out"; 27 - 28 - dontUseCmakeConfigure = true; 29 - 30 - # I rewrote the configure phase to get the $out references evaluated in 31 - # cmakeFlags 32 - configurePhase = '' 33 - set -x 34 - mkdir -p build; 35 - cd build 36 - eval -- "cmake .. $cmakeFlags" 37 - set +x 38 - ''; 39 - 40 20 meta = { 41 21 description = "Open source panorama viewer using GL"; 42 22 homepage = http://freepv.sourceforge.net/;
+2 -22
pkgs/applications/graphics/hugin/default.nix
··· 15 15 16 16 NIX_LDFLAGS = "-lrt"; 17 17 18 - # I added these flags to get all the rpaths right, which I guess they are 19 - # taken from the qt4 sources. Not very nice. 20 - cmakeFlags = "-DCMAKE_SHARED_LINKER_FLAGS=\"-Wl,-rpath,$out/lib\"" + 21 - " -DCMAKE_EXE_LINKER_FLAGS=\"-Wl,-rpath,$out/lib" + 22 - " -lpng12 -lpano13 -lImath -lIlmImf -lIex -lHalf -lIlmThread" + 23 - " -ljpeg -ltiff -lz -lexiv2 -lboost_thread\"" + 24 - " -DCMAKE_SKIP_BUILD_RPATH=ON" + 25 - " -DCMAKE_BUILD_TYPE=Release" + 26 - " -DCMAKE_INSTALL_PREFIX=$out"; 27 - 28 - buildInputs = [ cmake panotools wxGTK libtiff libpng openexr boost pkgconfig exiv2 gettext ilmbase ]; 29 - 30 - dontUseCmakeConfigure = true; 18 + buildInputs = [ cmake panotools wxGTK libtiff libpng openexr boost pkgconfig 19 + exiv2 gettext ilmbase ]; 31 20 32 - # I rewrote the configure phase to get the $out references evaluated in 33 - # cmakeFlags 34 - configurePhase = '' 35 - set -x 36 - mkdir -p build; 37 - cd build 38 - eval -- "cmake .. $cmakeFlags" 39 - set +x 40 - ''; 41 21 postInstall = '' 42 22 ensureDir "$out/nix-support" 43 23 echo "${enblendenfuse} ${autopanosiftc}" > $out/nix-support/propagated-user-env-packages
+6 -26
pkgs/applications/graphics/paraview/default.nix
··· 1 1 { fetchurl, stdenv, cmake, qt4 }: 2 2 3 3 stdenv.mkDerivation { 4 - name = "paraview-3.4.0"; 4 + name = "paraview-3.6.1"; 5 5 src = fetchurl { 6 - url = http://www.paraview.org/files/v3.4/paraview-3.4.0.tar.gz; 7 - sha256 = "27544f442e957e9aa60b32c674f2dcd84fffeecc9a40071ef6e305333413187d"; 6 + url = http://www.paraview.org/files/v3.6/paraview-3.6.1.tar.gz; 7 + sha256 = "1dh0dqbdvjagy122nbwr1gg03ck2if2aqqbvzcpkx38sz12cjh7h"; 8 8 }; 9 9 10 - patches = [ ./include-qobject.patch ]; 11 - 12 - # I added these flags to get all the rpaths right, which I guess they are 13 - # taken from the qt4 sources. Not very nice. 14 - cmakeFlags = "-DCMAKE_SHARED_LINKER_FLAGS=\"-Wl,-rpath,$out/lib/paraview-3.4\"" + 15 - " -DCMAKE_EXE_LINKER_FLAGS=\"-Wl,-rpath,$out/lib/paraview-3.4" + 16 - " -lpng12 -lSM -lICE -lXrender -lXrandr -lXcursor -lXinerama" + 17 - " -lXfixes -lfreetype -lfontconfig -lXext -lX11 -lssl -lXt -lz\"" + 18 - " -DCMAKE_SKIP_BUILD_RPATH=ON" + 19 - " -DCMAKE_BUILD_TYPE=Release" + 20 - " -DCMAKE_INSTALL_PREFIX=$out"; 21 - 22 - dontUseCmakeConfigure = true; 23 - 24 - # I rewrote the configure phase to get the $out references evaluated in 25 - # cmakeFlags 26 - configurePhase = '' 27 - set -x 28 - mkdir -p build; 29 - cd build 30 - eval -- "cmake .. $cmakeFlags" 31 - set +x 32 - ''; 10 + preConfigure = '' 11 + export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/paraview-3.6" 12 + ''; 33 13 34 14 buildInputs = [ cmake qt4 ]; 35 15
-38
pkgs/applications/graphics/paraview/include-qobject.patch
··· 1 - diff --git a/VTK/GUISupport/Qt/CMakeLists.txt b/VTK/GUISupport/Qt/CMakeLists.txt 2 - index 2c35be7..866f1aa 100644 3 - --- a/VTK/GUISupport/Qt/CMakeLists.txt 4 - +++ b/VTK/GUISupport/Qt/CMakeLists.txt 5 - @@ -166,6 +166,7 @@ IF(DESIRED_QT_VERSION MATCHES 4) 6 - ) 7 - ENDIF(QT_QTGUI_LIBRARY) 8 - INCLUDE_DIRECTORIES(${QT_QTDESIGNER_INCLUDE_DIR}) 9 - + INCLUDE_DIRECTORIES(${QT_QTCORE_INCLUDE_DIR}) 10 - QT4_WRAP_CPP ( PluginMocSrcs ${PluginMocHeaders} ) 11 - ELSE(DESIRED_QT_VERSION MATCHES 4) 12 - QT_WRAP_CPP ( QVTKWidgetPlugin PluginMocSrcs ${PluginMocHeaders} ) 13 - diff --git a/VTK/GUISupport/Qt/vtkEventQtSlotConnect.h b/VTK/GUISupport/Qt/vtkEventQtSlotConnect.h 14 - index 6782b90..ced3a67 100644 15 - --- a/VTK/GUISupport/Qt/vtkEventQtSlotConnect.h 16 - +++ b/VTK/GUISupport/Qt/vtkEventQtSlotConnect.h 17 - @@ -43,7 +43,7 @@ 18 - #include "vtkObject.h" 19 - #include "vtkCommand.h" // for event defines 20 - #include "QVTKWin32Header.h" // for export define 21 - -#include "qobject.h" // for version info 22 - +#include <qobject.h> // for version info 23 - 24 - class QObject; 25 - class vtkQtConnections; 26 - diff --git a/VTK/GUISupport/Qt/vtkQtConnection.h b/VTK/GUISupport/Qt/vtkQtConnection.h 27 - index 923ec2e..b189ddc 100644 28 - --- a/VTK/GUISupport/Qt/vtkQtConnection.h 29 - +++ b/VTK/GUISupport/Qt/vtkQtConnection.h 30 - @@ -33,7 +33,7 @@ 31 - 32 - #include "vtkObject.h" 33 - #include "vtkCommand.h" // for event defines 34 - -#include "qobject.h" 35 - +#include <qobject.h> 36 - 37 - class QObject; 38 - class vtkCallbackCommand;
+2 -4
pkgs/applications/video/avidemux/default.nix
··· 18 18 19 19 cmakeFlags = "-DPTHREAD_INCLUDE_DIR=${stdenv.glibc}/include" + 20 20 " -DGETTEXT_INCLUDE_DIR=${gettext}/include" + 21 - " -DSDL_INCLUDE_DIR=${SDL}/include/SDL" + 22 - " -DCMAKE_SKIP_BUILD_RPATH=ON" + 23 - " -DCMAKE_BUILD_TYPE=Release"; 21 + " -DSDL_INCLUDE_DIR=${SDL}/include/SDL"; 24 22 25 - NIX_LDFLAGS="-lxml2 -lXv -lSDL -lQtGui -lQtCore -lpthread"; 23 + NIX_LDFLAGS="-lpthread"; 26 24 27 25 postInstall = '' 28 26 cd $NIX_BUILD_TOP/$sourceRoot
+6
pkgs/build-support/gcc-wrapper2/README
··· 1 + To be removed after we merge stdenv-updates in. 2 + stdenv-updates should have this gcc-wrapper2 as gcc-wrapper. 3 + 4 + Changelog against gcc-wrapper: 5 + - Support for linking shared objects with direct mention of the /path/libxxx.so object, 6 + thus, adding its path to the rpath.
+24
pkgs/build-support/gcc-wrapper2/add-flags
··· 1 + # `-B@out@/bin' forces gcc to use ld-wrapper.sh when calling ld. 2 + export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE" 3 + 4 + if test -e @out@/nix-support/libc-cflags; then 5 + export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE" 6 + fi 7 + 8 + if test -e @out@/nix-support/gcc-cflags; then 9 + export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/gcc-cflags) $NIX_CFLAGS_COMPILE" 10 + fi 11 + 12 + if test -e @out@/nix-support/libc-ldflags; then 13 + export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)" 14 + fi 15 + 16 + if test -e @out@/nix-support/gcc-ldflags; then 17 + export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/gcc-ldflags)" 18 + fi 19 + 20 + if test -e @out@/nix-support/libc-ldflags-before; then 21 + export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE" 22 + fi 23 + 24 + export NIX_GCC_WRAPPER_FLAGS_SET=1
+135
pkgs/build-support/gcc-wrapper2/builder.sh
··· 1 + source $stdenv/setup 2 + 3 + 4 + ensureDir $out/bin 5 + ensureDir $out/nix-support 6 + 7 + 8 + if test -z "$nativeLibc"; then 9 + dynamicLinker="$libc/lib/$dynamicLinker" 10 + echo $dynamicLinker > $out/nix-support/dynamic-linker 11 + 12 + if test -e $libc/lib/32/ld-linux.so.2; then 13 + echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 14 + fi 15 + 16 + # The "-B$libc/lib/" flag is a quick hack to force gcc to link 17 + # against the crt1.o from our own glibc, rather than the one in 18 + # /usr/lib. (This is only an issue when using an `impure' 19 + # compiler/linker, i.e., one that searches /usr/lib and so on.) 20 + # 21 + # Unfortunately, setting -B appears to override the default search 22 + # path. Thus, the gcc-specific "../includes-fixed" directory is 23 + # now longer searched and glibc's <limits.h> header fails to 24 + # compile, because it uses "#include_next <limits.h>" to find the 25 + # limits.h file in ../includes-fixed. To remedy the problem, 26 + # another -idirafter is necessary to add that directory again. 27 + echo "-B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags 28 + 29 + echo "-L$libc/lib" > $out/nix-support/libc-ldflags 30 + 31 + # The dynamic linker is passed in `ldflagsBefore' to allow 32 + # explicit overrides of the dynamic linker by callers to gcc/ld 33 + # (the *last* value counts, so ours should come first). 34 + echo "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before 35 + fi 36 + 37 + if test -n "$nativeTools"; then 38 + gccPath="$nativePrefix/bin" 39 + ldPath="$nativePrefix/bin" 40 + else 41 + if test -e "$gcc/lib64"; then 42 + gccLDFlags="$gccLDFlags -L$gcc/lib64" 43 + fi 44 + gccLDFlags="$gccLDFlags -L$gcc/lib" 45 + echo "$gccLDFlags" > $out/nix-support/gcc-ldflags 46 + 47 + # GCC shows $gcc/lib in `gcc -print-search-dirs', but not 48 + # $gcc/lib64 (even though it does actually search there...).. 49 + # This confuses libtool. So add it to the compiler tool search 50 + # path explicitly. 51 + if test -e "$gcc/lib64"; then 52 + gccCFlags="$gccCFlags -B$gcc/lib64" 53 + fi 54 + echo "$gccCFlags" > $out/nix-support/gcc-cflags 55 + 56 + gccPath="$gcc/bin" 57 + ldPath="$binutils/bin" 58 + fi 59 + 60 + 61 + doSubstitute() { 62 + local src=$1 63 + local dst=$2 64 + # Can't use substitute() here, because replace may not have been 65 + # built yet (in the bootstrap). 66 + sed \ 67 + -e "s^@out@^$out^g" \ 68 + -e "s^@shell@^$shell^g" \ 69 + -e "s^@gcc@^$gcc^g" \ 70 + -e "s^@gccProg@^$gccProg^g" \ 71 + -e "s^@binutils@^$binutils^g" \ 72 + -e "s^@libc@^$libc^g" \ 73 + -e "s^@ld@^$ldPath/ld^g" \ 74 + < "$src" > "$dst" 75 + } 76 + 77 + 78 + # Make wrapper scripts around gcc, g++, and gfortran. Also make symlinks 79 + # cc, c++, and f77. 80 + mkGccWrapper() { 81 + local dst=$1 82 + local src=$2 83 + 84 + if ! test -f "$src"; then 85 + echo "$src does not exist (skipping)" 86 + return 87 + fi 88 + 89 + gccProg="$src" 90 + doSubstitute "$gccWrapper" "$dst" 91 + chmod +x "$dst" 92 + } 93 + 94 + mkGccWrapper $out/bin/gcc $gccPath/gcc 95 + ln -s gcc $out/bin/cc 96 + 97 + mkGccWrapper $out/bin/g++ $gccPath/g++ 98 + ln -s g++ $out/bin/c++ 99 + 100 + if test -e $gccPath/gfortran; then 101 + mkGccWrapper $out/bin/gfortran $gccPath/gfortran 102 + ln -s gfortran $out/bin/g77 103 + ln -s gfortran $out/bin/f77 104 + fi 105 + 106 + 107 + # Create a symlink to as (the assembler). This is useful when a 108 + # gcc-wrapper is installed in a user environment, as it ensures that 109 + # the right assembler is called. 110 + ln -s $ldPath/as $out/bin/as 111 + 112 + 113 + # Make a wrapper around the linker. 114 + doSubstitute "$ldWrapper" "$out/bin/ld" 115 + chmod +x "$out/bin/ld" 116 + 117 + 118 + # Emit a setup hook. Also store the path to the original GCC and 119 + # Glibc. 120 + test -n "$gcc" && echo $gcc > $out/nix-support/orig-gcc 121 + test -n "$libc" && echo $libc > $out/nix-support/orig-libc 122 + 123 + doSubstitute "$addFlags" "$out/nix-support/add-flags.sh" 124 + 125 + doSubstitute "$setupHook" "$out/nix-support/setup-hook" 126 + 127 + cp -p $utils $out/nix-support/utils.sh 128 + 129 + 130 + # Propagate the wrapped gcc so that if you install the wrapper, you get 131 + # tools like gcov, the manpages, etc. as well (including for binutils 132 + # and Glibc). 133 + if test -z "$nativeTools"; then 134 + echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages 135 + fi
+60
pkgs/build-support/gcc-wrapper2/default.nix
··· 1 + # The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't 2 + # know where the C library and standard header files are. Therefore 3 + # the compiler produced by that package cannot be installed directly 4 + # in a user environment and used from the command line. This 5 + # stdenv.mkDerivation provides a wrapper that sets up the right environment 6 + # variables so that the compiler and the linker just "work". 7 + 8 + { name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" 9 + , gcc ? null, libc ? null, binutils ? null, shell ? "" 10 + }: 11 + 12 + assert nativeTools -> nativePrefix != ""; 13 + assert !nativeTools -> gcc != null && binutils != null; 14 + assert !nativeLibc -> libc != null; 15 + 16 + let 17 + 18 + gccVersion = (builtins.parseDrvName gcc.name).version; 19 + gccName = (builtins.parseDrvName gcc.name).name; 20 + 21 + in 22 + 23 + stdenv.mkDerivation { 24 + name = 25 + (if name != "" then name else gccName + "-wrapper") + 26 + (if gcc != null && gccVersion != "" then "-" + gccVersion else ""); 27 + 28 + builder = ./builder.sh; 29 + setupHook = ./setup-hook.sh; 30 + gccWrapper = ./gcc-wrapper.sh; 31 + ldWrapper = ./ld-wrapper.sh; 32 + utils = ./utils.sh; 33 + addFlags = ./add-flags; 34 + 35 + inherit nativeTools nativeLibc nativePrefix gcc; 36 + libc = if nativeLibc then null else libc; 37 + binutils = if nativeTools then null else binutils; 38 + 39 + langC = if nativeTools then true else gcc.langC; 40 + langCC = if nativeTools then true else gcc.langCC; 41 + langFortran = if nativeTools then false else gcc ? langFortran; 42 + shell = if shell == "" then stdenv.shell else shell; 43 + 44 + meta = 45 + let gcc_ = if gcc != null then gcc else {}; in 46 + (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) // 47 + { description = 48 + stdenv.lib.attrByPath ["meta" "description"] "System C compiler" gcc_ 49 + + " (wrapper script)"; 50 + }; 51 + 52 + # The dynamic linker has different names on different Linux platforms. 53 + dynamicLinker = 54 + if !nativeLibc then 55 + (if stdenv.system == "i686-linux" then "ld-linux.so.2" else 56 + if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else 57 + if stdenv.system == "powerpc-linux" then "ld.so.1" else 58 + abort "don't know the name of the dynamic linker for this platform") 59 + else ""; 60 + }
+148
pkgs/build-support/gcc-wrapper2/gcc-wrapper.sh
··· 1 + #! @shell@ -e 2 + 3 + if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then 4 + source "$NIX_GCC_WRAPPER_START_HOOK" 5 + fi 6 + 7 + if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then 8 + source @out@/nix-support/add-flags.sh 9 + fi 10 + 11 + source @out@/nix-support/utils.sh 12 + 13 + 14 + # Figure out if linker flags should be passed. GCC prints annoying 15 + # warnings when they are not needed. 16 + dontLink=0 17 + getVersion=0 18 + nonFlagArgs=0 19 + 20 + for i in "$@"; do 21 + if test "$i" = "-c"; then 22 + dontLink=1 23 + elif test "$i" = "-S"; then 24 + dontLink=1 25 + elif test "$i" = "-E"; then 26 + dontLink=1 27 + elif test "$i" = "-E"; then 28 + dontLink=1 29 + elif test "$i" = "-M"; then 30 + dontLink=1 31 + elif test "$i" = "-MM"; then 32 + dontLink=1 33 + elif test "${i:0:1}" != "-"; then 34 + nonFlagArgs=1 35 + elif test "$i" = "-m32"; then 36 + if test -e @out@/nix-support/dynamic-linker-m32; then 37 + NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" 38 + fi 39 + fi 40 + done 41 + 42 + # If we pass a flag like -Wl, then gcc will call the linker unless it 43 + # can figure out that it has to do something else (e.g., because of a 44 + # "-c" flag). So if no non-flag arguments are given, don't pass any 45 + # linker flags. This catches cases like "gcc" (should just print 46 + # "gcc: no input files") and "gcc -v" (should print the version). 47 + if test "$nonFlagArgs" = "0"; then 48 + dontLink=1 49 + fi 50 + 51 + 52 + # Optionally filter out paths not refering to the store. 53 + params=("$@") 54 + if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then 55 + rest=() 56 + n=0 57 + while test $n -lt ${#params[*]}; do 58 + p=${params[n]} 59 + p2=${params[$((n+1))]} 60 + if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then 61 + skip $p 62 + elif test "$p" = "-L" && badPath "$p2"; then 63 + n=$((n + 1)); skip $p2 64 + elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then 65 + skip $p 66 + elif test "$p" = "-I" && badPath "$p2"; then 67 + n=$((n + 1)); skip $p2 68 + elif test "$p" = "-isystem" && badPath "$p2"; then 69 + n=$((n + 1)); skip $p2 70 + else 71 + rest=("${rest[@]}" "$p") 72 + fi 73 + n=$((n + 1)) 74 + done 75 + params=("${rest[@]}") 76 + fi 77 + 78 + 79 + # Add the flags for the C compiler proper. 80 + extraAfter=($NIX_CFLAGS_COMPILE) 81 + extraBefore=() 82 + 83 + if test "$dontLink" != "1"; then 84 + 85 + # Add the flags that should only be passed to the compiler when 86 + # linking. 87 + extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK) 88 + 89 + # Add the flags that should be passed to the linker (and prevent 90 + # `ld-wrapper' from adding NIX_LDFLAGS again). 91 + for i in $NIX_LDFLAGS_BEFORE; do 92 + extraBefore=(${extraBefore[@]} "-Wl,$i") 93 + done 94 + for i in $NIX_LDFLAGS; do 95 + if test "${i:0:3}" = "-L/"; then 96 + extraAfter=(${extraAfter[@]} "$i") 97 + else 98 + extraAfter=(${extraAfter[@]} "-Wl,$i") 99 + fi 100 + done 101 + export NIX_LDFLAGS_SET=1 102 + 103 + if test "$NIX_STRIP_DEBUG" = "1"; then 104 + # Add executable-stripping flags. 105 + extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP) 106 + fi 107 + fi 108 + 109 + # As a very special hack, if the arguments are just `-v', then don't 110 + # add anything. This is to prevent `gcc -v' (which normally prints 111 + # out the version number and returns exit code 0) from printing out 112 + # `No input files specified' and returning exit code 1. 113 + if test "$*" = "-v"; then 114 + extraAfter=() 115 + extraBefore=() 116 + fi 117 + 118 + # Optionally print debug info. 119 + if test "$NIX_DEBUG" = "1"; then 120 + echo "original flags to @gccProg@:" >&2 121 + for i in "${params[@]}"; do 122 + echo " $i" >&2 123 + done 124 + echo "extraBefore flags to @gccProg@:" >&2 125 + for i in ${extraBefore[@]}; do 126 + echo " $i" >&2 127 + done 128 + echo "extraAfter flags to @gccProg@:" >&2 129 + for i in ${extraAfter[@]}; do 130 + echo " $i" >&2 131 + done 132 + fi 133 + 134 + if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then 135 + source "$NIX_GCC_WRAPPER_EXEC_HOOK" 136 + fi 137 + 138 + 139 + # Call the real `gcc'. Filter out warnings from stderr about unused 140 + # `-B' flags, since they confuse some programs. Deep bash magic to 141 + # apply grep to stderr (by swapping stdin/stderr twice). 142 + if test -z "$NIX_GCC_NEEDS_GREP"; then 143 + @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 144 + else 145 + (@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \ 146 + | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3- 147 + exit $? 148 + fi
+155
pkgs/build-support/gcc-wrapper2/ld-wrapper.sh
··· 1 + #! @shell@ -e 2 + 3 + if test -n "$NIX_LD_WRAPPER_START_HOOK"; then 4 + source "$NIX_LD_WRAPPER_START_HOOK" 5 + fi 6 + 7 + if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then 8 + source @out@/nix-support/add-flags.sh 9 + fi 10 + 11 + source @out@/nix-support/utils.sh 12 + 13 + 14 + # Optionally filter out paths not refering to the store. 15 + params=("$@") 16 + if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \ 17 + -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then 18 + rest=() 19 + n=0 20 + while test $n -lt ${#params[*]}; do 21 + p=${params[n]} 22 + p2=${params[$((n+1))]} 23 + if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then 24 + skip $p 25 + elif test "$p" = "-L" && badPath "$p2"; then 26 + n=$((n + 1)); skip $p2 27 + elif test "$p" = "-rpath" && badPath "$p2"; then 28 + n=$((n + 1)); skip $p2 29 + elif test "$p" = "-dynamic-linker" && badPath "$p2"; then 30 + n=$((n + 1)); skip $p2 31 + elif test "${p:0:1}" = "/" && badPath "$p"; then 32 + # We cannot skip this; barf. 33 + echo "impure path \`$p' used in link" >&2 34 + exit 1 35 + else 36 + rest=("${rest[@]}" "$p") 37 + fi 38 + n=$((n + 1)) 39 + done 40 + params=("${rest[@]}") 41 + fi 42 + 43 + 44 + extra=() 45 + extraBefore=() 46 + 47 + if test -z "$NIX_LDFLAGS_SET"; then 48 + extra=(${extra[@]} $NIX_LDFLAGS) 49 + extraBefore=(${extraBefore[@]} $NIX_LDFLAGS_BEFORE) 50 + fi 51 + 52 + 53 + # Add all used dynamic libraries to the rpath. 54 + if test "$NIX_DONT_SET_RPATH" != "1"; then 55 + 56 + # First, find all -L... switches. 57 + allParams=("${params[@]}" ${extra[@]}) 58 + libPath="" 59 + addToLibPath() { 60 + local path="$1" 61 + if test "${path:0:1}" != "/"; then return 0; fi 62 + case "$path" in 63 + *..*|*./*|*/.*|*//*) 64 + local path2 65 + if path2=$(readlink -f "$path"); then 66 + path="$path2" 67 + fi 68 + ;; 69 + esac 70 + case $libPath in 71 + *\ $path\ *) return 0 ;; 72 + esac 73 + libPath="$libPath $path " 74 + } 75 + n=0 76 + while test $n -lt ${#allParams[*]}; do 77 + p=${allParams[n]} 78 + p2=${allParams[$((n+1))]} 79 + if test "${p:0:3}" = "-L/"; then 80 + addToLibPath ${p:2} 81 + elif test "$p" = "-L"; then 82 + addToLibPath ${p2} 83 + n=$((n + 1)) 84 + elif $(echo "$p" | grep -q '\.so\($\|\.\)'); then 85 + path="$(dirname "$p")"; 86 + addToLibPath "${path}" 87 + fi 88 + n=$((n + 1)) 89 + done 90 + 91 + # Second, for each directory in the library search path (-L...), 92 + # see if it contains a dynamic library used by a -l... flag. If 93 + # so, add the directory to the rpath. 94 + rpath="" 95 + 96 + addToRPath() { 97 + # If the path is not in the store, don't add it to the rpath. 98 + # This typically happens for libraries in /tmp that are later 99 + # copied to $out/lib. If not, we're screwed. 100 + if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi 101 + case $rpath in 102 + *\ $1\ *) return 0 ;; 103 + esac 104 + rpath="$rpath $1 " 105 + } 106 + 107 + for i in $libPath; do 108 + n=0 109 + while test $n -lt ${#allParams[*]}; do 110 + p=${allParams[n]} 111 + p2=${allParams[$((n+1))]} 112 + if test "${p:0:2}" = "-l" -a -f "$i/lib${p:2}.so"; then 113 + addToRPath $i 114 + break 115 + elif test "$p" = "-l" -a -f "$i/lib${p2}"; then 116 + # I haven't seen `-l foo', but you never know... 117 + addToRPath $i 118 + break 119 + elif $(echo "$p" | grep -q '\.so\($\|\.\)'); then 120 + path="$(dirname "$p")"; 121 + if test "$path" == "$i"; then 122 + addToRPath $i 123 + break; 124 + fi 125 + fi 126 + n=$((n + 1)) 127 + done 128 + 129 + done 130 + 131 + 132 + # Finally, add `-rpath' switches. 133 + for i in $rpath; do 134 + extra=(${extra[@]} -rpath $i) 135 + done 136 + fi 137 + 138 + 139 + # Optionally print debug info. 140 + if test "$NIX_DEBUG" = "1"; then 141 + echo "original flags to @ld@:" >&2 142 + for i in "${params[@]}"; do 143 + echo " $i" >&2 144 + done 145 + echo "extra flags to @ld@:" >&2 146 + for i in ${extra[@]}; do 147 + echo " $i" >&2 148 + done 149 + fi 150 + 151 + if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then 152 + source "$NIX_LD_WRAPPER_EXEC_HOOK" 153 + fi 154 + 155 + exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}
+29
pkgs/build-support/gcc-wrapper2/setup-hook.sh
··· 1 + addCVars () { 2 + if test -d $1/include; then 3 + export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$1/include" 4 + fi 5 + 6 + if test -d $1/lib64; then 7 + export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64" 8 + fi 9 + 10 + if test -d $1/lib; then 11 + export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib" 12 + fi 13 + } 14 + 15 + envHooks=(${envHooks[@]} addCVars) 16 + 17 + # Note: these come *after* $out in the PATH (see setup.sh). 18 + 19 + if test -n "@gcc@"; then 20 + addToSearchPath PATH @gcc@/bin 21 + fi 22 + 23 + if test -n "@binutils@"; then 24 + addToSearchPath PATH @binutils@/bin 25 + fi 26 + 27 + if test -n "@libc@"; then 28 + addToSearchPath PATH @libc@/bin 29 + fi
+23
pkgs/build-support/gcc-wrapper2/utils.sh
··· 1 + skip () { 2 + if test "$NIX_DEBUG" = "1"; then 3 + echo "skipping impure path $1" >&2 4 + fi 5 + } 6 + 7 + 8 + # Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but 9 + # `/nix/store/.../lib/foo.so' isn't. 10 + badPath() { 11 + local p=$1 12 + 13 + # Relative paths are okay (since they're presumably relative to 14 + # the temporary build directory). 15 + if test "${p:0:1}" != "/"; then return 1; fi 16 + 17 + # Otherwise, the path should refer to the store or some temporary 18 + # directory (including the build directory). 19 + test \ 20 + "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \ 21 + "${p:0:4}" != "/tmp" -a \ 22 + "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP" 23 + }
+3
pkgs/development/tools/build-managers/cmake/setup-hook.sh
··· 32 32 cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix $cmakeFlags" 33 33 fi 34 34 35 + # Avoid cmake resetting the rpath of binaries, on make install 36 + cmakeFlags="-DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags" 37 + 35 38 echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}" 36 39 37 40 cmake ${cmakeDir:-.} $cmakeFlags ${cmakeFlagsArray[@]}
+13 -5
pkgs/top-level/all-packages.nix
··· 1783 1783 1784 1784 gcc43 = useFromStdenv "gcc" gcc43_real; 1785 1785 1786 + gcc43_wrapper2 = wrapGCC2 gcc43.gcc; 1787 + 1786 1788 gcc43_real = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.3) { 1787 1789 inherit fetchurl stdenv texinfo gmp mpfr noSysDirs; 1788 1790 profiledCompiler = true; ··· 2217 2219 }; 2218 2220 2219 2221 wrapGCC = wrapGCCWith (import ../build-support/gcc-wrapper) glibc; 2222 + wrapGCC2 = wrapGCCWith (import ../build-support/gcc-wrapper2) glibc; 2220 2223 2221 2224 # FIXME: This is a specific hack for GCC-UPC. Eventually, we may 2222 2225 # want to merge `gcc-upc-wrapper' and `gcc-wrapper'. ··· 6234 6237 }; 6235 6238 6236 6239 autopanosiftc = import ../applications/graphics/autopanosiftc { 6237 - inherit fetchurl stdenv cmake libpng libtiff libjpeg panotools libxml2; 6240 + inherit fetchurl cmake libpng libtiff libjpeg panotools libxml2; 6241 + stdenv = overrideGCC stdenv gcc43_wrapper2; 6238 6242 }; 6239 6243 6240 6244 avidemux = import ../applications/video/avidemux { 6241 - inherit fetchurl stdenv cmake pkgconfig libxml2 qt4 gettext SDL libxslt x264 6245 + inherit fetchurl cmake pkgconfig libxml2 qt4 gettext SDL libxslt x264 6242 6246 alsaLib lame faac faad2 libvorbis; 6247 + stdenv = overrideGCC stdenv gcc43_wrapper2; 6243 6248 inherit (gtkLibs) gtk; 6244 6249 inherit (xlibs) libXv pixman libpthreadstubs libXau libXdmcp; 6245 6250 }; ··· 6768 6773 }; 6769 6774 6770 6775 freepv = import ../applications/graphics/freepv { 6771 - inherit fetchurl stdenv mesa freeglut libjpeg zlib cmake libxml2 libpng; 6776 + inherit fetchurl mesa freeglut libjpeg zlib cmake libxml2 libpng; 6777 + stdenv = overrideGCC stdenv gcc43_wrapper2; 6772 6778 inherit (xlibs) libX11 libXxf86vm; 6773 6779 }; 6774 6780 ··· 6918 6924 }; 6919 6925 6920 6926 hugin = import ../applications/graphics/hugin { 6921 - inherit stdenv fetchurl cmake panotools libtiff libpng boost pkgconfig 6927 + inherit fetchurl cmake panotools libtiff libpng boost pkgconfig 6922 6928 exiv2 gettext ilmbase enblendenfuse autopanosiftc; 6923 6929 inherit wxGTK; 6924 6930 openexr = openexr_1_6_1; 6931 + stdenv = overrideGCC stdenv gcc43_wrapper2; 6925 6932 }; 6926 6933 6927 6934 i810switch = import ../applications/misc/i810 { ··· 7285 7292 }; 7286 7293 7287 7294 paraview = import ../applications/graphics/paraview { 7288 - inherit fetchurl stdenv cmake qt4; 7295 + inherit fetchurl cmake qt4; 7296 + stdenv = overrideGCC stdenv gcc43_wrapper2; 7289 7297 }; 7290 7298 7291 7299 partitionManager = import ../tools/misc/partition-manager {