forked from mirrors/nixpkgs
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
This commit is contained in:
parent
164eb9c699
commit
f3c23487a2
|
@ -10,27 +10,6 @@ stdenv.mkDerivation {
|
|||
|
||||
buildInputs = [ cmake libpng libtiff libjpeg panotools libxml2 ];
|
||||
|
||||
# I added these flags to get all the rpaths right, which I guess they are
|
||||
# taken from the qt4 sources. Not very nice.
|
||||
cmakeFlags = "-DCMAKE_SHARED_LINKER_FLAGS=\"-Wl,-rpath,$out/lib\"" +
|
||||
" -DCMAKE_EXE_LINKER_FLAGS=\"-Wl,-rpath,$out/lib" +
|
||||
" -lpng12 -lpano13 -ljpeg -ltiff -lz -lxml2 \"" +
|
||||
" -DCMAKE_SKIP_BUILD_RPATH=ON" +
|
||||
" -DCMAKE_BUILD_TYPE=Release" +
|
||||
" -DCMAKE_INSTALL_PREFIX=$out";
|
||||
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
# I rewrote the configure phase to get the $out references evaluated in
|
||||
# cmakeFlags
|
||||
configurePhase = ''
|
||||
set -x
|
||||
mkdir -p build;
|
||||
cd build
|
||||
eval -- "cmake .. $cmakeFlags"
|
||||
set +x
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = http://hugin.sourceforge.net/;
|
||||
description = "Implementation in C of the autopano-sift algorithm for automatically stitching panoramas";
|
||||
|
|
|
@ -17,26 +17,6 @@ stdenv.mkDerivation {
|
|||
sed -i -e '/mozilla/d' src/CMakeLists.txt
|
||||
'';
|
||||
|
||||
# I added these flags to get all the rpaths right, which I guess they are
|
||||
# taken from the qt4 sources. Not very nice.
|
||||
cmakeFlags = " -DCMAKE_EXE_LINKER_FLAGS=\"" +
|
||||
" -lpng12 -lXxf86vm -ljpeg -lz -lglut -lGLU -lxml2 -lX11\"" +
|
||||
" -DCMAKE_SKIP_BUILD_RPATH=ON" +
|
||||
" -DCMAKE_BUILD_TYPE=Release" +
|
||||
" -DCMAKE_INSTALL_PREFIX=$out";
|
||||
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
# I rewrote the configure phase to get the $out references evaluated in
|
||||
# cmakeFlags
|
||||
configurePhase = ''
|
||||
set -x
|
||||
mkdir -p build;
|
||||
cd build
|
||||
eval -- "cmake .. $cmakeFlags"
|
||||
set +x
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Open source panorama viewer using GL";
|
||||
homepage = http://freepv.sourceforge.net/;
|
||||
|
|
|
@ -15,29 +15,9 @@ stdenv.mkDerivation {
|
|||
|
||||
NIX_LDFLAGS = "-lrt";
|
||||
|
||||
# I added these flags to get all the rpaths right, which I guess they are
|
||||
# taken from the qt4 sources. Not very nice.
|
||||
cmakeFlags = "-DCMAKE_SHARED_LINKER_FLAGS=\"-Wl,-rpath,$out/lib\"" +
|
||||
" -DCMAKE_EXE_LINKER_FLAGS=\"-Wl,-rpath,$out/lib" +
|
||||
" -lpng12 -lpano13 -lImath -lIlmImf -lIex -lHalf -lIlmThread" +
|
||||
" -ljpeg -ltiff -lz -lexiv2 -lboost_thread\"" +
|
||||
" -DCMAKE_SKIP_BUILD_RPATH=ON" +
|
||||
" -DCMAKE_BUILD_TYPE=Release" +
|
||||
" -DCMAKE_INSTALL_PREFIX=$out";
|
||||
buildInputs = [ cmake panotools wxGTK libtiff libpng openexr boost pkgconfig
|
||||
exiv2 gettext ilmbase ];
|
||||
|
||||
buildInputs = [ cmake panotools wxGTK libtiff libpng openexr boost pkgconfig exiv2 gettext ilmbase ];
|
||||
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
# I rewrote the configure phase to get the $out references evaluated in
|
||||
# cmakeFlags
|
||||
configurePhase = ''
|
||||
set -x
|
||||
mkdir -p build;
|
||||
cd build
|
||||
eval -- "cmake .. $cmakeFlags"
|
||||
set +x
|
||||
'';
|
||||
postInstall = ''
|
||||
ensureDir "$out/nix-support"
|
||||
echo "${enblendenfuse} ${autopanosiftc}" > $out/nix-support/propagated-user-env-packages
|
||||
|
|
|
@ -1,34 +1,14 @@
|
|||
{ fetchurl, stdenv, cmake, qt4 }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "paraview-3.4.0";
|
||||
name = "paraview-3.6.1";
|
||||
src = fetchurl {
|
||||
url = http://www.paraview.org/files/v3.4/paraview-3.4.0.tar.gz;
|
||||
sha256 = "27544f442e957e9aa60b32c674f2dcd84fffeecc9a40071ef6e305333413187d";
|
||||
url = http://www.paraview.org/files/v3.6/paraview-3.6.1.tar.gz;
|
||||
sha256 = "1dh0dqbdvjagy122nbwr1gg03ck2if2aqqbvzcpkx38sz12cjh7h";
|
||||
};
|
||||
|
||||
patches = [ ./include-qobject.patch ];
|
||||
|
||||
# I added these flags to get all the rpaths right, which I guess they are
|
||||
# taken from the qt4 sources. Not very nice.
|
||||
cmakeFlags = "-DCMAKE_SHARED_LINKER_FLAGS=\"-Wl,-rpath,$out/lib/paraview-3.4\"" +
|
||||
" -DCMAKE_EXE_LINKER_FLAGS=\"-Wl,-rpath,$out/lib/paraview-3.4" +
|
||||
" -lpng12 -lSM -lICE -lXrender -lXrandr -lXcursor -lXinerama" +
|
||||
" -lXfixes -lfreetype -lfontconfig -lXext -lX11 -lssl -lXt -lz\"" +
|
||||
" -DCMAKE_SKIP_BUILD_RPATH=ON" +
|
||||
" -DCMAKE_BUILD_TYPE=Release" +
|
||||
" -DCMAKE_INSTALL_PREFIX=$out";
|
||||
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
# I rewrote the configure phase to get the $out references evaluated in
|
||||
# cmakeFlags
|
||||
configurePhase = ''
|
||||
set -x
|
||||
mkdir -p build;
|
||||
cd build
|
||||
eval -- "cmake .. $cmakeFlags"
|
||||
set +x
|
||||
preConfigure = ''
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/paraview-3.6"
|
||||
'';
|
||||
|
||||
buildInputs = [ cmake qt4 ];
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
diff --git a/VTK/GUISupport/Qt/CMakeLists.txt b/VTK/GUISupport/Qt/CMakeLists.txt
|
||||
index 2c35be7..866f1aa 100644
|
||||
--- a/VTK/GUISupport/Qt/CMakeLists.txt
|
||||
+++ b/VTK/GUISupport/Qt/CMakeLists.txt
|
||||
@@ -166,6 +166,7 @@ IF(DESIRED_QT_VERSION MATCHES 4)
|
||||
)
|
||||
ENDIF(QT_QTGUI_LIBRARY)
|
||||
INCLUDE_DIRECTORIES(${QT_QTDESIGNER_INCLUDE_DIR})
|
||||
+ INCLUDE_DIRECTORIES(${QT_QTCORE_INCLUDE_DIR})
|
||||
QT4_WRAP_CPP ( PluginMocSrcs ${PluginMocHeaders} )
|
||||
ELSE(DESIRED_QT_VERSION MATCHES 4)
|
||||
QT_WRAP_CPP ( QVTKWidgetPlugin PluginMocSrcs ${PluginMocHeaders} )
|
||||
diff --git a/VTK/GUISupport/Qt/vtkEventQtSlotConnect.h b/VTK/GUISupport/Qt/vtkEventQtSlotConnect.h
|
||||
index 6782b90..ced3a67 100644
|
||||
--- a/VTK/GUISupport/Qt/vtkEventQtSlotConnect.h
|
||||
+++ b/VTK/GUISupport/Qt/vtkEventQtSlotConnect.h
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "vtkObject.h"
|
||||
#include "vtkCommand.h" // for event defines
|
||||
#include "QVTKWin32Header.h" // for export define
|
||||
-#include "qobject.h" // for version info
|
||||
+#include <qobject.h> // for version info
|
||||
|
||||
class QObject;
|
||||
class vtkQtConnections;
|
||||
diff --git a/VTK/GUISupport/Qt/vtkQtConnection.h b/VTK/GUISupport/Qt/vtkQtConnection.h
|
||||
index 923ec2e..b189ddc 100644
|
||||
--- a/VTK/GUISupport/Qt/vtkQtConnection.h
|
||||
+++ b/VTK/GUISupport/Qt/vtkQtConnection.h
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "vtkObject.h"
|
||||
#include "vtkCommand.h" // for event defines
|
||||
-#include "qobject.h"
|
||||
+#include <qobject.h>
|
||||
|
||||
class QObject;
|
||||
class vtkCallbackCommand;
|
|
@ -18,11 +18,9 @@ stdenv.mkDerivation {
|
|||
|
||||
cmakeFlags = "-DPTHREAD_INCLUDE_DIR=${stdenv.glibc}/include" +
|
||||
" -DGETTEXT_INCLUDE_DIR=${gettext}/include" +
|
||||
" -DSDL_INCLUDE_DIR=${SDL}/include/SDL" +
|
||||
" -DCMAKE_SKIP_BUILD_RPATH=ON" +
|
||||
" -DCMAKE_BUILD_TYPE=Release";
|
||||
" -DSDL_INCLUDE_DIR=${SDL}/include/SDL";
|
||||
|
||||
NIX_LDFLAGS="-lxml2 -lXv -lSDL -lQtGui -lQtCore -lpthread";
|
||||
NIX_LDFLAGS="-lpthread";
|
||||
|
||||
postInstall = ''
|
||||
cd $NIX_BUILD_TOP/$sourceRoot
|
||||
|
|
6
pkgs/build-support/gcc-wrapper2/README
Normal file
6
pkgs/build-support/gcc-wrapper2/README
Normal file
|
@ -0,0 +1,6 @@
|
|||
To be removed after we merge stdenv-updates in.
|
||||
stdenv-updates should have this gcc-wrapper2 as gcc-wrapper.
|
||||
|
||||
Changelog against gcc-wrapper:
|
||||
- Support for linking shared objects with direct mention of the /path/libxxx.so object,
|
||||
thus, adding its path to the rpath.
|
24
pkgs/build-support/gcc-wrapper2/add-flags
Normal file
24
pkgs/build-support/gcc-wrapper2/add-flags
Normal file
|
@ -0,0 +1,24 @@
|
|||
# `-B@out@/bin' forces gcc to use ld-wrapper.sh when calling ld.
|
||||
export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE"
|
||||
|
||||
if test -e @out@/nix-support/libc-cflags; then
|
||||
export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if test -e @out@/nix-support/gcc-cflags; then
|
||||
export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/gcc-cflags) $NIX_CFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if test -e @out@/nix-support/libc-ldflags; then
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)"
|
||||
fi
|
||||
|
||||
if test -e @out@/nix-support/gcc-ldflags; then
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/gcc-ldflags)"
|
||||
fi
|
||||
|
||||
if test -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_GCC_WRAPPER_FLAGS_SET=1
|
135
pkgs/build-support/gcc-wrapper2/builder.sh
Normal file
135
pkgs/build-support/gcc-wrapper2/builder.sh
Normal file
|
@ -0,0 +1,135 @@
|
|||
source $stdenv/setup
|
||||
|
||||
|
||||
ensureDir $out/bin
|
||||
ensureDir $out/nix-support
|
||||
|
||||
|
||||
if test -z "$nativeLibc"; then
|
||||
dynamicLinker="$libc/lib/$dynamicLinker"
|
||||
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
||||
|
||||
if test -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 <limits.h> header fails to
|
||||
# compile, because it uses "#include_next <limits.h>" 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
|
||||
fi
|
||||
|
||||
if test -n "$nativeTools"; then
|
||||
gccPath="$nativePrefix/bin"
|
||||
ldPath="$nativePrefix/bin"
|
||||
else
|
||||
if test -e "$gcc/lib64"; then
|
||||
gccLDFlags="$gccLDFlags -L$gcc/lib64"
|
||||
fi
|
||||
gccLDFlags="$gccLDFlags -L$gcc/lib"
|
||||
echo "$gccLDFlags" > $out/nix-support/gcc-ldflags
|
||||
|
||||
# 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 test -e "$gcc/lib64"; then
|
||||
gccCFlags="$gccCFlags -B$gcc/lib64"
|
||||
fi
|
||||
echo "$gccCFlags" > $out/nix-support/gcc-cflags
|
||||
|
||||
gccPath="$gcc/bin"
|
||||
ldPath="$binutils/bin"
|
||||
fi
|
||||
|
||||
|
||||
doSubstitute() {
|
||||
local src=$1
|
||||
local dst=$2
|
||||
# Can't use substitute() here, because replace may not have been
|
||||
# built yet (in the bootstrap).
|
||||
sed \
|
||||
-e "s^@out@^$out^g" \
|
||||
-e "s^@shell@^$shell^g" \
|
||||
-e "s^@gcc@^$gcc^g" \
|
||||
-e "s^@gccProg@^$gccProg^g" \
|
||||
-e "s^@binutils@^$binutils^g" \
|
||||
-e "s^@libc@^$libc^g" \
|
||||
-e "s^@ld@^$ldPath/ld^g" \
|
||||
< "$src" > "$dst"
|
||||
}
|
||||
|
||||
|
||||
# Make wrapper scripts around gcc, g++, and gfortran. Also make symlinks
|
||||
# cc, c++, and f77.
|
||||
mkGccWrapper() {
|
||||
local dst=$1
|
||||
local src=$2
|
||||
|
||||
if ! test -f "$src"; then
|
||||
echo "$src does not exist (skipping)"
|
||||
return
|
||||
fi
|
||||
|
||||
gccProg="$src"
|
||||
doSubstitute "$gccWrapper" "$dst"
|
||||
chmod +x "$dst"
|
||||
}
|
||||
|
||||
mkGccWrapper $out/bin/gcc $gccPath/gcc
|
||||
ln -s gcc $out/bin/cc
|
||||
|
||||
mkGccWrapper $out/bin/g++ $gccPath/g++
|
||||
ln -s g++ $out/bin/c++
|
||||
|
||||
if test -e $gccPath/gfortran; then
|
||||
mkGccWrapper $out/bin/gfortran $gccPath/gfortran
|
||||
ln -s gfortran $out/bin/g77
|
||||
ln -s gfortran $out/bin/f77
|
||||
fi
|
||||
|
||||
|
||||
# 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.
|
||||
ln -s $ldPath/as $out/bin/as
|
||||
|
||||
|
||||
# Make a wrapper around the linker.
|
||||
doSubstitute "$ldWrapper" "$out/bin/ld"
|
||||
chmod +x "$out/bin/ld"
|
||||
|
||||
|
||||
# Emit a setup hook. Also store the path to the original GCC and
|
||||
# Glibc.
|
||||
test -n "$gcc" && echo $gcc > $out/nix-support/orig-gcc
|
||||
test -n "$libc" && echo $libc > $out/nix-support/orig-libc
|
||||
|
||||
doSubstitute "$addFlags" "$out/nix-support/add-flags.sh"
|
||||
|
||||
doSubstitute "$setupHook" "$out/nix-support/setup-hook"
|
||||
|
||||
cp -p $utils $out/nix-support/utils.sh
|
||||
|
||||
|
||||
# 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).
|
||||
if test -z "$nativeTools"; then
|
||||
echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages
|
||||
fi
|
60
pkgs/build-support/gcc-wrapper2/default.nix
Normal file
60
pkgs/build-support/gcc-wrapper2/default.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
# The Nix `gcc' stdenv.mkDerivation 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. This
|
||||
# stdenv.mkDerivation provides a wrapper 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, shell ? ""
|
||||
}:
|
||||
|
||||
assert nativeTools -> nativePrefix != "";
|
||||
assert !nativeTools -> gcc != null && binutils != null;
|
||||
assert !nativeLibc -> libc != 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 "");
|
||||
|
||||
builder = ./builder.sh;
|
||||
setupHook = ./setup-hook.sh;
|
||||
gccWrapper = ./gcc-wrapper.sh;
|
||||
ldWrapper = ./ld-wrapper.sh;
|
||||
utils = ./utils.sh;
|
||||
addFlags = ./add-flags;
|
||||
|
||||
inherit nativeTools nativeLibc nativePrefix gcc;
|
||||
libc = if nativeLibc then null else libc;
|
||||
binutils = if nativeTools then null else binutils;
|
||||
|
||||
langC = if nativeTools then true else gcc.langC;
|
||||
langCC = if nativeTools then true else gcc.langCC;
|
||||
langFortran = if nativeTools then false else gcc ? langFortran;
|
||||
shell = if shell == "" then stdenv.shell else shell;
|
||||
|
||||
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)";
|
||||
};
|
||||
|
||||
# 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
|
||||
if stdenv.system == "powerpc-linux" then "ld.so.1" else
|
||||
abort "don't know the name of the dynamic linker for this platform")
|
||||
else "";
|
||||
}
|
148
pkgs/build-support/gcc-wrapper2/gcc-wrapper.sh
Normal file
148
pkgs/build-support/gcc-wrapper2/gcc-wrapper.sh
Normal file
|
@ -0,0 +1,148 @@
|
|||
#! @shell@ -e
|
||||
|
||||
if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
|
||||
source "$NIX_GCC_WRAPPER_START_HOOK"
|
||||
fi
|
||||
|
||||
if test -z "$NIX_GCC_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 test "$i" = "-c"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-S"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-E"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-E"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-M"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-MM"; then
|
||||
dontLink=1
|
||||
elif test "${i:0:1}" != "-"; then
|
||||
nonFlagArgs=1
|
||||
elif test "$i" = "-m32"; then
|
||||
if test -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 test "$nonFlagArgs" = "0"; then
|
||||
dontLink=1
|
||||
fi
|
||||
|
||||
|
||||
# Optionally filter out paths not refering to the store.
|
||||
params=("$@")
|
||||
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
|
||||
rest=()
|
||||
n=0
|
||||
while test $n -lt ${#params[*]}; do
|
||||
p=${params[n]}
|
||||
p2=${params[$((n+1))]}
|
||||
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
|
||||
skip $p
|
||||
elif test "$p" = "-L" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
|
||||
skip $p
|
||||
elif test "$p" = "-I" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "$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=()
|
||||
|
||||
if test "$dontLink" != "1"; then
|
||||
|
||||
# Add the flags that should only be passed to the compiler when
|
||||
# linking.
|
||||
extraAfter=(${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 test "${i:0:3}" = "-L/"; then
|
||||
extraAfter=(${extraAfter[@]} "$i")
|
||||
else
|
||||
extraAfter=(${extraAfter[@]} "-Wl,$i")
|
||||
fi
|
||||
done
|
||||
export NIX_LDFLAGS_SET=1
|
||||
|
||||
if test "$NIX_STRIP_DEBUG" = "1"; then
|
||||
# Add executable-stripping flags.
|
||||
extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP)
|
||||
fi
|
||||
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 test "$*" = "-v"; then
|
||||
extraAfter=()
|
||||
extraBefore=()
|
||||
fi
|
||||
|
||||
# Optionally print debug info.
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "original flags to @gccProg@:" >&2
|
||||
for i in "${params[@]}"; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
echo "extraBefore flags to @gccProg@:" >&2
|
||||
for i in ${extraBefore[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
echo "extraAfter flags to @gccProg@:" >&2
|
||||
for i in ${extraAfter[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then
|
||||
source "$NIX_GCC_WRAPPER_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
|
||||
# Call the real `gcc'. Filter out warnings from stderr about unused
|
||||
# `-B' flags, since they confuse some programs. Deep bash magic to
|
||||
# apply grep to stderr (by swapping stdin/stderr twice).
|
||||
if test -z "$NIX_GCC_NEEDS_GREP"; then
|
||||
@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
|
||||
else
|
||||
(@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
|
||||
| (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
|
||||
exit $?
|
||||
fi
|
155
pkgs/build-support/gcc-wrapper2/ld-wrapper.sh
Normal file
155
pkgs/build-support/gcc-wrapper2/ld-wrapper.sh
Normal file
|
@ -0,0 +1,155 @@
|
|||
#! @shell@ -e
|
||||
|
||||
if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
|
||||
source "$NIX_LD_WRAPPER_START_HOOK"
|
||||
fi
|
||||
|
||||
if test -z "$NIX_GCC_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 test "$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 test $n -lt ${#params[*]}; do
|
||||
p=${params[n]}
|
||||
p2=${params[$((n+1))]}
|
||||
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
|
||||
skip $p
|
||||
elif test "$p" = "-L" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "$p" = "-rpath" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "${p:0:1}" = "/" && badPath "$p"; then
|
||||
# We cannot skip this; barf.
|
||||
echo "impure path \`$p' used in link" >&2
|
||||
exit 1
|
||||
else
|
||||
rest=("${rest[@]}" "$p")
|
||||
fi
|
||||
n=$((n + 1))
|
||||
done
|
||||
params=("${rest[@]}")
|
||||
fi
|
||||
|
||||
|
||||
extra=()
|
||||
extraBefore=()
|
||||
|
||||
if test -z "$NIX_LDFLAGS_SET"; then
|
||||
extra=(${extra[@]} $NIX_LDFLAGS)
|
||||
extraBefore=(${extraBefore[@]} $NIX_LDFLAGS_BEFORE)
|
||||
fi
|
||||
|
||||
|
||||
# Add all used dynamic libraries to the rpath.
|
||||
if test "$NIX_DONT_SET_RPATH" != "1"; then
|
||||
|
||||
# First, find all -L... switches.
|
||||
allParams=("${params[@]}" ${extra[@]})
|
||||
libPath=""
|
||||
addToLibPath() {
|
||||
local path="$1"
|
||||
if test "${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 "
|
||||
}
|
||||
n=0
|
||||
while test $n -lt ${#allParams[*]}; do
|
||||
p=${allParams[n]}
|
||||
p2=${allParams[$((n+1))]}
|
||||
if test "${p:0:3}" = "-L/"; then
|
||||
addToLibPath ${p:2}
|
||||
elif test "$p" = "-L"; then
|
||||
addToLibPath ${p2}
|
||||
n=$((n + 1))
|
||||
elif $(echo "$p" | grep -q '\.so\($\|\.\)'); then
|
||||
path="$(dirname "$p")";
|
||||
addToLibPath "${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.
|
||||
rpath=""
|
||||
|
||||
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 test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
|
||||
case $rpath in
|
||||
*\ $1\ *) return 0 ;;
|
||||
esac
|
||||
rpath="$rpath $1 "
|
||||
}
|
||||
|
||||
for i in $libPath; do
|
||||
n=0
|
||||
while test $n -lt ${#allParams[*]}; do
|
||||
p=${allParams[n]}
|
||||
p2=${allParams[$((n+1))]}
|
||||
if test "${p:0:2}" = "-l" -a -f "$i/lib${p:2}.so"; then
|
||||
addToRPath $i
|
||||
break
|
||||
elif test "$p" = "-l" -a -f "$i/lib${p2}"; then
|
||||
# I haven't seen `-l foo', but you never know...
|
||||
addToRPath $i
|
||||
break
|
||||
elif $(echo "$p" | grep -q '\.so\($\|\.\)'); then
|
||||
path="$(dirname "$p")";
|
||||
if test "$path" == "$i"; then
|
||||
addToRPath $i
|
||||
break;
|
||||
fi
|
||||
fi
|
||||
n=$((n + 1))
|
||||
done
|
||||
|
||||
done
|
||||
|
||||
|
||||
# Finally, add `-rpath' switches.
|
||||
for i in $rpath; do
|
||||
extra=(${extra[@]} -rpath $i)
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Optionally print debug info.
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "original flags to @ld@:" >&2
|
||||
for i in "${params[@]}"; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
echo "extra flags to @ld@:" >&2
|
||||
for i in ${extra[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
|
||||
source "$NIX_LD_WRAPPER_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}
|
29
pkgs/build-support/gcc-wrapper2/setup-hook.sh
Normal file
29
pkgs/build-support/gcc-wrapper2/setup-hook.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
addCVars () {
|
||||
if test -d $1/include; then
|
||||
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$1/include"
|
||||
fi
|
||||
|
||||
if test -d $1/lib64; then
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64"
|
||||
fi
|
||||
|
||||
if test -d $1/lib; then
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib"
|
||||
fi
|
||||
}
|
||||
|
||||
envHooks=(${envHooks[@]} addCVars)
|
||||
|
||||
# Note: these come *after* $out in the PATH (see setup.sh).
|
||||
|
||||
if test -n "@gcc@"; then
|
||||
addToSearchPath PATH @gcc@/bin
|
||||
fi
|
||||
|
||||
if test -n "@binutils@"; then
|
||||
addToSearchPath PATH @binutils@/bin
|
||||
fi
|
||||
|
||||
if test -n "@libc@"; then
|
||||
addToSearchPath PATH @libc@/bin
|
||||
fi
|
23
pkgs/build-support/gcc-wrapper2/utils.sh
Normal file
23
pkgs/build-support/gcc-wrapper2/utils.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
skip () {
|
||||
if test "$NIX_DEBUG" = "1"; 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 test "${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:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
|
||||
"${p:0:4}" != "/tmp" -a \
|
||||
"${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
|
||||
}
|
|
@ -32,6 +32,9 @@ cmakeConfigurePhase()
|
|||
cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix $cmakeFlags"
|
||||
fi
|
||||
|
||||
# Avoid cmake resetting the rpath of binaries, on make install
|
||||
cmakeFlags="-DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"
|
||||
|
||||
echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}"
|
||||
|
||||
cmake ${cmakeDir:-.} $cmakeFlags ${cmakeFlagsArray[@]}
|
||||
|
|
|
@ -1783,6 +1783,8 @@ let
|
|||
|
||||
gcc43 = useFromStdenv "gcc" gcc43_real;
|
||||
|
||||
gcc43_wrapper2 = wrapGCC2 gcc43.gcc;
|
||||
|
||||
gcc43_real = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.3) {
|
||||
inherit fetchurl stdenv texinfo gmp mpfr noSysDirs;
|
||||
profiledCompiler = true;
|
||||
|
@ -2217,6 +2219,7 @@ let
|
|||
};
|
||||
|
||||
wrapGCC = wrapGCCWith (import ../build-support/gcc-wrapper) glibc;
|
||||
wrapGCC2 = wrapGCCWith (import ../build-support/gcc-wrapper2) glibc;
|
||||
|
||||
# FIXME: This is a specific hack for GCC-UPC. Eventually, we may
|
||||
# want to merge `gcc-upc-wrapper' and `gcc-wrapper'.
|
||||
|
@ -6234,12 +6237,14 @@ let
|
|||
};
|
||||
|
||||
autopanosiftc = import ../applications/graphics/autopanosiftc {
|
||||
inherit fetchurl stdenv cmake libpng libtiff libjpeg panotools libxml2;
|
||||
inherit fetchurl cmake libpng libtiff libjpeg panotools libxml2;
|
||||
stdenv = overrideGCC stdenv gcc43_wrapper2;
|
||||
};
|
||||
|
||||
avidemux = import ../applications/video/avidemux {
|
||||
inherit fetchurl stdenv cmake pkgconfig libxml2 qt4 gettext SDL libxslt x264
|
||||
inherit fetchurl cmake pkgconfig libxml2 qt4 gettext SDL libxslt x264
|
||||
alsaLib lame faac faad2 libvorbis;
|
||||
stdenv = overrideGCC stdenv gcc43_wrapper2;
|
||||
inherit (gtkLibs) gtk;
|
||||
inherit (xlibs) libXv pixman libpthreadstubs libXau libXdmcp;
|
||||
};
|
||||
|
@ -6768,7 +6773,8 @@ let
|
|||
};
|
||||
|
||||
freepv = import ../applications/graphics/freepv {
|
||||
inherit fetchurl stdenv mesa freeglut libjpeg zlib cmake libxml2 libpng;
|
||||
inherit fetchurl mesa freeglut libjpeg zlib cmake libxml2 libpng;
|
||||
stdenv = overrideGCC stdenv gcc43_wrapper2;
|
||||
inherit (xlibs) libX11 libXxf86vm;
|
||||
};
|
||||
|
||||
|
@ -6918,10 +6924,11 @@ let
|
|||
};
|
||||
|
||||
hugin = import ../applications/graphics/hugin {
|
||||
inherit stdenv fetchurl cmake panotools libtiff libpng boost pkgconfig
|
||||
inherit fetchurl cmake panotools libtiff libpng boost pkgconfig
|
||||
exiv2 gettext ilmbase enblendenfuse autopanosiftc;
|
||||
inherit wxGTK;
|
||||
openexr = openexr_1_6_1;
|
||||
stdenv = overrideGCC stdenv gcc43_wrapper2;
|
||||
};
|
||||
|
||||
i810switch = import ../applications/misc/i810 {
|
||||
|
@ -7285,7 +7292,8 @@ let
|
|||
};
|
||||
|
||||
paraview = import ../applications/graphics/paraview {
|
||||
inherit fetchurl stdenv cmake qt4;
|
||||
inherit fetchurl cmake qt4;
|
||||
stdenv = overrideGCC stdenv gcc43_wrapper2;
|
||||
};
|
||||
|
||||
partitionManager = import ../tools/misc/partition-manager {
|
||||
|
|
Loading…
Reference in a new issue