From 964b92b614b1a2459520780073d8d97044362467 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 18 Aug 2018 23:51:14 -0400 Subject: [PATCH] Rework -pthread test for GCC on Solaris It looks like GCC is rejecting the -pthread option but it is advertising Pthread support by defining 39 related macros. I'm not sure what to make of it, but we can't use -pthread because it breaks the compile. --- GNUmakefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 66ec5493..461fb1a0 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -546,9 +546,15 @@ endif # Use -pthread whenever it is available. See http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf # http://stackoverflow.com/questions/2127797/gcc-significance-of-pthread-flag-when-compiling -ifneq ($(IS_LINUX)$(GCC_COMPILER)$(CLANG_COMPILER)$(INTEL_COMPILER),0000) +# BAD_PTHREAD and HAVE_PTHREAD is due to GCC on Solaris. GCC rejects -pthread but defines +# 39 *_PTHREAD_* related macros. Then we pickup the macros and enable the option... +BAD_PTHREAD = $(shell $(CXX) $(CXXFLAGS) -pthread -dM -E adhoc.cpp 2>&1 | $(GREP) -i -c -E 'warning|illegal|unrecognized') +HAVE_PTHREAD = $(shell $(CXX) $(CXXFLAGS) -pthread -dM -E adhoc.cpp 2>/dev/null | $(GREP) -i -c 'PTHREAD') +ifeq ($(BAD_PTHREAD),0) +ifneq ($(HAVE_PTHREAD),0) CXXFLAGS += -pthread endif # CXXFLAGS +endif # CXXFLAGS # Remove -fPIC if present. SunCC use -KPIC ifeq ($(SUN_COMPILER),1)