From d68dee04b7aa47c8eecf721ccdb4c269deea657c Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Fri, 12 Feb 2021 20:38:38 +0100 Subject: [PATCH] gcc: fix cross compilation to musl32 --- pkgs/development/compilers/gcc/7/default.nix | 2 +- .../development/compilers/gcc/common/configure-flags.nix | 6 +++--- pkgs/top-level/all-packages.nix | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 75d519c3107b..d9b4c639b5ab 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -73,7 +73,7 @@ let majorVersion = "7"; ++ optional langFortran ../gfortran-driving.patch ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch ++ optional (targetPlatform.libc == "musl" && targetPlatform.isx86_32) (fetchpatch { - url = "https://git.alpinelinux.org/aports/plain/main/gcc/gcc-6.1-musl-libssp.patch"; + url = "https://git.alpinelinux.org/aports/plain/main/gcc/gcc-6.1-musl-libssp.patch?id=5e4b96e23871ee28ef593b439f8c07ca7c7eb5bb"; sha256 = "1jf1ciz4gr49lwyh8knfhw6l5gvfkwzjy90m7qiwkcbsf4a3fqn2"; }) ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index 4bdec26fd993..443ed19235d5 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -94,9 +94,6 @@ let # In uclibc cases, libgomp needs an additional '-ldl' # and as I don't know how to pass it, I disable libgomp. "--disable-libgomp" - ] ++ lib.optionals (targetPlatform.libc == "musl") [ - # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 - "--disable-libmpx" ] ++ lib.optional (targetPlatform.libc == "newlib") "--with-newlib" ++ lib.optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" ); @@ -181,6 +178,9 @@ let # On Illumos/Solaris GNU as is preferred "--with-gnu-as" "--without-gnu-ld" ] + ++ lib.optional (targetPlatform.libc == "musl") + # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 + "--disable-libmpx" ++ lib.optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ "--disable-libsanitizer" "--disable-symvers" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 715aeed5813e..9a8096eef626 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9827,6 +9827,9 @@ in libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null; + # gcc 10 is too strict to cross compile gcc <= 8 + stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; + isl = if stdenv.isDarwin then null else if stdenv.targetPlatform.isRedox @@ -9843,6 +9846,9 @@ in libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null; + # gcc 10 is too strict to cross compile gcc <= 8 + stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; + isl = if !stdenv.isDarwin then isl_0_17 else null; })); @@ -9855,6 +9861,9 @@ in libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null; + # gcc 10 is too strict to cross compile gcc <= 8 + stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; + isl = if !stdenv.isDarwin then isl_0_17 else null; }));