diff mbox

[Build,Driver] Add -lcilkrts for -fcilkplus

Message ID 531EB05C.8060603@net-b.de
State New
Headers show

Commit Message

Tobias Burnus March 11, 2014, 6:42 a.m. UTC
When using Cilk Plus (-fcilkplus), it makes sense to automatically link 
the run-time library (-lcilkrts).

This patch mimics libgomp by adding a .spec file; I am not 100% sure 
whether the .spec file is needed, but the pthread tests in libgomp imply 
that it makes sense. (libgomp also checks for -lrt for the 
high-performance timers, a check which is not required for libcilkrts.)

Bootstrapped on x86-64-gnu-linux.
OK for the trunk?

Tobias

Comments

Joseph Myers March 11, 2014, 5:51 p.m. UTC | #1
On Tue, 11 Mar 2014, Tobias Burnus wrote:

> When using Cilk Plus (-fcilkplus), it makes sense to automatically link the
> run-time library (-lcilkrts).
> 
> This patch mimics libgomp by adding a .spec file; I am not 100% sure whether
> the .spec file is needed, but the pthread tests in libgomp imply that it makes
> sense. (libgomp also checks for -lrt for the high-performance timers, a check
> which is not required for libcilkrts.)
> 
> Bootstrapped on x86-64-gnu-linux.
> OK for the trunk?

The driver changes are OK.
Tobias Burnus March 16, 2014, 1:05 p.m. UTC | #2
PING for the build part; Joseph has already approved the driver part.

Tobias Burnus wrote:
> When using Cilk Plus (-fcilkplus), it makes sense to automatically 
> link the run-time library (-lcilkrts).
>
> This patch mimics libgomp by adding a .spec file; I am not 100% sure 
> whether the .spec file is needed, but the pthread tests in libgomp 
> imply that it makes sense. (libgomp also checks for -lrt for the 
> high-performance timers, a check which is not required for libcilkrts.)
>
> Bootstrapped on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias
Tobias Burnus March 24, 2014, 9:16 p.m. UTC | #3
*PING* for the build part as the driver part has been already approved.
http://gcc.gnu.org/ml/gcc-patches/2014-03/msg00492.html

Also pinging another one-line libcilkrts/Makefile.am patch: 
http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01111.html

On March 11, 2014, Tobias Burnus wrote:
> When using Cilk Plus (-fcilkplus), it makes sense to automatically 
> link the run-time library (-lcilkrts).
>
> This patch mimics libgomp by adding a .spec file; I am not 100% sure 
> whether the .spec file is needed, but the pthread tests in libgomp 
> imply that it makes sense. (libgomp also checks for -lrt for the 
> high-performance timers, a check which is not required for libcilkrts.)
>
> Bootstrapped on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias
Paolo Bonzini March 25, 2014, 3:49 p.m. UTC | #4
Il 11/03/2014 07:42, Tobias Burnus ha scritto:
>
> +# Check to see if -pthread or -lpthread is needed.  Prefer the former.
> +# In case the pthread.h system header is not found, this test will fail.
> +XPCFLAGS=""
> +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);])],
> + [XPCFLAGS=" -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])])])
> +

XPCFLAGS is dead, I think?

Also, should -pthread be included in the spec too?

Paolo
H.J. Lu March 26, 2014, 9:53 p.m. UTC | #5
On Mon, Mar 10, 2014 at 11:42 PM, Tobias Burnus <burnus@net-b.de> wrote:
> When using Cilk Plus (-fcilkplus), it makes sense to automatically link the
> run-time library (-lcilkrts).
>
> This patch mimics libgomp by adding a .spec file; I am not 100% sure whether
> the .spec file is needed, but the pthread tests in libgomp imply that it
> makes sense. (libgomp also checks for -lrt for the high-performance timers,
> a check which is not required for libcilkrts.)
>
> Bootstrapped on x86-64-gnu-linux.
> OK for the trunk?
>

All cilk-plus link tests failed with

xgcc: error: libcilkrts.spec: No such file or directory

Don't you need to add -B............/libcilkrts for this?
Tobias Burnus March 26, 2014, 10:35 p.m. UTC | #6
H.J. Lu wrote:
> All cilk-plus link tests failed with
> xgcc: error: libcilkrts.spec: No such file or directory
> Don't you need to add -B............/libcilkrts for this?

Hmm, I really wonder why it fails for you while it works for me:

Running 
/home/tob/projects/gcc/gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp ...
                 === gcc Summary ===
# of expected passes            1934
Running 
/home/tob/projects/gcc/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp ...
                 === g++ Summary ===
# of expected passes            1906
# of unsupported tests          37


I cross-checked: I have the installed version not in the $PATH or 
$LD_LIBRARY_PATH. And your version is r208851, which has my spec file, 
which I initially (r208851) missed: 
http://gcc.gnu.org/ml/gcc-testresults/2014-03/msg01965.html

Tobias
H.J. Lu March 26, 2014, 10:40 p.m. UTC | #7
On Wed, Mar 26, 2014 at 3:35 PM, Tobias Burnus <burnus@net-b.de> wrote:
> H.J. Lu wrote:
>>
>> All cilk-plus link tests failed with
>> xgcc: error: libcilkrts.spec: No such file or directory
>> Don't you need to add -B............/libcilkrts for this?
>
>
> Hmm, I really wonder why it fails for you while it works for me:
>
> Running /home/tob/projects/gcc/gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp
> ...
>                 === gcc Summary ===
> # of expected passes            1934
> Running /home/tob/projects/gcc/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp
> ...
>                 === g++ Summary ===
> # of expected passes            1906
> # of unsupported tests          37
>
>
> I cross-checked: I have the installed version not in the $PATH or
> $LD_LIBRARY_PATH. And your version is r208851, which has my spec file, which
> I initially (r208851) missed:
> http://gcc.gnu.org/ml/gcc-testresults/2014-03/msg01965.html
>

I got

spawn -ignore SIGHUP
/export/gnu/import/git/gcc-test-ia32corei7/bld/gcc/xgcc
-B/export/gnu/import/git/gcc-test-ia32corei7/bld/gcc/
/export/gnu/import/git/gcc-test-ia32corei7/src-trunk/gcc/testsuite/c-c++-common/cilk-plus/PS/reduction-1.c
-fno-diagnostics-show-caret -fdiagnostics-color=never -ftree-vectorize
-fcilkplus -std=c99 -O3 -fcilkplus
-L/export/gnu/import/git/gcc-test-ia32corei7/bld/i686-linux/./libcilkrts/.libs
-lm -o ./reduction-1.exe^M
xgcc: error:l libcikrts.spec: No such file or directory^M
compiler exited with status 1

Can you find where your tests get libcilkrts.spec?
Rainer Orth March 26, 2014, 10:48 p.m. UTC | #8
Tobias Burnus <burnus@net-b.de> writes:

> H.J. Lu wrote:
>> All cilk-plus link tests failed with
>> xgcc: error: libcilkrts.spec: No such file or directory
>> Don't you need to add -B............/libcilkrts for this?
>
> Hmm, I really wonder why it fails for you while it works for me:
[...]
> I cross-checked: I have the installed version not in the $PATH or
> $LD_LIBRARY_PATH. And your version is r208851, which has my spec file,
> which I initially (r208851) missed:
> http://gcc.gnu.org/ml/gcc-testresults/2014-03/msg01965.html

Do you happen to have the same/a recent version installed at the same
prefix your build under test is configured for?  In that case, it's
likely that libcilkrts.spec is picked up from there.

For reasons like this, I usually configure test builds with a prefix
where no gcc is installed, so I can guarantee I really test the freshly
built version and not a mix.

	Rainer
diff mbox

Patch

diff --git a/libcilkrts/Makefile.in b/libcilkrts/Makefile.in
index 706a0da..4439292 100644
--- a/libcilkrts/Makefile.in
+++ b/libcilkrts/Makefile.in
@@ -112,8 +112,8 @@  target_triplet = @target@
 DIST_COMMON = $(srcdir)/include/internal/rev.mk README ChangeLog \
 	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(top_srcdir)/configure $(am__configure_deps) \
-	$(srcdir)/../mkinstalldirs $(srcdir)/../depcomp \
-	$(cilkinclude_HEADERS)
+	$(srcdir)/../mkinstalldirs $(srcdir)/libcilkrts.spec.in \
+	$(srcdir)/../depcomp $(cilkinclude_HEADERS)
 
 # If we're building on Linux, use the Linux version script
 @LINUX_LINKER_SCRIPT_TRUE@am__append_1 = -Wl,--version-script,$(srcdir)/runtime/linux-symbols.ver
@@ -134,7 +134,7 @@  am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = libcilkrts.spec
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
@@ -158,7 +158,8 @@  am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
 am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \
-	"$(DESTDIR)$(cilkincludedir)" "$(DESTDIR)$(cilkincludedir)"
+	"$(DESTDIR)$(cilkincludedir)" "$(DESTDIR)$(cilkincludedir)" \
+	"$(DESTDIR)$(toolexeclibdir)"
 LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
 libcilkrts_la_LIBADD =
 am_libcilkrts_la_OBJECTS = cilk-abi-vla.lo os-unix-sysdep.lo bug.lo \
@@ -202,7 +203,8 @@  MULTIDIRS =
 MULTISUBDIR = 
 MULTIDO = true
 MULTICLEAN = true
-HEADERS = $(cilkinclude_HEADERS) $(nodist_cilkinclude_HEADERS)
+HEADERS = $(cilkinclude_HEADERS) $(nodist_cilkinclude_HEADERS) \
+	$(nodist_toolexeclib_HEADERS)
 ETAGS = etags
 CTAGS = ctags
 ACLOCAL = @ACLOCAL@
@@ -306,6 +308,7 @@  infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
+link_cilkrts = @link_cilkrts@
 localedir = @localedir@
 localstatedir = @localstatedir@
 lt_cv_dlopen_libs = @lt_cv_dlopen_libs@
@@ -356,6 +359,7 @@  cilkincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include/cilk
 
 # Target list.
 toolexeclib_LTLIBRARIES = libcilkrts.la
+nodist_toolexeclib_HEADERS = libcilkrts.spec
 nodist_cilkinclude_HEADERS = include/cilk/cilk.h
 libcilkrts_la_SOURCES = \
   runtime/config/$(config_dir)/cilk-abi-vla.c           \
@@ -501,6 +505,8 @@  $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 $(am__aclocal_m4_deps):
+libcilkrts.spec: $(top_builddir)/config.status $(srcdir)/libcilkrts.spec.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
 install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
 	test -z "$(toolexeclibdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)"
@@ -889,6 +895,26 @@  uninstall-nodist_cilkincludeHEADERS:
 	test -n "$$files" || exit 0; \
 	echo " ( cd '$(DESTDIR)$(cilkincludedir)' && rm -f" $$files ")"; \
 	cd "$(DESTDIR)$(cilkincludedir)" && rm -f $$files
+install-nodist_toolexeclibHEADERS: $(nodist_toolexeclib_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(toolexeclibdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)"
+	@list='$(nodist_toolexeclib_HEADERS)'; test -n "$(toolexeclibdir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(toolexeclibdir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(toolexeclibdir)" || exit $$?; \
+	done
+
+uninstall-nodist_toolexeclibHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(nodist_toolexeclib_HEADERS)'; test -n "$(toolexeclibdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(toolexeclibdir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(toolexeclibdir)" && rm -f $$files
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@@ -945,7 +971,7 @@  check-am: all-am
 check: check-am
 all-am: Makefile $(LTLIBRARIES) all-multi $(HEADERS)
 installdirs:
-	for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(cilkincludedir)" "$(DESTDIR)$(cilkincludedir)"; do \
+	for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(cilkincludedir)" "$(DESTDIR)$(cilkincludedir)" "$(DESTDIR)$(toolexeclibdir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: install-am
@@ -1004,7 +1030,8 @@  install-dvi: install-dvi-am
 
 install-dvi-am:
 
-install-exec-am: install-multi install-toolexeclibLTLIBRARIES
+install-exec-am: install-multi install-nodist_toolexeclibHEADERS \
+	install-toolexeclibLTLIBRARIES
 
 install-html: install-html-am
 
@@ -1048,6 +1075,7 @@  ps-am:
 
 uninstall-am: uninstall-cilkincludeHEADERS \
 	uninstall-nodist_cilkincludeHEADERS \
+	uninstall-nodist_toolexeclibHEADERS \
 	uninstall-toolexeclibLTLIBRARIES
 
 .MAKE: all-multi clean-multi distclean-multi install-am install-multi \
@@ -1062,7 +1090,8 @@  uninstall-am: uninstall-cilkincludeHEADERS \
 	install-data-am install-dvi install-dvi-am install-exec \
 	install-exec-am install-html install-html-am install-info \
 	install-info-am install-man install-multi \
-	install-nodist_cilkincludeHEADERS install-pdf install-pdf-am \
+	install-nodist_cilkincludeHEADERS \
+	install-nodist_toolexeclibHEADERS install-pdf install-pdf-am \
 	install-ps install-ps-am install-strip \
 	install-toolexeclibLTLIBRARIES installcheck installcheck-am \
 	installdirs maintainer-clean maintainer-clean-generic \
@@ -1071,6 +1100,7 @@  uninstall-am: uninstall-cilkincludeHEADERS \
 	pdf-am ps ps-am tags uninstall uninstall-am \
 	uninstall-cilkincludeHEADERS \
 	uninstall-nodist_cilkincludeHEADERS \
+	uninstall-nodist_toolexeclibHEADERS \
 	uninstall-toolexeclibLTLIBRARIES
 
 
diff --git a/libcilkrts/configure b/libcilkrts/configure
index 63181d7..cf7649c 100644
--- a/libcilkrts/configure
+++ b/libcilkrts/configure
@@ -604,6 +604,7 @@  ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+link_cilkrts
 lt_cv_dlopen_libs
 toolexeclibdir
 toolexecdir
@@ -4214,7 +4215,7 @@  fi
 
 # AC_PROG_LIBTOOL
 # AC_CONFIG_MACRO_DIR([..])
-ac_config_files="$ac_config_files Makefile"
+ac_config_files="$ac_config_files Makefile libcilkrts.spec"
 
 # Default to --enable-multilib
 # Check whether --enable-multilib was given.
@@ -11056,7 +11057,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11059 "configure"
+#line 11060 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11162,7 +11163,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11165 "configure"
+#line 11166 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14451,6 +14452,60 @@  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.
+# In case the pthread.h system header is not found, this test will fail.
+XPCFLAGS=""
+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 :
+  XPCFLAGS=" -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
+
+# Set up the set of libraries that we need to link against for libcilkrts.
+# Note that the CILK_SELF_SPEC in gcc.c may force -pthread,
+# which will force linkage against -lpthread (or equivalent for the system).
+# That's not 100% ideal, but about the best we can do easily.
+if test $enable_shared = yes; then
+  link_cilkrts="-lcilkrts %{static: $LIBS}"
+else
+  link_cilkrts="-lcilkrts $LIBS"
+fi
+
+
 
 # Must be last
 cat >confcache <<\_ACEOF
@@ -15567,6 +15622,7 @@  do
   case $ac_config_target in
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "libcilkrts.spec") CONFIG_FILES="$CONFIG_FILES libcilkrts.spec" ;;
     "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;