summaryrefslogtreecommitdiff
path: root/libcilkrts/configure.ac
diff options
context:
space:
mode:
authorkyukhin <kyukhin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-12 11:06:44 +0000
committerkyukhin <kyukhin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-12 11:06:44 +0000
commit58f14deb9ba2f88e6bbed20d2f15feac3a699cd5 (patch)
tree158a00fe3e709b3e54e467d019bdf2029d24f729 /libcilkrts/configure.ac
parent7a093de906508a300c8e3e1706b3b112bf08428d (diff)
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@213854 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcilkrts/configure.ac')
-rw-r--r--libcilkrts/configure.ac57
1 files changed, 39 insertions, 18 deletions
diff --git a/libcilkrts/configure.ac b/libcilkrts/configure.ac
index fb215052dd63..cc9a39f0533d 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}"