summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-10-04 17:46:32 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-10-04 17:47:22 +0200
commit4a42f84a70f38ee848b01baeaa6da5219dfe9b53 (patch)
treed11131b0ec6926ae60cfc45aa57799a06b133478
parent4bcf34ae5a524d4c35407bd087aef52c4592011c (diff)
Clean up HAVE_THREADSAFE_STATICS
Change-Id: I042269aabaa2e9952c5d2f41cf93e55d654f6313
-rw-r--r--configure.in81
-rw-r--r--solenv/gbuild/platform/com_GCC_defs.mk4
-rw-r--r--solenv/gbuild/platform/macosx.mk4
-rw-r--r--solenv/inc/unxgcc.mk3
-rw-r--r--solenv/inc/unxiosr.mk3
-rw-r--r--solenv/inc/unxsogs.mk4
-rw-r--r--solenv/inc/wntgcci.mk3
7 files changed, 53 insertions, 49 deletions
diff --git a/configure.in b/configure.in
index 8fb72878fb6a..4ea7155d2db5 100644
--- a/configure.in
+++ b/configure.in
@@ -5166,51 +5166,42 @@ dnl ===================================================================
AC_MSG_CHECKING([whether $CXX supports thread safe statics])
unset HAVE_THREADSAFE_STATICS
if test "$GCC" = "yes"; then
- save_CXXFLAGS=$CXXFLAGS
- CXXFLAGS="$CXXFLAGS -fthreadsafe-statics"
- AC_LANG_PUSH([C++])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)],[HAVE_THREADSAFE_STATICS=TRUE],[])
- AC_LANG_POP([C++])
- CXXFLAGS=$save_CXXFLAGS
- if test "$HAVE_THREADSAFE_STATICS" = "TRUE"; then
- dnl Some C++ runtimes use a single lock for all static variables, which
- dnl can cause deadlock in multi-threaded applications. This is not
- dnl easily tested here; for POSIX-based systems, if executing the
- dnl following C++ program does not terminate then the tool chain
- dnl apparently has this problem:
- dnl
- dnl #include <pthread.h>
- dnl int h() { return 0; }
- dnl void * g(void * unused) {
- dnl static int n = h();
- dnl return &n;
- dnl }
- dnl int f() {
- dnl pthread_t t;
- dnl pthread_create(&t, 0, g, 0);
- dnl pthread_join(t, 0);
- dnl return 0;
- dnl }
- dnl int main() {
- dnl static int n = f();
- dnl return n;
- dnl }
- dnl
- dnl Mac OS X up to at least 10.7.1 is known to have this problem, as is
- dnl at least one instance of GCC 4.2.4 (used on a "Linux
- dnl ooobuild1.osuosl.org 2.6.9-101.plus.c4smp #1 SMP Thu Jul 21 19:08:15
- dnl EDT 2011 i686 i686 i386 GNU/Linux" machine); see the definition of
- dnl __cxa_guard_acquire in GCC's libstdc++-v3/libsupc++/guard.cc for
- dnl what #ifdefs actually make a difference there. Conservative advice
- dnl from Jakub Jelinek is to assume it working in GCC >= 4.3:
- if test "$_os" = "Darwin" -o "${GCCVER?}" -lt 040300; then
- unset HAVE_THREADSAFE_STATICS
- AC_MSG_RESULT([broken (i.e., no)])
- else
- AC_MSG_RESULT([yes])
- fi
- else
- AC_MSG_RESULT([no])
+ dnl -fthreadsafe-statics is available since GCC 4, so always available for
+ dnl us. However, some C++ runtimes use a single lock for all static
+ dnl variables, which can cause deadlock in multi-threaded applications.
+ dnl This is not easily tested here; for POSIX-based systems, if executing
+ dnl the following C++ program does not terminate then the tool chain
+ dnl apparently has this problem:
+ dnl
+ dnl #include <pthread.h>
+ dnl int h() { return 0; }
+ dnl void * g(void * unused) {
+ dnl static int n = h();
+ dnl return &n;
+ dnl }
+ dnl int f() {
+ dnl pthread_t t;
+ dnl pthread_create(&t, 0, g, 0);
+ dnl pthread_join(t, 0);
+ dnl return 0;
+ dnl }
+ dnl int main() {
+ dnl static int n = f();
+ dnl return n;
+ dnl }
+ dnl
+ dnl Mac OS X up to at least 10.7.1 is known to have this problem, as is at
+ dnl least one instance of GCC 4.2.4 (used on a "Linux ooobuild1.osuosl.org
+ dnl 2.6.9-101.plus.c4smp #1 SMP Thu Jul 21 19:08:15 EDT 2011 i686 i686 i386
+ dnl GNU/Linux" machine); see the definition of __cxa_guard_acquire in GCC's
+ dnl libstdc++-v3/libsupc++/guard.cc for what #ifdefs actually make a
+ dnl difference there. Conservative advice from Jakub Jelinek is to assume
+ dnl it working in GCC >= 4.3:
+ if test "$_os" = "Darwin" -o "${GCCVER?}" -lt 040300; then
+ AC_MSG_RESULT([broken (i.e., no)])
+ else
+ HAVE_THREADSAFE_STATICS=TRUE
+ AC_MSG_RESULT([yes])
fi
else
AC_MSG_RESULT([unknown (assuming no)])
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk
index 0cc86e3c73d2..1e349f0a8325 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -81,6 +81,10 @@ gb_CXXFLAGS_COMMON := \
-fno-common \
-pipe \
+ifneq ($(HAVE_THREADSAFE_STATICS),TRUE)
+gb_CXXFLAGS_COMMON += -fno-threadsafe-statics
+endif
+
ifeq ($(HAVE_GCC_VISIBILITY_FEATURE),TRUE)
gb_VISIBILITY_FLAGS := -DHAVE_GCC_VISIBILITY_FEATURE -fvisibility=hidden
ifneq ($(HAVE_GCC_VISIBILITY_BROKEN),TRUE)
diff --git a/solenv/gbuild/platform/macosx.mk b/solenv/gbuild/platform/macosx.mk
index 2e2c20302132..ecb7d71076ff 100644
--- a/solenv/gbuild/platform/macosx.mk
+++ b/solenv/gbuild/platform/macosx.mk
@@ -87,10 +87,6 @@ ifeq ($(HAVE_GCC_NO_LONG_DOUBLE),TRUE)
gb_CXXFLAGS += -Wno-long-double
endif
-ifneq ($(HAVE_THREADSAFE_STATICS),TRUE)
-gb_CXXFLAGS += -fno-threadsafe-statics
-endif
-
# these are to get g++ to switch to Objective-C++ mode
# (see toolkit module for a case where it is necessary to do it this way)
gb_OBJCXXFLAGS := -x objective-c++ -fobjc-exceptions
diff --git a/solenv/inc/unxgcc.mk b/solenv/inc/unxgcc.mk
index 3ac4956ff216..04419863f32a 100644
--- a/solenv/inc/unxgcc.mk
+++ b/solenv/inc/unxgcc.mk
@@ -93,6 +93,9 @@ CFLAGS_NO_EXCEPTIONS=-fno-exceptions
# -fpermissive should be removed as soon as possible
CFLAGSCXX= -pipe $(ARCH_FLAGS)
+.IF "$(HAVE_THREADSAFE_STATICS)" != "TRUE"
+CFLAGSCXX += -fno-threadsafe-statics
+.END
.IF "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE" && "$(HAVE_GCC_VISIBILITY_BROKEN)" != "TRUE"
CFLAGSCXX+=-fvisibility-inlines-hidden
.ENDIF # "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
diff --git a/solenv/inc/unxiosr.mk b/solenv/inc/unxiosr.mk
index 089dc3d588aa..f1a64929e20c 100644
--- a/solenv/inc/unxiosr.mk
+++ b/solenv/inc/unxiosr.mk
@@ -64,6 +64,9 @@ CFLAGS_NO_EXCEPTIONS=-fno-exceptions
# Normal C++ compilation flags
CFLAGSCXX=-pipe -fsigned-char $(ARCH_FLAGS) -Wno-ctor-dtor-privacy
+.IF "$(HAVE_THREADSAFE_STATICS)" != "TRUE"
+CFLAGSCXX += -fno-threadsafe-statics
+.END
# No PIC needed as we don't build dynamic objects
PICSWITCH:=
diff --git a/solenv/inc/unxsogs.mk b/solenv/inc/unxsogs.mk
index a4151439beb8..f75c4aa0883e 100644
--- a/solenv/inc/unxsogs.mk
+++ b/solenv/inc/unxsogs.mk
@@ -58,6 +58,10 @@ CFLAGSEXCEPTIONS=-fexceptions
CFLAGS_NO_EXCEPTIONS=-fno-exceptions
CFLAGSCXX= -pipe $(ARCH_FLAGS)
+.IF "$(HAVE_THREADSAFE_STATICS)" != "TRUE"
+CFLAGSCXX += -fno-threadsafe-statics
+.END
+
PICSWITCH:=-fPIC
CFLAGSOBJGUIMT=
CFLAGSOBJCUIMT=
diff --git a/solenv/inc/wntgcci.mk b/solenv/inc/wntgcci.mk
index c8e39d1570bb..496e8c22c319 100644
--- a/solenv/inc/wntgcci.mk
+++ b/solenv/inc/wntgcci.mk
@@ -46,6 +46,9 @@ CFLAGS+=-fmessage-length=0 -c
CFLAGSCC=-pipe $(ARCH_FLAGS)
CFLAGSCXX=-pipe $(ARCH_FLAGS)
+.IF "$(HAVE_THREADSAFE_STATICS)" != "TRUE"
+CFLAGSCXX += -fno-threadsafe-statics
+.END
.IF "$(HAVE_CXX0X)" == "TRUE"
# FIXME still does not compile fully CFLAGSCXX+=-std=gnu++0x