+2014-08-01 Alexander Ivchenko <alexander.ivchenko@intel.com>
+
+ * 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.
+
2014-05-21 John Marino <gnugcc@marino.st>
* runtime/os-unix.c (__DragonFly__): New target.
# Enable Intel Cilk Plus extension
GENERAL_FLAGS += -fcilkplus
-AM_CFLAGS = $(GENERAL_FLAGS) -std=c99
+AM_CFLAGS = $(XCFLAGS) $(GENERAL_FLAGS) -std=c99
AM_CPPFLAGS = $(GENERAL_FLAGS)
-AM_LDFLAGS = -lpthread
+AM_LDFLAGS = $(XLDFLAGS)
# May be used by toolexeclibdir.
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
#libcilkrts_la_LDFLAGS = -rpath '$(libdir)'
libcilkrts_la_LDFLAGS = -version-info 5:0:0
-libcilkrts_la_LDFLAGS += -lpthread @lt_cv_dlopen_libs@
+libcilkrts_la_LDFLAGS += @lt_cv_dlopen_libs@
+libcilkrts_la_LDFLAGS += $(AM_LDFLAGS)
# If we're building on Linux, use the Linux version script
if LINUX_LINKER_SCRIPT
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
+XCFLAGS = @XCFLAGS@
+XLDFLAGS = @XLDFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
GENERAL_FLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/runtime \
-I$(top_srcdir)/runtime/config/$(config_dir) \
-DIN_CILK_RUNTIME=1 -fcilkplus
-AM_CFLAGS = $(GENERAL_FLAGS) -std=c99
+AM_CFLAGS = $(XCFLAGS) $(GENERAL_FLAGS) -std=c99
AM_CPPFLAGS = $(GENERAL_FLAGS)
-AM_LDFLAGS = -lpthread
+AM_LDFLAGS = $(XLDFLAGS)
# May be used by toolexeclibdir.
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
#libcilkrts_la_LDFLAGS = -rpath '$(libdir)'
# Hack for Cygwin
-libcilkrts_la_LDFLAGS = -version-info 5:0:0 -lpthread \
- @lt_cv_dlopen_libs@ $(am__append_1) $(am__append_2) \
- -no-undefined
+libcilkrts_la_LDFLAGS = -version-info 5:0:0 @lt_cv_dlopen_libs@ \
+ $(AM_LDFLAGS) $(am__append_1) $(am__append_2) -no-undefined
# C/C++ header files for Cilk.
# cilkincludedir = $(includedir)/cilk
LTLIBOBJS
LIBOBJS
link_cilkrts
+XLDFLAGS
+XCFLAGS
lt_cv_dlopen_libs
toolexeclibdir
toolexecdir
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11060 "configure"
+#line 11062 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11166 "configure"
+#line 11168 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-# Check for pthread_{,attr_}[sg]etaffinity_np.
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#define _GNU_SOURCE
- #include <pthread.h>
-int
-main ()
-{
-cpu_set_t cpuset;
- pthread_attr_t attr;
- pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
- if (CPU_ISSET (0, &cpuset))
- CPU_SET (1, &cpuset);
- else
- CPU_ZERO (&cpuset);
- pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
- pthread_attr_init (&attr);
- pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
- pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-$as_echo "#define HAVE_PTHREAD_AFFINITY_NP 1" >>confdefs.h
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
# 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"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
-
+ XCFLAGS=" -Wc,-pthread"
else
CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
+# Check for pthread_{,attr_}[sg]etaffinity_np.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _GNU_SOURCE
+ #include <pthread.h>
+int
+main ()
+{
+cpu_set_t cpuset;
+ pthread_attr_t attr;
+ pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+ if (CPU_ISSET (0, &cpuset))
+ CPU_SET (1, &cpuset);
+ else
+ CPU_ZERO (&cpuset);
+ pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+ pthread_attr_init (&attr);
+ pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
+ pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+$as_echo "#define HAVE_PTHREAD_AFFINITY_NP 1" >>confdefs.h
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+# 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
+
+
+
+
+CFLAGS="$save_CFLAGS"
+
if test $enable_shared = yes; then
link_cilkrts="-lcilkrts %{static: $LIBS}"
else
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(
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}"