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
This commit is contained in:
Alexander Ivchenko 2014-08-12 11:06:44 +00:00 committed by Kirill Yukhin
parent 5435176b31
commit 7955b06580
5 changed files with 126 additions and 68 deletions

View File

@ -1,3 +1,15 @@
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> 2014-05-21 John Marino <gnugcc@marino.st>
* runtime/os-unix.c (__DragonFly__): New target. * runtime/os-unix.c (__DragonFly__): New target.

View File

@ -43,9 +43,9 @@ GENERAL_FLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/runtime -I$(top_srcdir)/
# Enable Intel Cilk Plus extension # Enable Intel Cilk Plus extension
GENERAL_FLAGS += -fcilkplus GENERAL_FLAGS += -fcilkplus
AM_CFLAGS = $(GENERAL_FLAGS) -std=c99 AM_CFLAGS = $(XCFLAGS) $(GENERAL_FLAGS) -std=c99
AM_CPPFLAGS = $(GENERAL_FLAGS) AM_CPPFLAGS = $(GENERAL_FLAGS)
AM_LDFLAGS = -lpthread AM_LDFLAGS = $(XLDFLAGS)
# May be used by toolexeclibdir. # May be used by toolexeclibdir.
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
@ -92,7 +92,8 @@ include include/internal/rev.mk
#libcilkrts_la_LDFLAGS = -rpath '$(libdir)' #libcilkrts_la_LDFLAGS = -rpath '$(libdir)'
libcilkrts_la_LDFLAGS = -version-info 5:0:0 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 we're building on Linux, use the Linux version script
if LINUX_LINKER_SCRIPT if LINUX_LINKER_SCRIPT

View File

@ -270,6 +270,8 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@ SHELL = @SHELL@
STRIP = @STRIP@ STRIP = @STRIP@
VERSION = @VERSION@ VERSION = @VERSION@
XCFLAGS = @XCFLAGS@
XLDFLAGS = @XLDFLAGS@
abs_builddir = @abs_builddir@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@ abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@ abs_top_builddir = @abs_top_builddir@
@ -344,9 +346,9 @@ ACLOCAL_AMFLAGS = -I .. -I ../config
GENERAL_FLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/runtime \ GENERAL_FLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/runtime \
-I$(top_srcdir)/runtime/config/$(config_dir) \ -I$(top_srcdir)/runtime/config/$(config_dir) \
-DIN_CILK_RUNTIME=1 -fcilkplus -DIN_CILK_RUNTIME=1 -fcilkplus
AM_CFLAGS = $(GENERAL_FLAGS) -std=c99 AM_CFLAGS = $(XCFLAGS) $(GENERAL_FLAGS) -std=c99
AM_CPPFLAGS = $(GENERAL_FLAGS) AM_CPPFLAGS = $(GENERAL_FLAGS)
AM_LDFLAGS = -lpthread AM_LDFLAGS = $(XLDFLAGS)
# May be used by toolexeclibdir. # May be used by toolexeclibdir.
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
@ -393,9 +395,8 @@ CILK_REVISION = 3902
#libcilkrts_la_LDFLAGS = -rpath '$(libdir)' #libcilkrts_la_LDFLAGS = -rpath '$(libdir)'
# Hack for Cygwin # Hack for Cygwin
libcilkrts_la_LDFLAGS = -version-info 5:0:0 -lpthread \ libcilkrts_la_LDFLAGS = -version-info 5:0:0 @lt_cv_dlopen_libs@ \
@lt_cv_dlopen_libs@ $(am__append_1) $(am__append_2) \ $(AM_LDFLAGS) $(am__append_1) $(am__append_2) -no-undefined
-no-undefined
# C/C++ header files for Cilk. # C/C++ header files for Cilk.
# cilkincludedir = $(includedir)/cilk # cilkincludedir = $(includedir)/cilk

107
libcilkrts/configure vendored
View File

@ -605,6 +605,8 @@ am__EXEEXT_TRUE
LTLIBOBJS LTLIBOBJS
LIBOBJS LIBOBJS
link_cilkrts link_cilkrts
XLDFLAGS
XCFLAGS
lt_cv_dlopen_libs lt_cv_dlopen_libs
toolexeclibdir toolexeclibdir
toolexecdir toolexecdir
@ -11057,7 +11059,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 11060 "configure" #line 11062 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -11163,7 +11165,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 11166 "configure" #line 11168 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -14421,6 +14423,51 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# 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. */
#include <pthread.h>
void *g(void *d) { return NULL; }
int
main ()
{
pthread_t t; pthread_create(&t,NULL,g,NULL);
;
return 0;
}
_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
/* end confdefs.h. */
#include <pthread.h>
void *g(void *d) { return NULL; }
int
main ()
{
pthread_t t; pthread_create(&t,NULL,g,NULL);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
else
as_fn_error "Pthreads are required to build libcilkrts" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
# Check for pthread_{,attr_}[sg]etaffinity_np. # Check for pthread_{,attr_}[sg]etaffinity_np.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -14452,48 +14499,24 @@ fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
# Check to see if -pthread or -lpthread is needed. Prefer the former. # Every c++ lib is linking by default with -nostdlib, which leads to the
# Note that the CILK_SELF_SPEC in gcc.c may force -pthread. # fact, that proper pthread library will not be given at link time. We have
# In case the pthread.h system header is not found, this test will fail. # to hard-code that.
CFLAGS="$CFLAGS -pthread" case "${target}" in
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <pthread.h>
void *g(void *d) { return NULL; }
int
main ()
{
pthread_t t; pthread_create(&t,NULL,g,NULL);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
else *android*)
CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" XLDFLAGS="$XLDFLAGS -lc"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext ;;
/* end confdefs.h. */ *)
#include <pthread.h> XLDFLAGS="$XLDFLAGS -lpthread"
void *g(void *d) { return NULL; } ;;
int
main ()
{
pthread_t t; pthread_create(&t,NULL,g,NULL);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
else esac
as_fn_error "Pthreads are required to build libcilkrts" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi CFLAGS="$save_CFLAGS"
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
if test $enable_shared = yes; then if test $enable_shared = yes; then
link_cilkrts="-lcilkrts %{static: $LIBS}" link_cilkrts="-lcilkrts %{static: $LIBS}"

View File

@ -164,6 +164,27 @@ AC_SUBST(toolexeclibdir)
AC_SUBST(lt_cv_dlopen_libs) 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. # Check for pthread_{,attr_}[sg]etaffinity_np.
AC_LINK_IFELSE( AC_LINK_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
@ -183,24 +204,24 @@ AC_LINK_IFELSE(
AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1, AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1,
[ Define if pthread_{,attr_}{g,s}etaffinity_np is supported.])) [ Define if pthread_{,attr_}{g,s}etaffinity_np is supported.]))
# Check to see if -pthread or -lpthread is needed. Prefer the former. # Every c++ lib is linking by default with -nostdlib, which leads to the
# Note that the CILK_SELF_SPEC in gcc.c may force -pthread. # fact, that proper pthread library will not be given at link time. We have
# In case the pthread.h system header is not found, this test will fail. # to hard-code that.
CFLAGS="$CFLAGS -pthread" case "${target}" in
AC_LINK_IFELSE(
[AC_LANG_PROGRAM( *android*)
[#include <pthread.h> XLDFLAGS="$XLDFLAGS -lc"
void *g(void *d) { return NULL; }], ;;
[pthread_t t; pthread_create(&t,NULL,g,NULL);])], *)
[], XLDFLAGS="$XLDFLAGS -lpthread"
[CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" ;;
AC_LINK_IFELSE(
[AC_LANG_PROGRAM( esac
[#include <pthread.h>
void *g(void *d) { return NULL; }], AC_SUBST(XCFLAGS)
[pthread_t t; pthread_create(&t,NULL,g,NULL);])], AC_SUBST(XLDFLAGS)
[],
[AC_MSG_ERROR([Pthreads are required to build libcilkrts])])]) CFLAGS="$save_CFLAGS"
if test $enable_shared = yes; then if test $enable_shared = yes; then
link_cilkrts="-lcilkrts %{static: $LIBS}" link_cilkrts="-lcilkrts %{static: $LIBS}"