From e3e354f63a8804cd88cce39db7132463ef2391c7 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 25 Sep 2018 13:52:59 -0400 Subject: [PATCH] add patches to fix invalid tls-model usage in gcc target libs the initial-exec tls model is not valid in any code that might be dynamically loaded. it usually happens to work on glibc because glibc reserves some static tls space for late-loaded libraries that need it, but if it's already been exhausted that will fail. musl does not support this hack at all, and it's not valid for gcc target libs to be doing it anywhere, so patch it out entirely rather than just for musl. --- patches/gcc-5.3.0/0016-invalid_tls_model.diff | 51 +++++++++++++++++++ patches/gcc-6.4.0/0016-invalid_tls_model.diff | 51 +++++++++++++++++++ patches/gcc-7.3.0/0016-invalid_tls_model.diff | 51 +++++++++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 patches/gcc-5.3.0/0016-invalid_tls_model.diff create mode 100644 patches/gcc-6.4.0/0016-invalid_tls_model.diff create mode 100644 patches/gcc-7.3.0/0016-invalid_tls_model.diff diff --git a/patches/gcc-5.3.0/0016-invalid_tls_model.diff b/patches/gcc-5.3.0/0016-invalid_tls_model.diff new file mode 100644 index 0000000..d3b2b8e --- /dev/null +++ b/patches/gcc-5.3.0/0016-invalid_tls_model.diff @@ -0,0 +1,51 @@ +--- gcc-7.3.0/libgomp/configure.tgt.orig 2018-09-25 13:44:16.654561098 -0400 ++++ gcc-7.3.0/libgomp/configure.tgt 2018-09-25 13:44:50.452688100 -0400 +@@ -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" + +--- gcc-7.3.0/libitm/configure.tgt.orig 2018-09-25 13:47:31.019296903 -0400 ++++ gcc-7.3.0/libitm/configure.tgt 2018-09-25 13:47:37.676322335 -0400 +@@ -27,22 +27,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 +- +- # For x86, we use slots in the TCB head for most of our TLS. +- # The setup of those slots in beginTransaction can afford to +- # use the global-dynamic model. +- i[456]86-*-linux* | x86_64-*-linux*) +- ;; +- +- *-*-linux*) +- XCFLAGS="${XCFLAGS} -ftls-model=initial-exec" +- ;; +- esac +-fi +- + # Map the target cpu to an ARCH sub-directory. At the same time, + # work out any special compilation flags as necessary. + case "${target_cpu}" in diff --git a/patches/gcc-6.4.0/0016-invalid_tls_model.diff b/patches/gcc-6.4.0/0016-invalid_tls_model.diff new file mode 100644 index 0000000..d3b2b8e --- /dev/null +++ b/patches/gcc-6.4.0/0016-invalid_tls_model.diff @@ -0,0 +1,51 @@ +--- gcc-7.3.0/libgomp/configure.tgt.orig 2018-09-25 13:44:16.654561098 -0400 ++++ gcc-7.3.0/libgomp/configure.tgt 2018-09-25 13:44:50.452688100 -0400 +@@ -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" + +--- gcc-7.3.0/libitm/configure.tgt.orig 2018-09-25 13:47:31.019296903 -0400 ++++ gcc-7.3.0/libitm/configure.tgt 2018-09-25 13:47:37.676322335 -0400 +@@ -27,22 +27,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 +- +- # For x86, we use slots in the TCB head for most of our TLS. +- # The setup of those slots in beginTransaction can afford to +- # use the global-dynamic model. +- i[456]86-*-linux* | x86_64-*-linux*) +- ;; +- +- *-*-linux*) +- XCFLAGS="${XCFLAGS} -ftls-model=initial-exec" +- ;; +- esac +-fi +- + # Map the target cpu to an ARCH sub-directory. At the same time, + # work out any special compilation flags as necessary. + case "${target_cpu}" in diff --git a/patches/gcc-7.3.0/0016-invalid_tls_model.diff b/patches/gcc-7.3.0/0016-invalid_tls_model.diff new file mode 100644 index 0000000..d3b2b8e --- /dev/null +++ b/patches/gcc-7.3.0/0016-invalid_tls_model.diff @@ -0,0 +1,51 @@ +--- gcc-7.3.0/libgomp/configure.tgt.orig 2018-09-25 13:44:16.654561098 -0400 ++++ gcc-7.3.0/libgomp/configure.tgt 2018-09-25 13:44:50.452688100 -0400 +@@ -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" + +--- gcc-7.3.0/libitm/configure.tgt.orig 2018-09-25 13:47:31.019296903 -0400 ++++ gcc-7.3.0/libitm/configure.tgt 2018-09-25 13:47:37.676322335 -0400 +@@ -27,22 +27,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 +- +- # For x86, we use slots in the TCB head for most of our TLS. +- # The setup of those slots in beginTransaction can afford to +- # use the global-dynamic model. +- i[456]86-*-linux* | x86_64-*-linux*) +- ;; +- +- *-*-linux*) +- XCFLAGS="${XCFLAGS} -ftls-model=initial-exec" +- ;; +- esac +-fi +- + # Map the target cpu to an ARCH sub-directory. At the same time, + # work out any special compilation flags as necessary. + case "${target_cpu}" in