Skip to content

Commit

Permalink
Disable non-POSIX TLS usage in libgomp (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsamaroo authored Oct 20, 2020
1 parent 78a8000 commit 564e1d7
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 1 deletion.
19 changes: 19 additions & 0 deletions 0_RootFS/GCCBootstrap@4/bundled/patches/musl_disable_tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/gcc/libgomp/configure.tgt 2020-09-30 20:53:48.451232161 -0500
+++ b/gcc/libgomp/configure.tgt 2020-09-30 20:54:49.194468515 -0500
@@ -10,16 +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
-
- *-*-linux*)
- XCFLAGS="${XCFLAGS} -ftls-model=initial-exec"
- ;;
- esac
-fi
-
# Since we require POSIX threads, assume a POSIX system by default.
config_path="posix"

26 changes: 26 additions & 0 deletions 0_RootFS/GCCBootstrap@5/bundled/patches/musl_disable_tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/gcc/libgomp/configure.tgt 2020-09-30 21:05:24.538481160 -0500
+++ b/gcc/libgomp/configure.tgt 2020-09-30 21:05:34.669353797 -0500
@@ -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"

26 changes: 26 additions & 0 deletions 0_RootFS/GCCBootstrap@6/bundled/patches/musl_disable_tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/gcc/libgomp/configure.tgt 2020-09-30 21:02:37.562580331 -0500
+++ b/gcc/libgomp/configure.tgt 2020-09-30 21:02:51.535404669 -0500
@@ -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"

26 changes: 26 additions & 0 deletions 0_RootFS/GCCBootstrap@7/bundled/patches/musl_disable_tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/gcc/libgomp/configure.tgt 2020-09-30 21:03:36.980833342 -0500
+++ b/gcc/libgomp/configure.tgt 2020-09-30 21:03:50.471663740 -0500
@@ -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"

26 changes: 26 additions & 0 deletions 0_RootFS/GCCBootstrap@8/bundled/patches/musl_disable_tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/gcc/libgomp/configure.tgt 2020-09-30 21:06:46.507450670 -0500
+++ b/gcc/libgomp/configure.tgt 2020-09-30 21:06:56.086330247 -0500
@@ -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"

26 changes: 26 additions & 0 deletions 0_RootFS/GCCBootstrap@9/bundled/patches/musl_disable_tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/gcc/libgomp/configure.tgt 2020-09-30 21:07:34.427848229 -0500
+++ b/gcc/libgomp/configure.tgt 2020-09-30 21:07:49.426659669 -0500
@@ -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 -DUSING_INITIAL_EXEC_TLS"
- ;;
-
- *-*-rtems*)
- XCFLAGS="${XCFLAGS} -ftls-model=local-exec"
- ;;
- esac
-fi
-
# Since we require POSIX threads, assume a POSIX system by default.
config_path="posix"

7 changes: 6 additions & 1 deletion 0_RootFS/gcc_common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ function gcc_script(compiler_target::Platform)
atomic_patch -p1 "${p}" || true
done
# Disable any non-POSIX usage of TLS for musl
if [[ "${COMPILER_TARGET}" == *musl* ]]; then
patch -p1 $WORKSPACE/srcdir/gcc-*/libgomp/configure.tgt $WORKSPACE/srcdir/patches/musl_disable_tls.patch
fi
# If we're on MacOS, we need to install cctools first, separately.
if [[ ${COMPILER_TARGET} == *-darwin* ]]; then
Expand Down Expand Up @@ -649,7 +654,7 @@ function gcc_script(compiler_target::Platform)
elif [[ "${COMPILER_TARGET}" == *freebsd* ]]; then
GCC_CONF_ARGS="${GCC_CONF_ARGS} --enable-languages=c,c++,fortran"
# On mingw32 override native system header directories
elif [[ "${COMPILER_TARGET}" == *mingw* ]]; then
GCC_CONF_ARGS="${GCC_CONF_ARGS} --enable-languages=c,c++,fortran"
Expand Down

0 comments on commit 564e1d7

Please sign in to comment.