From patchwork Sat Nov 20 19:33:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 72360 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 A3318B7157 for ; Sun, 21 Nov 2010 06:34:04 +1100 (EST) Received: (qmail 8273 invoked by alias); 20 Nov 2010 19:34:01 -0000 Received: (qmail 8250 invoked by uid 22791); 20 Nov 2010 19:33:59 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_IB X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 20 Nov 2010 19:33:53 +0000 Received: from [192.168.178.22] (port-92-204-76-125.dynamic.qsc.de [92.204.76.125]) by mx01.qsc.de (Postfix) with ESMTP id C53ED3DF84; Sat, 20 Nov 2010 20:33:50 +0100 (CET) Message-ID: <4CE8229E.9050600@net-b.de> Date: Sat, 20 Nov 2010 20:33:50 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.12) Gecko/20101026 SUSE/3.1.6 Thunderbird/3.1.6 MIME-Version: 1.0 To: Michael Matz CC: gcc patches , "Joseph S. Myers" , Jakub Jelinek , gfortran Subject: Re: RFC automatic linkage of libquadmath with gfortran: PR driver/46516; libgfortran.spec, multilib search path References: <4CE80CA9.9050205@net-b.de> In-Reply-To: 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 Michael Matz wrote: > Oh right. I didn't consider that the lang-specs.h files are all included > together, and not just for the lang-specific driver :-/ > > There's currently one language specific hook coming right before linking > that you might be able to use: lang_specific_pre_link(). It might work if > you just do 'do_spec ("%:include(libgfortran.spec)")' in there (with the > current contents of libgfortran.spec, i.e. replacing '*lib:') in case > libgfortran.spec wasn't found in one of the -L paths in > lang_specific_driver() function (that is, you'll have to remember state > from lang_specific_driver to lang_specific_pre_link). Awesome! The attached patch seems to work as it should! I will do some bootstrapping tests, but I think should be fine. Assuming that no issue pops up: Is this patch OK for committal? Tobias diff --git a/gcc/fortran/gfortranspec.c b/gcc/fortran/gfortranspec.c index 24c9093..d8d9fc2 100644 --- a/gcc/fortran/gfortranspec.c +++ b/gcc/fortran/gfortranspec.c @@ -75,6 +75,9 @@ static void append_arg (const struct cl_decoded_option *); static unsigned int g77_newargc; static struct cl_decoded_option *g77_new_decoded_options; +/* The path to the spec file. */ +char *spec_file = NULL; + /* Return full path name of spec file if it is in DIR, or NULL if not. */ @@ -223,9 +226,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* Whether we should link a static libgfortran. */ int static_lib = 0; - /* The path to the spec file. */ - char *spec_file = NULL; - /* Whether we need to link statically. */ int static_linking = 0; @@ -447,9 +447,10 @@ For more information about these matters, see the file named COPYING\n\n")); #endif /* Read the specs file corresponding to libgfortran. - If we didn't find the spec file on the -L path, then we hope it - is somewhere in the standard install areas. */ - append_option (OPT_specs_, spec_file == NULL ? SPEC_FILE : spec_file, 1); + If we didn't find the spec file on the -L path, we load it + via lang_specific_pre_link. */ + if (spec_file) + append_option (OPT_specs_, spec_file, 1); if (verbose && g77_new_decoded_options != g77_x_decoded_options) { @@ -467,8 +468,13 @@ For more information about these matters, see the file named COPYING\n\n")); /* Called before linking. Returns 0 on success and -1 on failure. */ int -lang_specific_pre_link (void) /* Not used for F77. */ +lang_specific_pre_link (void) { + if (spec_file) + free (spec_file); + else + do_spec ("%:include(libgfortran.spec)"); + return 0; }