From 3ec0d14140dc086ce40a5f5b67338a8c9a9ab08f Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 24 Sep 2018 18:33:34 -0500 Subject: [PATCH 1/4] gcc7: more options for musl --- pkgs/development/compilers/gcc/7/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 4dfbcf0f5458..2dd919d978fa 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -292,7 +292,12 @@ stdenv.mkDerivation ({ # On Illumos/Solaris GNU as is preferred "--with-gnu-as" "--without-gnu-ld" ] - ++ optional (targetPlatform == hostPlatform && targetPlatform.libc == "musl") "--disable-libsanitizer" + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] ++ optional (targetPlatform.isAarch64) "--enable-fix-cortex-a53-843419" ; From e845be175602f9784a457beb2a0e2d30e97facc1 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 24 Sep 2018 19:51:29 -0500 Subject: [PATCH 2/4] gcc: fix libgomp to not use initial-exec Only apply w/musl since while it's wrong everywhere it apparently hasn't broken things entirely w/glibc so keep things as they were. Patch regenerated from original so that it applies which isn't saying much since it's simple :). Source: https://patchwork.ozlabs.org/patch/154298/ IRC chat on #musl with Rich and others endorses this, at least at the conceptual level of no shared library should be using initial-exec TLS. Fixes various uses of libgomp that previously crashed (before 1.1.20) or encounter errors (post-1.1.20), such as pythonPackages.cython . --- pkgs/development/compilers/gcc/7/default.nix | 3 +- .../7/libgomp-dont-force-initial-exec.patch | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/compilers/gcc/7/libgomp-dont-force-initial-exec.patch diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 2dd919d978fa..6643d41ff77c 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -56,7 +56,8 @@ let version = "7.3.0"; sha256 = "0mrvxsdwip2p3l17dscpc1x8vhdsciqw1z5q9i6p5g9yg1cqnmgs"; }) ++ optional langFortran ../gfortran-driving.patch - ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch; + ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch + ++ optional (targetPlatform.libc == "musl") ./libgomp-dont-force-initial-exec.patch; /* Cross-gcc settings (build == host != target) */ crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; diff --git a/pkgs/development/compilers/gcc/7/libgomp-dont-force-initial-exec.patch b/pkgs/development/compilers/gcc/7/libgomp-dont-force-initial-exec.patch new file mode 100644 index 000000000000..afd1f7456d32 --- /dev/null +++ b/pkgs/development/compilers/gcc/7/libgomp-dont-force-initial-exec.patch @@ -0,0 +1,40 @@ +From 01c433f4788441c0963005b9d3fad5b2865e6651 Mon Sep 17 00:00:00 2001 +From: Will Dietz +Date: Mon, 24 Sep 2018 19:57:50 -0500 +Subject: [PATCH] libgomp/configure.tgt: don't force initial-exec tls-model + +--- + libgomp/configure.tgt | 17 ----------------- + 1 file changed, 17 deletions(-) + +diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt +index 74d95a570c7..b608c55f0c1 100644 +--- a/libgomp/configure.tgt ++++ b/libgomp/configure.tgt +@@ -10,23 +10,6 @@ + # XCFLAGS Add extra compile flags to use. + # XLDFLAGS Add extra link flags to use. + +-# Optimize TLS usage by avoiding the overhead of dynamic allocation. +-if test $gcc_cv_have_tls = yes ; then +- case "${target}" in +- +- *-*-k*bsd*-gnu*) +- ;; +- +- *-*-linux* | *-*-gnu*) +- XCFLAGS="${XCFLAGS} -ftls-model=initial-exec" +- ;; +- +- *-*-rtems*) +- XCFLAGS="${XCFLAGS} -ftls-model=local-exec" +- ;; +- esac +-fi +- + # Since we require POSIX threads, assume a POSIX system by default. + config_path="posix" + +-- +2.19.0 + From fecd326399d72ecf0e5356f60aec7d79a0b7b7ef Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 24 Sep 2018 20:03:50 -0500 Subject: [PATCH 3/4] gcc{5,6,7,8}: share libgomp patch, propagate musl config flags --- pkgs/development/compilers/gcc/5/default.nix | 8 +++++++- pkgs/development/compilers/gcc/6/default.nix | 8 +++++++- pkgs/development/compilers/gcc/7/default.nix | 2 +- pkgs/development/compilers/gcc/8/default.nix | 10 ++++++++-- .../gcc/{7 => }/libgomp-dont-force-initial-exec.patch | 0 5 files changed, 23 insertions(+), 5 deletions(-) rename pkgs/development/compilers/gcc/{7 => }/libgomp-dont-force-initial-exec.patch (100%) diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index 2e51e9c05066..14da38b34fb4 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -60,6 +60,7 @@ let version = "5.5.0"; ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch ++ optional noSysDirs ../no-sys-dirs.patch ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch ++ optional stdenv.hostPlatform.isMusl (fetchpatch { url = https://raw.githubusercontent.com/richfelker/musl-cross-make/e84b1bd1fc12a3def33111ca6df522cd6e5ec361/patches/gcc-5.3.0/0001-musl.diff; sha256 = "0pppbf8myi2kjhm3z3479ihn1cm60kycfv60gj8yy1bs0pl1qcfm"; @@ -331,7 +332,12 @@ stdenv.mkDerivation ({ # On Illumos/Solaris GNU as is preferred "--with-gnu-as" "--without-gnu-ld" ] - ++ optional (targetPlatform == hostPlatform && targetPlatform.libc == "musl") "--disable-libsanitizer" + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] ; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index e6825afcfa84..2a7af827f2dd 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -61,6 +61,7 @@ let version = "6.4.0"; ++ optional langFortran ../gfortran-driving.patch ++ [ ../struct-ucontext.patch ../struct-sigaltstack.patch ] # glibc-2.26 ++ optional langJava [ ../struct-ucontext-libjava.patch ] # glibc-2.26 + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch ; javaEcj = fetchurl { @@ -336,7 +337,12 @@ stdenv.mkDerivation ({ # On Illumos/Solaris GNU as is preferred "--with-gnu-as" "--without-gnu-ld" ] - ++ optional (targetPlatform == hostPlatform && targetPlatform.libc == "musl") "--disable-libsanitizer" + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] ; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 6643d41ff77c..fd3ce8df497d 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -57,7 +57,7 @@ let version = "7.3.0"; }) ++ optional langFortran ../gfortran-driving.patch ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch - ++ optional (targetPlatform.libc == "musl") ./libgomp-dont-force-initial-exec.patch; + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch; /* Cross-gcc settings (build == host != target) */ crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index 04054df8bf82..427fe3fdddf7 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -51,7 +51,8 @@ let version = "8.2.0"; sha256 = ""; # TODO: uncomment and check hash when available. }) */ ++ optional langFortran ../gfortran-driving.patch - ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch; + ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch; /* Cross-gcc settings (build == host != target) */ crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; @@ -284,7 +285,12 @@ stdenv.mkDerivation ({ # On Illumos/Solaris GNU as is preferred "--with-gnu-as" "--without-gnu-ld" ] - ++ optional (targetPlatform == hostPlatform && targetPlatform.libc == "musl") "--disable-libsanitizer" + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] ; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; diff --git a/pkgs/development/compilers/gcc/7/libgomp-dont-force-initial-exec.patch b/pkgs/development/compilers/gcc/libgomp-dont-force-initial-exec.patch similarity index 100% rename from pkgs/development/compilers/gcc/7/libgomp-dont-force-initial-exec.patch rename to pkgs/development/compilers/gcc/libgomp-dont-force-initial-exec.patch From 8a0a34f76645a090e1f2f0e2c17912f54bfe84e4 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 24 Sep 2018 20:43:27 -0500 Subject: [PATCH 4/4] openblas: try leaving openmp enabled w/musl --- pkgs/development/libraries/science/math/openblas/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix index 3f271d015027..a84cb7623d8f 100644 --- a/pkgs/development/libraries/science/math/openblas/default.nix +++ b/pkgs/development/libraries/science/math/openblas/default.nix @@ -60,7 +60,7 @@ let TARGET = "ATHLON"; DYNAMIC_ARCH = "1"; CC = "gcc"; - USE_OPENMP = if stdenv.hostPlatform.isMusl then "0" else "1"; + USE_OPENMP = "1"; }; }; in