about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWill Dietz <w@wdtz.org>2018-09-24 19:51:29 -0500
committerWill Dietz <w@wdtz.org>2018-09-25 00:04:33 -0500
commite845be175602f9784a457beb2a0e2d30e97facc1 (patch)
tree22c8a226fbab771768a9a714a1c4065b88f3d041
parent3ec0d14140dc086ce40a5f5b67338a8c9a9ab08f (diff)
downloadnixlib-e845be175602f9784a457beb2a0e2d30e97facc1.tar
nixlib-e845be175602f9784a457beb2a0e2d30e97facc1.tar.gz
nixlib-e845be175602f9784a457beb2a0e2d30e97facc1.tar.bz2
nixlib-e845be175602f9784a457beb2a0e2d30e97facc1.tar.lz
nixlib-e845be175602f9784a457beb2a0e2d30e97facc1.tar.xz
nixlib-e845be175602f9784a457beb2a0e2d30e97facc1.tar.zst
nixlib-e845be175602f9784a457beb2a0e2d30e97facc1.zip
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 .
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix3
-rw-r--r--pkgs/development/compilers/gcc/7/libgomp-dont-force-initial-exec.patch40
2 files changed, 42 insertions, 1 deletions
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 <w@wdtz.org>
+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
+