From patchwork Thu Nov 25 11:11:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 73040 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]) by ozlabs.org (Postfix) with SMTP id 38DD0B70A9 for ; Thu, 25 Nov 2010 22:14:02 +1100 (EST) Received: (qmail 12454 invoked by alias); 25 Nov 2010 11:11:48 -0000 Received: (qmail 12274 invoked by uid 22791); 25 Nov 2010 11:11:39 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_BG, TW_IB, TW_LG X-Spam-Check-By: sourceware.org Received: from c2beaomr10.btconnect.com (HELO mail.btconnect.com) (213.123.26.188) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 25 Nov 2010 11:11:30 +0000 Received: from host81-138-1-83.in-addr.btopenworld.com (EHLO thor.office) ([81.138.1.83]) by c2beaomr10.btconnect.com with ESMTP id ATY50414; Thu, 25 Nov 2010 11:11:18 +0000 (GMT) Cc: gfortran , GCC Patches , Michael Matz , FX , Mike Stump Message-Id: <8F247BFC-9228-4058-A27A-6EA907FA9BBA@sandoe-acoustics.co.uk> From: IainS To: Tobias Burnus In-Reply-To: <4CEA1B9D.7050702@net-b.de> Mime-Version: 1.0 (Apple Message framework v936) Subject: Additional RFC, Re: RFC automatic linkage of libquadmath with gfortran: PR driver/46516; libgfortran.spec, multilib search path Date: Thu, 25 Nov 2010 11:11:01 +0000 References: <4CE80CA9.9050205@net-b.de> <4CE8229E.9050600@net-b.de> <4CE8D295.5040606@net-b.de> <4CEA1B9D.7050702@net-b.de> X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0301.4CEE4446.032F, actions=tag X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0206.4CEE445F.010E, ss=1, fgs=0, ip=0.0.0.0, so=2010-07-22 22:03:31, dmn=2009-09-10 00:05:08, mode=single engine X-IsSubscribed: yes 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 Hello all... On 22 Nov 2010, at 07:28, Tobias Burnus wrote: > On 11/22/2010 12:07 AM, Michael Matz wrote: >> I have another improvement here. I'm regularly testing uninstalled >> compilers (or compilers installed in temp paths). This exposed a >> problem >> in that the .spec file is only found when the proper -L option is >> given >> (that's okay), which it usually isn't for non-linking commands. In >> that >> case lang_specific_pre_link is nevertheless called, tries to include >> libgfortran.spec and fails. Hence, let's remember if we're in a >> non-link >> run, and not do anything with that .spec file. >> >> Regstrapping on x86_64-linux in progress. Okay if that passes? > > OK. Thanks for the patch! I have some requested additions (for Darwin), but also some observations/suggestions... Firstly, when one hijacks *lib, it means that the target has no chance to do spec substitutions/outfile removal -- this is because the new libs are added after "output files" have been evaluated in the LINK_COMMAND. -- because libs are not treated as switches, one cannot switch on them either So that means that we must ensure: (a) that we don't add any libs that the target doesn't want (b) if there are any substitutions, unfortunately they need to appear in the libgfortran spec - since we can't hide them away in the target LINK_COMMAND if test -f ../libquadmath/libquadmath.la; then LIBQUADLIB=../libquadmath/libquadmath.la ==== Thoughts? OK for trunk? (tested on *-darwin9, and x86_64-unk-linux) cheers, Iain ==== Firstly, I wonder if it would be better to hijack the "*link_gcc_c_sequence" rather than "*lib" (this means that the correct link sequence for libgcc/lc will follow directly after the libgfortran/libquadmath sequence . ... which also means one doesn't have to embed any differences in the way targets make that sequence) like this: =================================================================== --- libgfortran/libgfortran.spec.in (revision 167142) +++ libgfortran/libgfortran.spec.in (working copy) @@ -2,7 +2,10 @@ # This spec file is read by gfortran when linking. # It is used to specify the libraries we need to link in, in the right # order. -# -%rename lib liborig -*lib: @LIBQUADSPEC@ -lm %(libgcc) %(liborig) +# Hijack the link sequence for libgcc and lc so that we can interpose +# the quad math and system math libs just before it. This also works for +# targets that only link lgcc once. + +%rename link_gcc_c_sequence link_gcc_c_sequence_orig +*link_gcc_c_sequence: @LIBQUADSPEC@ @LIBMSPEC@ % (link_gcc_c_sequence_orig) If that's not OK - then we need to suppress the additional %(libgcc) for darwin too. NOTE; I think that if we do this we can lose all the libm agonizing from gfortranspec.c - because the libgfortan.spec will automatically place "-lm" just before the libgcc/lc sequence for targets that require it. (If the user inserts a '-lm' by hand we should just pass that through - on the assumption that the user knows what (s)he is doing). ----- Secondly to cater for Darwin (and any other target that doesn't want - lm unconditionally); (plus our spec substitution for the static case) Index: libgfortran/configure.ac =================================================================== --- libgfortran/configure.ac (revision 167142) +++ libgfortran/configure.ac (working copy) @@ -515,6 +515,17 @@ else multilib_arg= fi +# Allow for targets which don't need/want -lm. +case "${host}" in + *-darwin*) + LIBMSPEC= + ;; + *) + LIBMSPEC="-lm" + ;; +esac +AC_SUBST(LIBMSPEC) + # Write our Makefile and spec file. AC_CONFIG_FILES([ Makefile Index: libgfortran/acinclude.m4 =================================================================== --- libgfortran/acinclude.m4 (revision 167142) +++ libgfortran/acinclude.m4 (working copy) @@ -329,7 +329,10 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [ if test "x$libgfor_cv_have_as_needed" = xyes; then LIBQUADSPEC="%{static-libgfortran:--as-needed} -lquadmath % {static-libgfortran:--no-as-needed}" else - LIBQUADSPEC="-lquadmath" + case "${target}" in + *86*-*-darwin*) LIBQUADSPEC="%{static|static-libgcc|static- libgfortran: libquadmath.a%s; : -lquadmath}" ;; + *) LIBQUADSPEC="-lquadmath" ;; + esac fi