diff options
author | Alexander Ivchenko <alexander.ivchenko@intel.com> | 2014-08-12 11:06:44 +0000 |
---|---|---|
committer | Kirill Yukhin <kyukhin@gcc.gnu.org> | 2014-08-12 11:06:44 +0000 |
commit | 7955b06580a73bd6ad0d744928ab4775e4723c78 (patch) | |
tree | 158a00fe3e709b3e54e467d019bdf2029d24f729 /libcilkrts/configure.ac | |
parent | 5435176b314566bf4b8907d323619bc9c73076b3 (diff) | |
download | gcc-7955b06580a73bd6ad0d744928ab4775e4723c78.zip gcc-7955b06580a73bd6ad0d744928ab4775e4723c78.tar.gz gcc-7955b06580a73bd6ad0d744928ab4775e4723c78.tar.bz2 |
configure.ac: Move pthread affinity test to the place where '-pthread' passed to CFLAGS.
libcilkrts/
* configure.ac: Move pthread affinity test to the place where
'-pthread' passed to CFLAGS. Otherwise the test always fails.
(XCFLAGS): New variable for correctly passing
'-pthread'.
(XLDFLAGS): New variable for passing the correct pthread lib.
* configure: Regenerate.
* Makefile.am (AM_CFLAGS): Add $XCFLAGS.
(AM_LDFLAGS): Add $XLDFLAGS.
* Makefile.in: Regenerate.
From-SVN: r213854
Diffstat (limited to 'libcilkrts/configure.ac')
-rw-r--r-- | libcilkrts/configure.ac | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/libcilkrts/configure.ac b/libcilkrts/configure.ac index fb21505..cc9a39f 100644 --- a/libcilkrts/configure.ac +++ b/libcilkrts/configure.ac @@ -164,6 +164,27 @@ AC_SUBST(toolexeclibdir) AC_SUBST(lt_cv_dlopen_libs) +# Check to see if -pthread or -lpthread is needed. Prefer the former. +# Note that the CILK_SELF_SPEC in gcc.c may force -pthread. +# In case the pthread.h system header is not found, this test will fail. +XCFLAGS="" +XLDFLAGS="" +CFLAGS="$CFLAGS -pthread" +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include <pthread.h> + void *g(void *d) { return NULL; }], + [pthread_t t; pthread_create(&t,NULL,g,NULL);])], + [XCFLAGS=" -Wc,-pthread"], + [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include <pthread.h> + void *g(void *d) { return NULL; }], + [pthread_t t; pthread_create(&t,NULL,g,NULL);])], + [], + [AC_MSG_ERROR([Pthreads are required to build libcilkrts])])]) + # Check for pthread_{,attr_}[sg]etaffinity_np. AC_LINK_IFELSE( [AC_LANG_PROGRAM( @@ -183,24 +204,24 @@ AC_LINK_IFELSE( AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1, [ Define if pthread_{,attr_}{g,s}etaffinity_np is supported.])) -# Check to see if -pthread or -lpthread is needed. Prefer the former. -# Note that the CILK_SELF_SPEC in gcc.c may force -pthread. -# In case the pthread.h system header is not found, this test will fail. -CFLAGS="$CFLAGS -pthread" -AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [#include <pthread.h> - void *g(void *d) { return NULL; }], - [pthread_t t; pthread_create(&t,NULL,g,NULL);])], - [], - [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [#include <pthread.h> - void *g(void *d) { return NULL; }], - [pthread_t t; pthread_create(&t,NULL,g,NULL);])], - [], - [AC_MSG_ERROR([Pthreads are required to build libcilkrts])])]) +# Every c++ lib is linking by default with -nostdlib, which leads to the +# fact, that proper pthread library will not be given at link time. We have +# to hard-code that. +case "${target}" in + + *android*) + XLDFLAGS="$XLDFLAGS -lc" + ;; + *) + XLDFLAGS="$XLDFLAGS -lpthread" + ;; + +esac + +AC_SUBST(XCFLAGS) +AC_SUBST(XLDFLAGS) + +CFLAGS="$save_CFLAGS" if test $enable_shared = yes; then link_cilkrts="-lcilkrts %{static: $LIBS}" |