Skip to content

Commit a486c77

Browse files
committed
bpo-33473: Be slightly better about CFLAGS, LDFLAGS, and related
- "-pthread" is a part of the C compiler and linker flags. It is not part of the compiler. In particular 'make CC=clang' ought to work - checking for pthreads support is a link time issue, not run time Not done in this patch: - convert from "gcc" to "cc" to more correctly infer the current compiler - regenerate generated code such as "configure" or "aclocal.m4"
1 parent b4bc5ca commit a486c77

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
configure.ac was fixed to correctly report CC, CFLAGS, and LDFLAGS

configure.ac

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,8 +1993,9 @@ then
19931993
AC_MSG_CHECKING(whether $CC accepts -pthread)
19941994
AC_CACHE_VAL(ac_cv_pthread,
19951995
[ac_save_cc="$CC"
1996-
CC="$CC -pthread"
1997-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
1996+
CC="$CC"
1997+
LDFLAGS="-pthread"
1998+
AC_LINK_IFELSE([AC_LANG_SOURCE([[
19981999
#include <stdio.h>
19992000
#include <pthread.h>
20002001
@@ -2030,7 +2031,8 @@ then
20302031
ac_cv_cxx_thread=yes
20312032
elif test "$ac_cv_pthread" = "yes"
20322033
then
2033-
CXX="$CXX -pthread"
2034+
CXX="$CXX"
2035+
CXXFLAGS="-pthread"
20342036
ac_cv_cxx_thread=yes
20352037
fi
20362038

@@ -2261,7 +2263,7 @@ then CC="$CC -Kpthread"
22612263
elif test "$ac_cv_kthread" = "yes"
22622264
then CC="$CC -Kthread"
22632265
elif test "$ac_cv_pthread" = "yes"
2264-
then CC="$CC -pthread"
2266+
then CC="$CC"; BASECFLAGS="-pthread"; BASECXXFLAGS="-pthread"
22652267
fi
22662268

22672269
AC_MSG_CHECKING(for pthread_t)
@@ -2973,9 +2975,11 @@ then
29732975
posix_threads=yes
29742976
elif test "$ac_cv_pthread" = "yes"
29752977
then
2976-
CC="$CC -pthread"
2978+
CC="$CC"
2979+
BASECFLAGS="-pthread"
29772980
if test "$ac_cv_cxx_thread" = "yes"; then
2978-
CXX="$CXX -pthread"
2981+
CXX="$CXX"
2982+
BASECXXFLAGS="-pthread"
29792983
fi
29802984
posix_threads=yes
29812985
else

0 commit comments

Comments
 (0)