From patchwork Tue Mar 25 23:28:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 333746 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6D5D0140091 for ; Wed, 26 Mar 2014 10:28:15 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=Nz9x176iuv+XW9OkL iWH5TtAiO3QoUAv/rOLQ1zkkgcOBky25Luplkc7c6pW/av8L4KA/RVn2CX3HhS2k BQxZFHgOManthpWKdGvm4Tetx7j8qbajYoQSmLJU71p4MH3fpXafyX0mK7nBbRNK 3ieSNGBO/EI6h8jIL81Srm616s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=gv6TrfN8l9PlE3RcTwKsn5g 0/KA=; b=MJLW0uSTgf0To5T4GdsYteJczL8YzA6gyfCCGm3DZaA8x0Fa1QgDKH4 AChf8gNNdGsUSc4tvZLh/5V9nfBSZ/GD/XdsToweUB095bsyxXIwKx3Lokepvfre jqPIwYJWjSW06IU/jqDUz0REzv+j9hyQd6dCzBjDBIz5qjQ4ZTx4= Received: (qmail 9031 invoked by alias); 25 Mar 2014 23:28:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 9018 invoked by uid 89); 25 Mar 2014 23:28:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx01.qsc.de Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 25 Mar 2014 23:28:04 +0000 Received: from tux.net-b.de (port-92-194-244-210.dynamic.qsc.de [92.194.244.210]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPSA id 1C2CB3CF74; Wed, 26 Mar 2014 00:28:01 +0100 (CET) Message-ID: <53321100.5010904@net-b.de> Date: Wed, 26 Mar 2014 00:28:00 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Paolo Bonzini , gcc-patches , "Iyer, Balaji V" , "Joseph S. Myers" Subject: Re: [Build, Driver] Add -lcilkrts for -fcilkplus References: <531EB05C.8060603@net-b.de> <5331A583.6010507@gnu.org> In-Reply-To: <5331A583.6010507@gnu.org> 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 * 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 + 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 + 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@