Skip to content

Commit

Permalink
Merge #15867: glibc, gcc: fixes for ARM targets
Browse files Browse the repository at this point in the history
... needed after closure-size merge (#7701)
  • Loading branch information
vcunat committed Jun 10, 2016
2 parents 772c92b + fa4fcaf commit 46f22d8
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 133 deletions.
3 changes: 2 additions & 1 deletion pkgs/build-support/gcc-cross-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ stdenv.mkDerivation {
ldWrapper = ./ld-wrapper.sh;
utils = ./utils.sh;
addFlags = ./add-flags;
inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
inherit nativeTools nativeLibc nativePrefix gcc binutils;
libc = if libc ? out then libc.out else libc;
crossConfig = if cross != null then cross.config else null;
osxMinVersion = cross.osxMinVersion or null;
gccLibs = if gcc != null then gccLibs else null;
Expand Down
37 changes: 25 additions & 12 deletions pkgs/development/compilers/gcc/4.5/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ stdenv.mkDerivation ({
sed -i "${gnu_h}" \
-es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..."
sed -i "${gnu_h}" \
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
sed -i gcc/config/t-gnu \
-es'|NATIVE_SYSTEM_HEADER_DIR.*$|NATIVE_SYSTEM_HEADER_DIR = ${libc}/include|g'
-es'|NATIVE_SYSTEM_HEADER_DIR.*$|NATIVE_SYSTEM_HEADER_DIR = ${libc.dev}/include|g'
''
else if cross != null || stdenv.cc.libc != null then
# On NixOS, use the right path to the dynamic linker instead of
Expand All @@ -197,18 +197,18 @@ stdenv.mkDerivation ({
grep -q LIBC_DYNAMIC_LINKER "$header" || continue
echo " fixing \`$header'..."
sed -i "$header" \
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g'
done
''
else null;

inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic
libcCross crossMingw;

nativeBuildInputs = [ texinfo which ]
nativeBuildInputs = [ texinfo which gettext ]
++ optional (perl != null) perl;

buildInputs = [ gmp mpfr libmpc libelf gettext ]
buildInputs = [ gmp mpfr libmpc libelf ]
++ (optional (ppl != null) ppl)
++ (optional (cloogppl != null) cloogppl)
++ (optional (zlib != null) zlib)
Expand Down Expand Up @@ -346,15 +346,28 @@ stdenv.mkDerivation ({
++ optional (libpthread != null) libpthread)));

EXTRA_TARGET_CFLAGS =
if cross != null && libcCross != null
then "-idirafter ${libcCross}/include"
if cross != null && libcCross != null then [
"-idirafter ${libcCross.dev}/include"
]
++ optionals (! crossStageStatic) [
"-B${libcCross.out}/lib"
]
else null;

EXTRA_TARGET_LDFLAGS =
if cross != null && libcCross != null
then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
(optionalString (libpthreadCross != null)
" -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
if cross != null && libcCross != null then [
"-Wl,-L${libcCross.out}/lib"
]
++ (if crossStageStatic then [
"-B${libcCross.out}/lib"
] else [
"-Wl,-rpath,${libcCross.out}/lib"
"-Wl,-rpath-link,${libcCross.out}/lib"
])
++ optionals (libpthreadCross != null) [
"-L${libpthreadCross}/lib"
"-Wl,${libpthreadCross.TARGET_LDFLAGS}"
]
else null;

passthru = { inherit langC langCC langAda langFortran langVhdl
Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/compilers/gcc/4.6/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ 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/
moveToOutput "lib/lib*.so" "$lib"
moveToOutput "lib/lib*.so.*[0-9]" "$lib"
moveToOutput "lib/*.la" "$lib"
for i in $lib/lib/*.la; do
substituteInPlace $i --replace $out $lib
done
Expand Down
33 changes: 23 additions & 10 deletions pkgs/development/compilers/gcc/4.6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ stdenv.mkDerivation ({
sed -i "${gnu_h}" \
-es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..."
sed -i "${gnu_h}" \
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
sed -i gcc/config/t-gnu \
-es'|NATIVE_SYSTEM_HEADER_DIR.*$|NATIVE_SYSTEM_HEADER_DIR = ${libc}/include|g'
-es'|NATIVE_SYSTEM_HEADER_DIR.*$|NATIVE_SYSTEM_HEADER_DIR = ${libc.dev}/include|g'
''
else if cross != null || stdenv.cc.libc != null then
# On NixOS, use the right path to the dynamic linker instead of
Expand All @@ -247,7 +247,7 @@ stdenv.mkDerivation ({
grep -q LIBC_DYNAMIC_LINKER "$header" || continue
echo " fixing \`$header'..."
sed -i "$header" \
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g'
done
''
else null;
Expand Down Expand Up @@ -421,15 +421,28 @@ stdenv.mkDerivation ({
++ optional (libpthread != null) libpthread)));

EXTRA_TARGET_CFLAGS =
if cross != null && libcCross != null
then "-idirafter ${libcCross}/include"
if cross != null && libcCross != null then [
"-idirafter ${libcCross.dev}/include"
]
++ optionals (! crossStageStatic) [
"-B${libcCross.out}/lib"
]
else null;

EXTRA_TARGET_LDFLAGS =
if cross != null && libcCross != null
then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
(optionalString (libpthreadCross != null)
" -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
if cross != null && libcCross != null then [
"-Wl,-L${libcCross.out}/lib"
]
++ (if crossStageStatic then [
"-B${libcCross.out}/lib"
] else [
"-Wl,-rpath,${libcCross.out}/lib"
"-Wl,-rpath-link,${libcCross.out}/lib"
])
++ optionals (libpthreadCross != null) [
"-L${libpthreadCross}/lib"
"-Wl,${libpthreadCross.TARGET_LDFLAGS}"
]
else null;

passthru = { inherit langC langCC langAda langFortran langVhdl
Expand Down
35 changes: 24 additions & 11 deletions pkgs/development/compilers/gcc/4.8/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ let version = "4.8.5";
" --disable-libatomic " + # libatomic requires libc
" --disable-decimal-float" # libdecnumber requires libc
else
(if crossDarwin then " --with-sysroot=${libcCross}/share/sysroot"
else " --with-headers=${libcCross}/include") +
(if crossDarwin then " --with-sysroot=${libcCross.out}/share/sysroot"
else " --with-headers=${libcCross.dev}/include") +
# Ensure that -print-prog-name is able to find the correct programs.
(stdenv.lib.optionalString (crossMingw || crossDarwin) (
" --with-as=${binutilsCross}/bin/${cross.config}-as" +
Expand Down Expand Up @@ -255,9 +255,9 @@ stdenv.mkDerivation ({
sed -i "${gnu_h}" \
-es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..."
sed -i "${gnu_h}" \
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
''
else if cross != null || stdenv.cc.libc != null then
# On NixOS, use the right path to the dynamic linker instead of
Expand All @@ -271,7 +271,7 @@ stdenv.mkDerivation ({
grep -q LIBC_DYNAMIC_LINKER "$header" || continue
echo " fixing \`$header'..."
sed -i "$header" \
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g'
done
''
else null;
Expand Down Expand Up @@ -482,15 +482,28 @@ stdenv.mkDerivation ({
++ optional (libpthread != null) libpthread)));

EXTRA_TARGET_CFLAGS =
if cross != null && libcCross != null
then "-idirafter ${libcCross}/include"
if cross != null && libcCross != null then [
"-idirafter ${libcCross.dev}/include"
]
++ optionals (! crossStageStatic) [
"-B${libcCross.out}/lib"
]
else null;

EXTRA_TARGET_LDFLAGS =
if cross != null && libcCross != null
then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
(optionalString (libpthreadCross != null)
" -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
if cross != null && libcCross != null then [
"-Wl,-L${libcCross.out}/lib"
]
++ (if crossStageStatic then [
"-B${libcCross.out}/lib"
] else [
"-Wl,-rpath,${libcCross.out}/lib"
"-Wl,-rpath-link,${libcCross.out}/lib"
])
++ optionals (libpthreadCross != null) [
"-L${libpthreadCross}/lib"
"-Wl,${libpthreadCross.TARGET_LDFLAGS}"
]
else null;

passthru =
Expand Down
35 changes: 24 additions & 11 deletions pkgs/development/compilers/gcc/4.9/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ let version = "4.9.3";
" --disable-libatomic " + # libatomic requires libc
" --disable-decimal-float" # libdecnumber requires libc
else
(if crossDarwin then " --with-sysroot=${libcCross}/share/sysroot"
else " --with-headers=${libcCross}/include") +
(if crossDarwin then " --with-sysroot=${libcCross.out}/share/sysroot"
else " --with-headers=${libcCross.dev}/include") +
# Ensure that -print-prog-name is able to find the correct programs.
(stdenv.lib.optionalString (crossMingw || crossDarwin) (
" --with-as=${binutilsCross}/bin/${cross.config}-as" +
Expand Down Expand Up @@ -258,9 +258,9 @@ stdenv.mkDerivation ({
sed -i "${gnu_h}" \
-es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..."
sed -i "${gnu_h}" \
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
''
else if cross != null || stdenv.cc.libc != null then
# On NixOS, use the right path to the dynamic linker instead of
Expand All @@ -274,7 +274,7 @@ stdenv.mkDerivation ({
grep -q LIBC_DYNAMIC_LINKER "$header" || continue
echo " fixing \`$header'..."
sed -i "$header" \
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g'
done
''
else null;
Expand Down Expand Up @@ -489,15 +489,28 @@ stdenv.mkDerivation ({
++ optional (libpthread != null) libpthread)));

EXTRA_TARGET_CFLAGS =
if cross != null && libcCross != null
then "-idirafter ${libcCross}/include"
if cross != null && libcCross != null then [
"-idirafter ${libcCross.dev}/include"
]
++ optionals (! crossStageStatic) [
"-B${libcCross.out}/lib"
]
else null;

EXTRA_TARGET_LDFLAGS =
if cross != null && libcCross != null
then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
(optionalString (libpthreadCross != null)
" -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
if cross != null && libcCross != null then [
"-Wl,-L${libcCross.out}/lib"
]
++ (if crossStageStatic then [
"-B${libcCross.out}/lib"
] else [
"-Wl,-rpath,${libcCross.out}/lib"
"-Wl,-rpath-link,${libcCross.out}/lib"
])
++ optionals (libpthreadCross != null) [
"-L${libpthreadCross}/lib"
"-Wl,${libpthreadCross.TARGET_LDFLAGS}"
]
else null;

passthru =
Expand Down
35 changes: 24 additions & 11 deletions pkgs/development/compilers/gcc/5/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ let version = "5.4.0";
" --disable-libatomic " + # libatomic requires libc
" --disable-decimal-float" # libdecnumber requires libc
else
(if crossDarwin then " --with-sysroot=${libcCross}/share/sysroot"
else " --with-headers=${libcCross}/include") +
(if crossDarwin then " --with-sysroot=${libcCross.out}/share/sysroot"
else " --with-headers=${libcCross.dev}/include") +
# Ensure that -print-prog-name is able to find the correct programs.
(stdenv.lib.optionalString (crossMingw || crossDarwin) (
" --with-as=${binutilsCross}/bin/${cross.config}-as" +
Expand Down Expand Up @@ -257,9 +257,9 @@ stdenv.mkDerivation ({
sed -i "${gnu_h}" \
-es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..."
sed -i "${gnu_h}" \
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
''
else if cross != null || stdenv.cc.libc != null then
# On NixOS, use the right path to the dynamic linker instead of
Expand All @@ -273,7 +273,7 @@ stdenv.mkDerivation ({
grep -q LIBC_DYNAMIC_LINKER "$header" || continue
echo " fixing \`$header'..."
sed -i "$header" \
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g'
done
''
else null;
Expand Down Expand Up @@ -483,15 +483,28 @@ stdenv.mkDerivation ({
++ optional (libpthread != null) libpthread)));

EXTRA_TARGET_CFLAGS =
if cross != null && libcCross != null
then "-idirafter ${libcCross}/include"
if cross != null && libcCross != null then [
"-idirafter ${libcCross.dev}/include"
]
++ optionals (! crossStageStatic) [
"-B${libcCross.out}/lib"
]
else null;

EXTRA_TARGET_LDFLAGS =
if cross != null && libcCross != null
then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
(optionalString (libpthreadCross != null)
" -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
if cross != null && libcCross != null then [
"-Wl,-L${libcCross.out}/lib"
]
++ (if crossStageStatic then [
"-B${libcCross.out}/lib"
] else [
"-Wl,-rpath,${libcCross.out}/lib"
"-Wl,-rpath-link,${libcCross.out}/lib"
])
++ optionals (libpthreadCross != null) [
"-L${libpthreadCross}/lib"
"-Wl,${libpthreadCross.TARGET_LDFLAGS}"
]
else null;

passthru =
Expand Down
Loading

0 comments on commit 46f22d8

Please sign in to comment.