aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8
diff options
context:
space:
mode:
authorAlexander Ivchenko <alexander.ivchenko@intel.com>2014-12-18 16:46:17 +0300
committerAlexander Ivchenko <alexander.ivchenko@intel.com>2014-12-18 16:49:24 +0300
commit866bd0b46cd84957df84e7a3e674d9777807b7f7 (patch)
treedc68ae6f6dc6c1af108a9b790c31d84c02db0ed8 /gcc-4.8
parent10a15a8a1fc940f47b008004b9180c0852c3e143 (diff)
downloadtoolchain_gcc-866bd0b46cd84957df84e7a3e674d9777807b7f7.tar.gz
toolchain_gcc-866bd0b46cd84957df84e7a3e674d9777807b7f7.tar.bz2
toolchain_gcc-866bd0b46cd84957df84e7a3e674d9777807b7f7.zip
[4.8, 4.9] Fix crash of omp loops that are not in the main thread.
Issue happens only when gcc is configured with "--disable-tls". Backport from trunk for fixing PR42616 2014-12-09 Varvara Rainchik <varvara.rainchik@intel.com> * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Add GCC_CHECK_EMUTLS. * libgomp.h: Add check for USE_EMUTLS: this case is equal to HAVE_TLS. * team.c: Likewise. Change-Id: Iee574d1a7888b3bcbd01718669eac34fdd116abb Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
Diffstat (limited to 'gcc-4.8')
-rw-r--r--gcc-4.8/libgomp/config.h.in3
-rwxr-xr-xgcc-4.8/libgomp/configure31
-rw-r--r--gcc-4.8/libgomp/configure.ac3
-rw-r--r--gcc-4.8/libgomp/libgomp.h2
-rw-r--r--gcc-4.8/libgomp/team.c8
5 files changed, 42 insertions, 5 deletions
diff --git a/gcc-4.8/libgomp/config.h.in b/gcc-4.8/libgomp/config.h.in
index 14c7e2a9a..9c26e6d98 100644
--- a/gcc-4.8/libgomp/config.h.in
+++ b/gcc-4.8/libgomp/config.h.in
@@ -76,6 +76,9 @@
/* Define to 1 if the target supports thread-local storage. */
#undef HAVE_TLS
+/* Define to 1 if the target use emutls for thread-local storage. */
+#undef USE_EMUTLS
+
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
diff --git a/gcc-4.8/libgomp/configure b/gcc-4.8/libgomp/configure
index 608a2b0dc..1281aa7fb 100755
--- a/gcc-4.8/libgomp/configure
+++ b/gcc-4.8/libgomp/configure
@@ -15520,6 +15520,37 @@ $as_echo "#define HAVE_TLS 1" >>confdefs.h
fi
+# See if we have emulated thread-local storage.
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the thread-local storage support is from emutls" >&5
+$as_echo_n "checking whether the thread-local storage support is from emutls... " >&6; }
+if test "${gcc_cv_use_emutls+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ gcc_cv_use_emutls=no
+ echo '__thread int a; int b; int main() { return a = b; }' > conftest.c
+ if { ac_try='${CC-cc} -Werror -S -o conftest.s conftest.c 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ if grep __emutls_get_address conftest.s > /dev/null; then
+ gcc_cv_use_emutls=yes
+ fi
+ fi
+ rm -f conftest.*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_use_emutls" >&5
+$as_echo "$gcc_cv_use_emutls" >&6; }
+ if test "$gcc_cv_use_emutls" = "yes" ; then
+
+$as_echo "#define USE_EMUTLS 1" >>confdefs.h
+
+ fi
+
# See what sort of export controls are availible.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the target supports hidden visibility" >&5
diff --git a/gcc-4.8/libgomp/configure.ac b/gcc-4.8/libgomp/configure.ac
index 292db2a13..df6c86e42 100644
--- a/gcc-4.8/libgomp/configure.ac
+++ b/gcc-4.8/libgomp/configure.ac
@@ -245,6 +245,9 @@ fi
# See if we support thread-local storage.
GCC_CHECK_TLS
+# See if we have emulated thread-local storage.
+GCC_CHECK_EMUTLS
+
# See what sort of export controls are availible.
LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY
LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT
diff --git a/gcc-4.8/libgomp/libgomp.h b/gcc-4.8/libgomp/libgomp.h
index 322a43520..e885b8f6b 100644
--- a/gcc-4.8/libgomp/libgomp.h
+++ b/gcc-4.8/libgomp/libgomp.h
@@ -370,7 +370,7 @@ struct gomp_thread_pool
/* ... and here is that TLS data. */
-#ifdef HAVE_TLS
+#if defined HAVE_TLS || defined USE_EMUTLS
extern __thread struct gomp_thread gomp_tls_data;
static inline struct gomp_thread *gomp_thread (void)
{
diff --git a/gcc-4.8/libgomp/team.c b/gcc-4.8/libgomp/team.c
index 243aa9aa9..86a83be5d 100644
--- a/gcc-4.8/libgomp/team.c
+++ b/gcc-4.8/libgomp/team.c
@@ -37,7 +37,7 @@ pthread_key_t gomp_thread_destructor;
/* This is the libgomp per-thread data structure. */
-#ifdef HAVE_TLS
+#if defined HAVE_TLS || defined USE_EMUTLS
__thread struct gomp_thread gomp_tls_data;
#else
pthread_key_t gomp_tls_key;
@@ -69,7 +69,7 @@ gomp_thread_start (void *xdata)
void (*local_fn) (void *);
void *local_data;
-#ifdef HAVE_TLS
+#if defined HAVE_TLS || defined USE_EMUTLS
thr = &gomp_tls_data;
#else
struct gomp_thread local_thr;
@@ -534,7 +534,7 @@ initialize_team (void)
{
struct gomp_thread *thr;
-#ifndef HAVE_TLS
+#if !defined HAVE_TLS && !defined USE_EMUTLS
static struct gomp_thread initial_thread_tls_data;
pthread_key_create (&gomp_tls_key, NULL);
@@ -544,7 +544,7 @@ initialize_team (void)
if (pthread_key_create (&gomp_thread_destructor, gomp_free_thread) != 0)
gomp_fatal ("could not create thread pool destructor.");
-#ifdef HAVE_TLS
+#if defined HAVE_TLS || defined USE_EMUTLS
thr = &gomp_tls_data;
#else
thr = &initial_thread_tls_data;