Paolo Bonzini wrote:
Il 11/03/2014 07:42, Tobias Burnus ha scritto:
+XPCFLAGS=""
+CFLAGS="$CFLAGS -pthread"
+AC_LINK_IFELSE(
...
+ [XPCFLAGS=" -Wc,-pthread"],
XPCFLAGS is dead, I think?
Yes - contrary to libgomp, from which I have taken that code block. I
have now removed it.
Also, should -pthread be included in the spec too?
Regarding -pthreads: That should already be included via gcc/gcc.c:
+#define CILK_SELF_SPECS "%{fcilkplus: -pthread}"
static const char *const driver_self_specs[] = {
...
CILK_SELF_SPECS
};
Updated patch below (nongenerated libcilkrts only).
Tobias
2014-03-24 Tobias Burnus <bur...@net-b.de>
* libcilkrts.spec.in: New.
* Makefile.am: Handle libcilkrts.spec.
* configure.ac: Determine link options for libcilkrts.spec.
* Makefile.in: Regenerate.
* configure: Regenerate.
diff --git a/libcilkrts/Makefile.am b/libcilkrts/Makefile.am
index f2d13aa..84551c8 100644
--- a/libcilkrts/Makefile.am
+++ b/libcilkrts/Makefile.am
@@ -51,6 +51,7 @@ AM_LDFLAGS = -lpthread
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
# Target list.
+nodist_toolexeclib_HEADERS = libcilkrts.spec
toolexeclib_LTLIBRARIES = libcilkrts.la
libcilkrts_la_SOURCES = \
diff --git a/libcilkrts/configure.ac b/libcilkrts/configure.ac
index 61b45b0..fb21505 100644
--- a/libcilkrts/configure.ac
+++ b/libcilkrts/configure.ac
@@ -49,7 +49,7 @@ AC_PROG_CC
AC_PROG_CXX
# AC_PROG_LIBTOOL
# AC_CONFIG_MACRO_DIR([..])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile libcilkrts.spec])
AM_ENABLE_MULTILIB(, ..)
AC_FUNC_ALLOCA
@@ -183,6 +183,32 @@ 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])])])
+
+if test $enable_shared = yes; then
+ link_cilkrts="-lcilkrts %{static: $LIBS}"
+else
+ link_cilkrts="-lcilkrts $LIBS"
+fi
+AC_SUBST(link_cilkrts)
+
# Must be last
AC_OUTPUT
diff --git a/libcilkrts/libcilkrts.spec.in b/libcilkrts/libcilkrts.spec.in
new file mode 100644
index 0000000..b98cce9
--- /dev/null
+++ b/libcilkrts/libcilkrts.spec.in
@@ -0,0 +1,3 @@
+# This spec file is read by gcc when linking. It is used to specify the
+# standard libraries we need in order to link with libcilkrts.
+*link_cilkrts: @link_cilkrts@