about summary refs log tree commit diff
path: root/nixpkgs
diff options
context:
space:
mode:
authorGaelan Steele <gbs@canishe.com>2020-05-26 03:16:03 -0700
committerAlyssa Ross <hi@alyssa.is>2020-11-27 13:27:00 +0000
commit0e5b3d4420d5e9c37533b11639d421b609f92e46 (patch)
tree4260d4283dd2c5261120a09c4f740d23d3a4e763 /nixpkgs
parente14330c5be9b005d4310cd4dc0d384cff882aedc (diff)
downloadnixlib-0e5b3d4420d5e9c37533b11639d421b609f92e46.tar
nixlib-0e5b3d4420d5e9c37533b11639d421b609f92e46.tar.gz
nixlib-0e5b3d4420d5e9c37533b11639d421b609f92e46.tar.bz2
nixlib-0e5b3d4420d5e9c37533b11639d421b609f92e46.tar.lz
nixlib-0e5b3d4420d5e9c37533b11639d421b609f92e46.tar.xz
nixlib-0e5b3d4420d5e9c37533b11639d421b609f92e46.tar.zst
nixlib-0e5b3d4420d5e9c37533b11639d421b609f92e46.zip
gcc: fix building darwin->linux cross compiler
This reverts d9feea5 with some slight modifications to work with
other changes since then.

Fixes #88213.

(cherry picked from commit 459c60dda2406d2207d2afd90f210ffc87efde54)
Diffstat (limited to 'nixpkgs')
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix15
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix15
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/6/default.nix15
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/7/default.nix15
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/8/default.nix15
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/9/default.nix15
-rw-r--r--nixpkgs/pkgs/development/compilers/gcc/builder.sh12
7 files changed, 65 insertions, 37 deletions
diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix b/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix
index 6a2c506b1bf3..213d0c91ff34 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix
@@ -11,7 +11,7 @@
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man); required for Java
-, gmp, mpfr, libmpc, gettext, which
+, gmp, mpfr, libmpc, gettext, which, patchelf
 , libelf                      # optional, for link-time optimizations (LTO)
 , cloog ? null, isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null, boehmgc ? null
@@ -160,11 +160,14 @@ stdenv.mkDerivation ({
 
   # For building runtime libs
   depsBuildTarget =
-    if hostPlatform == buildPlatform then [
-      targetPackages.stdenv.cc.bintools # newly-built gcc will be used
-    ] else assert targetPlatform == hostPlatform; [ # build != host == target
-      stdenv.cc
-    ];
+    (
+      if hostPlatform == buildPlatform then [
+        targetPackages.stdenv.cc.bintools # newly-built gcc will be used
+      ] else assert targetPlatform == hostPlatform; [ # build != host == target
+        stdenv.cc
+      ]
+    )
+    ++ optional targetPlatform.isLinux patchelf;
 
   buildInputs = [
     gmp mpfr libmpc libelf
diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix b/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix
index 0a35ed023c6f..1c6907b271aa 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix
@@ -11,7 +11,7 @@
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man); required for Java
-, gmp, mpfr, libmpc, gettext, which
+, gmp, mpfr, libmpc, gettext, which, patchelf
 , libelf                      # optional, for link-time optimizations (LTO)
 , cloog ? null, isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null, boehmgc ? null
@@ -172,11 +172,14 @@ stdenv.mkDerivation ({
 
   # For building runtime libs
   depsBuildTarget =
-    if hostPlatform == buildPlatform then [
-      targetPackages.stdenv.cc.bintools # newly-built gcc will be used
-    ] else assert targetPlatform == hostPlatform; [ # build != host == target
-      stdenv.cc
-    ];
+    (
+      if hostPlatform == buildPlatform then [
+        targetPackages.stdenv.cc.bintools # newly-built gcc will be used
+      ] else assert targetPlatform == hostPlatform; [ # build != host == target
+        stdenv.cc
+      ]
+    )
+    ++ optional targetPlatform.isLinux patchelf;
 
   buildInputs = [
     gmp mpfr libmpc libelf
diff --git a/nixpkgs/pkgs/development/compilers/gcc/6/default.nix b/nixpkgs/pkgs/development/compilers/gcc/6/default.nix
index f3b15eac55d2..822df18ed82c 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/6/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/6/default.nix
@@ -13,7 +13,7 @@
 , texinfo ? null
 , flex
 , perl ? null # optional, for texi2pod (then pod2man); required for Java
-, gmp, mpfr, libmpc, gettext, which
+, gmp, mpfr, libmpc, gettext, which, patchelf
 , libelf                      # optional, for link-time optimizations (LTO)
 , isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null, boehmgc ? null
@@ -186,11 +186,14 @@ stdenv.mkDerivation ({
 
   # For building runtime libs
   depsBuildTarget =
-    if hostPlatform == buildPlatform then [
-      targetPackages.stdenv.cc.bintools # newly-built gcc will be used
-    ] else assert targetPlatform == hostPlatform; [ # build != host == target
-      stdenv.cc
-    ];
+    (
+      if hostPlatform == buildPlatform then [
+        targetPackages.stdenv.cc.bintools # newly-built gcc will be used
+      ] else assert targetPlatform == hostPlatform; [ # build != host == target
+        stdenv.cc
+      ]
+    )
+    ++ optional targetPlatform.isLinux patchelf;
 
   buildInputs = [
     gmp mpfr libmpc libelf
diff --git a/nixpkgs/pkgs/development/compilers/gcc/7/default.nix b/nixpkgs/pkgs/development/compilers/gcc/7/default.nix
index 89933c22edd4..698cb501e01f 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/7/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/7/default.nix
@@ -10,7 +10,7 @@
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man)
-, gmp, mpfr, libmpc, gettext, which
+, gmp, mpfr, libmpc, gettext, which, patchelf
 , libelf                      # optional, for link-time optimizations (LTO)
 , isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null
@@ -156,11 +156,14 @@ stdenv.mkDerivation ({
 
   # For building runtime libs
   depsBuildTarget =
-    if hostPlatform == buildPlatform then [
-      targetPackages.stdenv.cc.bintools # newly-built gcc will be used
-    ] else assert targetPlatform == hostPlatform; [ # build != host == target
-      stdenv.cc
-    ];
+    (
+      if hostPlatform == buildPlatform then [
+        targetPackages.stdenv.cc.bintools # newly-built gcc will be used
+      ] else assert targetPlatform == hostPlatform; [ # build != host == target
+        stdenv.cc
+      ]
+    )
+    ++ optional targetPlatform.isLinux patchelf;
 
   buildInputs = [
     gmp mpfr libmpc libelf
diff --git a/nixpkgs/pkgs/development/compilers/gcc/8/default.nix b/nixpkgs/pkgs/development/compilers/gcc/8/default.nix
index 5a6e20c0f412..9e6a24d12948 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/8/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/8/default.nix
@@ -10,7 +10,7 @@
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man)
-, gmp, mpfr, libmpc, gettext, which
+, gmp, mpfr, libmpc, gettext, which, patchelf
 , libelf                      # optional, for link-time optimizations (LTO)
 , isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null
@@ -148,11 +148,14 @@ stdenv.mkDerivation ({
 
   # For building runtime libs
   depsBuildTarget =
-    if hostPlatform == buildPlatform then [
-      targetPackages.stdenv.cc.bintools # newly-built gcc will be used
-    ] else assert targetPlatform == hostPlatform; [ # build != host == target
-      stdenv.cc
-    ];
+    (
+      if hostPlatform == buildPlatform then [
+        targetPackages.stdenv.cc.bintools # newly-built gcc will be used
+      ] else assert targetPlatform == hostPlatform; [ # build != host == target
+        stdenv.cc
+      ]
+    )
+    ++ optional targetPlatform.isLinux patchelf;
 
   buildInputs = [
     gmp mpfr libmpc libelf
diff --git a/nixpkgs/pkgs/development/compilers/gcc/9/default.nix b/nixpkgs/pkgs/development/compilers/gcc/9/default.nix
index 978ad75a3d26..f015ef5605b5 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/9/default.nix
+++ b/nixpkgs/pkgs/development/compilers/gcc/9/default.nix
@@ -12,7 +12,7 @@
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man)
-, gmp, mpfr, libmpc, gettext, which
+, gmp, mpfr, libmpc, gettext, which, patchelf
 , libelf                      # optional, for link-time optimizations (LTO)
 , isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null
@@ -153,11 +153,14 @@ stdenv.mkDerivation ({
 
   # For building runtime libs
   depsBuildTarget =
-    if hostPlatform == buildPlatform then [
-      targetPackages.stdenv.cc.bintools # newly-built gcc will be used
-    ] else assert targetPlatform == hostPlatform; [ # build != host == target
-      stdenv.cc
-    ];
+    (
+      if hostPlatform == buildPlatform then [
+        targetPackages.stdenv.cc.bintools # newly-built gcc will be used
+      ] else assert targetPlatform == hostPlatform; [ # build != host == target
+        stdenv.cc
+      ]
+    )
+    ++ optional targetPlatform.isLinux patchelf;
 
   buildInputs = [
     gmp mpfr libmpc libelf
diff --git a/nixpkgs/pkgs/development/compilers/gcc/builder.sh b/nixpkgs/pkgs/development/compilers/gcc/builder.sh
index 4b14cdb94cdd..7b0632986691 100644
--- a/nixpkgs/pkgs/development/compilers/gcc/builder.sh
+++ b/nixpkgs/pkgs/development/compilers/gcc/builder.sh
@@ -241,7 +241,7 @@ postInstall() {
     # More dependencies with the previous gcc or some libs (gccbug stores the build command line)
     rm -rf $out/bin/gccbug
 
-    if type "patchelf"; then
+    if [[ buildConfig == *"linux"* ]]; then
         # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
         for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do
             PREV_RPATH=`patchelf --print-rpath "$i"`
@@ -250,6 +250,16 @@ postInstall() {
         done
     fi
 
+    if [[ targetConfig == *"linux"* ]]; then
+        # For some reason, when building for linux on darwin, the libs retain
+	# RPATH to $out.
+        for i in "$lib"/"$targetConfig"/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
+    fi
+
     if type "install_name_tool"; then
         for i in "${!outputLib}"/lib/*.*.dylib; do
             install_name_tool -id "$i" "$i" || true