Merge remote-tracking branch 'upstream/master' into hardened-stdenv
This commit is contained in:
@@ -8,9 +8,10 @@ mkdir $NIX_FIXINC_DUMMY
|
||||
if test "$staticCompiler" = "1"; then
|
||||
EXTRA_LDFLAGS="-static"
|
||||
else
|
||||
EXTRA_LDFLAGS=""
|
||||
EXTRA_LDFLAGS="-Wl,-rpath,$lib/lib"
|
||||
fi
|
||||
|
||||
|
||||
# GCC interprets empty paths as ".", which we don't want.
|
||||
if test -z "$CPATH"; then unset CPATH; fi
|
||||
if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
|
||||
@@ -29,7 +30,7 @@ if test "$noSysDirs" = "1"; then
|
||||
# Use *real* header files, otherwise a limits.h is generated
|
||||
# that does not include Glibc's limits.h (notably missing
|
||||
# SSIZE_MAX, which breaks the build).
|
||||
export NIX_FIXINC_DUMMY=$(cat $NIX_CC/nix-support/orig-libc)/include
|
||||
export NIX_FIXINC_DUMMY=$libc_dev/include
|
||||
|
||||
# The path to the Glibc binaries such as `crti.o'.
|
||||
glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
|
||||
@@ -50,10 +51,10 @@ if test "$noSysDirs" = "1"; then
|
||||
# bootstrap compiler are optimized and (optionally) contain
|
||||
# debugging information (info "(gccinstall) Building").
|
||||
if test -n "$dontStrip"; then
|
||||
extraFlags="-O2 -g $extraFlags"
|
||||
extraFlags="-O2 -g $extraFlags"
|
||||
else
|
||||
# Don't pass `-g' at all; this saves space while building.
|
||||
extraFlags="-O2 $extraFlags"
|
||||
# Don't pass `-g' at all; this saves space while building.
|
||||
extraFlags="-O2 $extraFlags"
|
||||
fi
|
||||
|
||||
EXTRA_FLAGS="$extraFlags"
|
||||
@@ -170,9 +171,8 @@ preConfigure() {
|
||||
# Patch the configure script so it finds glibc headers. It's
|
||||
# important for example in order not to get libssp built,
|
||||
# because its functionality is in glibc already.
|
||||
glibc_headers="$(cat $NIX_CC/nix-support/orig-libc)/include"
|
||||
sed -i \
|
||||
-e "s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers", \
|
||||
-e "s,glibc_header_dir=/usr/include,glibc_header_dir=$libc_dev/include", \
|
||||
gcc/configure
|
||||
fi
|
||||
|
||||
@@ -206,6 +206,14 @@ preInstall() {
|
||||
|
||||
|
||||
postInstall() {
|
||||
# Move runtime libraries to $lib.
|
||||
mkdir -p $lib/lib
|
||||
ln -s lib $lib/lib64
|
||||
mv -v $out/lib/lib*.so $out/lib/lib*.so.*[0-9] $out/lib/*.la $lib/lib/
|
||||
for i in $lib/lib/*.la; do
|
||||
substituteInPlace $i --replace $out $lib
|
||||
done
|
||||
|
||||
# Remove precompiled headers for now. They are very big and
|
||||
# probably not very useful yet.
|
||||
find $out/include -name "*.gch" -exec rm -rf {} \; -prune
|
||||
@@ -217,6 +225,7 @@ postInstall() {
|
||||
|
||||
# More dependencies with the previous gcc or some libs (gccbug stores the build command line)
|
||||
rm -rf $out/bin/gccbug
|
||||
|
||||
# Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
|
||||
for i in $out/libexec/gcc/*/*/*; do
|
||||
if PREV_RPATH=`patchelf --print-rpath $i`; then
|
||||
@@ -225,7 +234,7 @@ postInstall() {
|
||||
done
|
||||
|
||||
# Get rid of some "fixed" header files
|
||||
rm -rf $out/lib/gcc/*/*/include/root
|
||||
rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux}
|
||||
|
||||
# Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
|
||||
for i in $out/bin/*-gcc*; do
|
||||
|
||||
@@ -170,7 +170,7 @@ let version = "4.6.4";
|
||||
"-stage-final";
|
||||
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
|
||||
|
||||
bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
|
||||
bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
|
||||
|
||||
in
|
||||
|
||||
@@ -182,15 +182,21 @@ stdenv.mkDerivation ({
|
||||
|
||||
builder = ./builder.sh;
|
||||
|
||||
src = (import ./sources.nix) {
|
||||
srcs = (import ./sources.nix) {
|
||||
inherit fetchurl optional version;
|
||||
inherit langC langCC langFortran langJava langAda langGo;
|
||||
};
|
||||
|
||||
outputs = [ "out" "lib" ];
|
||||
|
||||
setOutputFlags = false;
|
||||
|
||||
inherit patches enableMultilib;
|
||||
|
||||
hardeningDisable = [ "format" ];
|
||||
|
||||
libc_dev = stdenv.cc.libc_dev;
|
||||
|
||||
postPatch =
|
||||
if (stdenv.isGNU
|
||||
|| (libcCross != null # e.g., building `gcc.crossDrv'
|
||||
|
||||
@@ -197,7 +197,7 @@ let version = "4.8.5";
|
||||
stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
|
||||
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
|
||||
|
||||
bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
|
||||
bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
|
||||
|
||||
in
|
||||
|
||||
@@ -209,8 +209,6 @@ stdenv.mkDerivation ({
|
||||
|
||||
builder = ../builder.sh;
|
||||
|
||||
outputs = [ "out" "info" ];
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
|
||||
sha256 = "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2";
|
||||
@@ -220,6 +218,12 @@ stdenv.mkDerivation ({
|
||||
|
||||
hardeningDisable = [ "format" ];
|
||||
|
||||
outputs = [ "out" "lib" "doc" ];
|
||||
setOutputFlags = false;
|
||||
NIX_NO_SELF_RPATH = true;
|
||||
|
||||
libc_dev = stdenv.cc.libc_dev;
|
||||
|
||||
postPatch =
|
||||
if (stdenv.isGNU
|
||||
|| (libcCross != null # e.g., building `gcc.crossDrv'
|
||||
@@ -360,7 +364,7 @@ stdenv.mkDerivation ({
|
||||
)
|
||||
}
|
||||
${if (stdenv ? glibc && cross == null)
|
||||
then " --with-native-system-header-dir=${stdenv.glibc}/include"
|
||||
then " --with-native-system-header-dir=${stdenv.glibc.dev}/include"
|
||||
else ""}
|
||||
${if langAda then " --enable-libada" else ""}
|
||||
${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
|
||||
|
||||
@@ -73,7 +73,7 @@ let version = "4.9.3";
|
||||
++ optional langAda ../gnat-cflags.patch
|
||||
++ optional langFortran ../gfortran-driving.patch
|
||||
# The NXConstStr.patch can be removed at 4.9.4
|
||||
++ optional stdenv.isDarwin ../gfortran-darwin-NXConstStr.patch;
|
||||
++ optional stdenv.isDarwin ../gfortran-darwin-NXConstStr.patch;
|
||||
|
||||
javaEcj = fetchurl {
|
||||
# The `$(top_srcdir)/ecj.jar' file is automatically picked up at
|
||||
@@ -199,7 +199,7 @@ let version = "4.9.3";
|
||||
stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
|
||||
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
|
||||
|
||||
bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
|
||||
bootstrap = cross == null;
|
||||
|
||||
in
|
||||
|
||||
@@ -211,8 +211,6 @@ stdenv.mkDerivation ({
|
||||
|
||||
builder = ../builder.sh;
|
||||
|
||||
outputs = [ "out" "info" ];
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
|
||||
sha256 = "0zmnm00d2a1hsd41g34bhvxzvxisa2l584q3p447bd91lfjv4ci3";
|
||||
@@ -222,6 +220,13 @@ stdenv.mkDerivation ({
|
||||
|
||||
hardeningDisable = [ "format" ];
|
||||
|
||||
outputs = if langJava || langGo then ["out" "man" "info"]
|
||||
else [ "out" "lib" "man" "info" ];
|
||||
setOutputFlags = false;
|
||||
NIX_NO_SELF_RPATH = true;
|
||||
|
||||
libc_dev = stdenv.cc.libc_dev;
|
||||
|
||||
postPatch =
|
||||
if (stdenv.isGNU
|
||||
|| (libcCross != null # e.g., building `gcc.crossDrv'
|
||||
@@ -313,7 +318,11 @@ stdenv.mkDerivation ({
|
||||
FLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \
|
||||
)
|
||||
fi
|
||||
'';
|
||||
''
|
||||
+ stdenv.lib.optionalString (langJava || langGo) ''
|
||||
export lib=$out;
|
||||
''
|
||||
;
|
||||
|
||||
dontDisableStatic = true;
|
||||
|
||||
@@ -362,7 +371,7 @@ stdenv.mkDerivation ({
|
||||
)
|
||||
}
|
||||
${if (stdenv ? glibc && cross == null)
|
||||
then " --with-native-system-header-dir=${stdenv.glibc}/include"
|
||||
then " --with-native-system-header-dir=${stdenv.glibc.dev}/include"
|
||||
else ""}
|
||||
${if langAda then " --enable-libada" else ""}
|
||||
${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
|
||||
@@ -536,4 +545,10 @@ stdenv.mkDerivation ({
|
||||
// optionalAttrs (!stripped || cross != null) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
|
||||
|
||||
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
|
||||
|
||||
// optionalAttrs (langJava) {
|
||||
postFixup = ''
|
||||
target="$(echo "$out/libexec/gcc"/*/*/ecj*)"
|
||||
patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target"
|
||||
'';}
|
||||
)
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
, stripped ? true
|
||||
, gnused ? null
|
||||
, binutils ? null
|
||||
, cloog # unused; just for compat with gcc4, as we override the parameter on some places
|
||||
}:
|
||||
|
||||
assert langJava -> zip != null && unzip != null
|
||||
@@ -197,7 +198,7 @@ let version = "5.3.0";
|
||||
stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
|
||||
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
|
||||
|
||||
bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
|
||||
bootstrap = cross == null;
|
||||
|
||||
in
|
||||
|
||||
@@ -209,8 +210,6 @@ stdenv.mkDerivation ({
|
||||
|
||||
builder = ../builder.sh;
|
||||
|
||||
outputs = [ "out" "info" ];
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
|
||||
sha256 = "1ny4smkp5bzs3cp8ss7pl6lk8yss0d9m4av1mvdp72r1x695akxq";
|
||||
@@ -221,6 +220,12 @@ stdenv.mkDerivation ({
|
||||
|
||||
inherit patches;
|
||||
|
||||
outputs = [ "out" "lib" "man" "info" ];
|
||||
setOutputFlags = false;
|
||||
NIX_NO_SELF_RPATH = true;
|
||||
|
||||
libc_dev = stdenv.cc.libc_dev;
|
||||
|
||||
postPatch =
|
||||
if (stdenv.isGNU
|
||||
|| (libcCross != null # e.g., building `gcc.crossDrv'
|
||||
@@ -361,7 +366,7 @@ stdenv.mkDerivation ({
|
||||
)
|
||||
}
|
||||
${if (stdenv ? glibc && cross == null)
|
||||
then " --with-native-system-header-dir=${stdenv.glibc}/include"
|
||||
then " --with-native-system-header-dir=${stdenv.glibc.dev}/include"
|
||||
else ""}
|
||||
${if langAda then " --enable-libada" else ""}
|
||||
${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
|
||||
|
||||
@@ -8,9 +8,10 @@ mkdir $NIX_FIXINC_DUMMY
|
||||
if test "$staticCompiler" = "1"; then
|
||||
EXTRA_LDFLAGS="-static"
|
||||
else
|
||||
EXTRA_LDFLAGS=""
|
||||
EXTRA_LDFLAGS="-Wl,-rpath,$lib/lib"
|
||||
fi
|
||||
|
||||
|
||||
# GCC interprets empty paths as ".", which we don't want.
|
||||
if test -z "$CPATH"; then unset CPATH; fi
|
||||
if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
|
||||
@@ -29,7 +30,7 @@ if test "$noSysDirs" = "1"; then
|
||||
# Use *real* header files, otherwise a limits.h is generated
|
||||
# that does not include Glibc's limits.h (notably missing
|
||||
# SSIZE_MAX, which breaks the build).
|
||||
export NIX_FIXINC_DUMMY=$(cat $NIX_CC/nix-support/orig-libc)/include
|
||||
export NIX_FIXINC_DUMMY=$libc_dev/include
|
||||
|
||||
# The path to the Glibc binaries such as `crti.o'.
|
||||
glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
|
||||
@@ -171,9 +172,8 @@ preConfigure() {
|
||||
# Patch the configure script so it finds glibc headers. It's
|
||||
# important for example in order not to get libssp built,
|
||||
# because its functionality is in glibc already.
|
||||
glibc_headers="$(cat $NIX_CC/nix-support/orig-libc)/include"
|
||||
sed -i \
|
||||
-e "s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers", \
|
||||
-e "s,glibc_header_dir=/usr/include,glibc_header_dir=$libc_dev/include", \
|
||||
gcc/configure
|
||||
fi
|
||||
|
||||
@@ -210,9 +210,15 @@ preInstall() {
|
||||
|
||||
|
||||
postInstall() {
|
||||
# Remove precompiled headers for now. They are very big and
|
||||
# probably not very useful yet.
|
||||
find $out/include -name "*.gch" -exec rm -rf {} \; -prune
|
||||
# Move runtime libraries to $lib.
|
||||
moveToOutput "lib/lib*.so*" "$lib"
|
||||
moveToOutput "lib/lib*.la" "$lib"
|
||||
ln -s lib "$lib/lib64" # for *.la
|
||||
moveToOutput "share/gcc-*/python" "$lib"
|
||||
|
||||
for i in "$lib"/lib/*.{la,py}; do
|
||||
substituteInPlace "$i" --replace "$out" "$lib"
|
||||
done
|
||||
|
||||
# Remove `fixincl' to prevent a retained dependency on the
|
||||
# previous gcc.
|
||||
@@ -221,15 +227,23 @@ postInstall() {
|
||||
|
||||
# More dependencies with the previous gcc or some libs (gccbug stores the build command line)
|
||||
rm -rf $out/bin/gccbug
|
||||
|
||||
# Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
|
||||
for i in $out/libexec/gcc/*/*/*; do
|
||||
if PREV_RPATH=`patchelf --print-rpath $i`; then
|
||||
patchelf --set-rpath `echo $PREV_RPATH | sed 's,:[^:]*bootstrap-tools/lib,,'` $i
|
||||
fi
|
||||
for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do
|
||||
PREV_RPATH=`patchelf --print-rpath "$i"`
|
||||
NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'`
|
||||
patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK
|
||||
done
|
||||
|
||||
# For some reason the libs retain RPATH to $out
|
||||
for i in "$lib"/lib/{libtsan,libasan,libubsan}.so.*.*.*; do
|
||||
PREV_RPATH=`patchelf --print-rpath "$i"`
|
||||
NEW_RPATH=`echo "$PREV_RPATH" | sed "s,:${out}[^:]*,,g"`
|
||||
patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK
|
||||
done
|
||||
|
||||
# Get rid of some "fixed" header files
|
||||
rm -rf $out/lib/gcc/*/*/include/root
|
||||
rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux}
|
||||
|
||||
# Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
|
||||
for i in $out/bin/*-gcc*; do
|
||||
@@ -250,6 +264,9 @@ postInstall() {
|
||||
paxmark r $out/libexec/gcc/*/*/{cc1,cc1plus}
|
||||
|
||||
eval "$postInstallGhdl"
|
||||
|
||||
# Two identical man pages are shipped (moving and compressing is done later)
|
||||
ln -sf gcc.1 "$out"/share/man/man1/g++.1
|
||||
}
|
||||
|
||||
genericBuild
|
||||
|
||||
Reference in New Issue
Block a user