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.
pull/709/head
Jeffrey Walton 2018-08-18 23:51:14 -04:00
parent 3929c3594c
commit 964b92b614
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 7 additions and 1 deletions

View File

@ -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)