summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Targets.cpp
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-02-05 21:34:28 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-02-05 21:34:28 +0000
commitb038a5268fc3c95c0e885fe39872308ef8e52537 (patch)
tree82ebadae7f58b871d9ec453f3b22f47a901eb5d5 /clang/lib/Basic/Targets.cpp
parenta090a00e45bb35ce46e9c665b7f9b84b1b070bc1 (diff)
downloadbcm5719-llvm-b038a5268fc3c95c0e885fe39872308ef8e52537.tar.gz
bcm5719-llvm-b038a5268fc3c95c0e885fe39872308ef8e52537.zip
[SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248] macros on SystemZ. This fixes a miscompile of GCC C++11 standard library headers due to use of those macros in an ABI-changing manner. See e.g. /usr/include/c++/4.8.5/ext/concurrence.h: // Compile time constant that indicates prefered locking policy in // the current configuration. static const _Lock_policy __default_lock_policy = #ifdef __GTHREADS #if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \ && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) _S_atomic; #else _S_mutex; #endif #else _S_single; #endif A different choice of __default_lock_policy causes different sizes of several of the C++11 data structures, which are then incompatible when inlined in clang-compiled code with what the (GCC-compiled) external library expects. This in turn leads to various crashes when using std::thread in code compiled with clang, as see e.g. via the ThreadPool unit tests. See PR 26473 for an example. llvm-svn: 259931
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r--clang/lib/Basic/Targets.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index cbbf51be18e..3788a82a5fb 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -6166,6 +6166,12 @@ public:
Builder.defineMacro("__s390x__");
Builder.defineMacro("__zarch__");
Builder.defineMacro("__LONG_DOUBLE_128__");
+
+ Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+ Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+ Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+ Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
if (HasTransactionalExecution)
Builder.defineMacro("__HTM__");
if (Opts.ZVector)
OpenPOWER on IntegriCloud