From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2941 invoked by alias); 19 Mar 2007 20:06:15 -0000 Received: (qmail 2923 invoked by uid 22791); 19 Mar 2007 20:06:14 -0000 X-Spam-Check-By: sourceware.org Received: from palrel11.hp.com (HELO palrel11.hp.com) (156.153.255.246) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 19 Mar 2007 20:06:07 +0000 Received: from smtp1.cup.hp.com (smtp.cup.hp.com [15.4.32.117]) by palrel11.hp.com (Postfix) with ESMTP id 78A803514F; Mon, 19 Mar 2007 13:06:04 -0700 (PDT) Received: from hpsje.cup.hp.com (hpsje.cup.hp.com [16.89.92.85]) by smtp1.cup.hp.com (Postfix) with ESMTP id D3F7749BDC3; Mon, 19 Mar 2007 20:06:04 +0000 (UTC) Received: (from sje@localhost) by hpsje.cup.hp.com (8.9.3 (PHNE_29774)/8.9.3) id NAA05229; Mon, 19 Mar 2007 13:06:04 -0700 (PDT) Date: Mon, 19 Mar 2007 21:08:00 -0000 From: Steve Ellcey Message-Id: <200703192006.NAA05229@hpsje.cup.hp.com> To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Patch to not link in libgfortranbegin.a when building ftn shared libs Cc: fxcoudert@gmail.com, paul@codesourcery.com, stevenb.gcc@gmail.com Reply-To: sje@cup.hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-03/txt/msg01277.txt.bz2 This patch is to remove '-lgfortranbegin' from the link line when using gfortran to build a shared library (gfortran -shared ...). Since the only symbol that gfortranbegin defines is main this should have no effect unless the shared library built has an undef of main. Presumably this will not happen in general. Background: I am experimenting with using the newest libtool in the GCC build. That libtool uses gfortran to link libgfortran instead of using the linker directly. When it does this I get an error because it can't find libgfortranbegin.a because it doesn't have the needed -B option to look in the libgfortran object directory. We could fix this by adding the needed -B but it seems like we should not really be linking libgfortranbegin.a into shared libraries anyway should we? OK to checkin? Tested on IA64 HP-UX and Linux with no problems, though I found it odd that on Linux GCC includes crtendS.o and crtn.o in the link line when gfortran (or gcc) with -shared to make a shared library. Steve Ellcey sje@cup.hp.com 2007-03-19 Steve Ellcey * gfortranspec.c (lookup_option): Set use_init to 1 if -shared seen. Index: gfortranspec.c =================================================================== --- gfortranspec.c (revision 123047) +++ gfortranspec.c (working copy) @@ -82,6 +82,7 @@ typedef enum -nodefaultlibs. */ OPTION_o, /* Aka --output. */ OPTION_S, /* Aka --assemble. */ + OPTION_shared, /* -shared. */ OPTION_syntax_only, /* -fsyntax-only. */ OPTION_v, /* Aka --verbose. */ OPTION_version, /* --version. */ @@ -174,6 +175,8 @@ lookup_option (Option *xopt, int *xskip, opt = OPTION_version; else if (!strcmp (text, "-fversion")) /* Really --version!! */ opt = OPTION_version; + else if (!strcmp (text, "-shared")) + opt = OPTION_shared; else if (!strcmp (text, "-Xlinker") || !strcmp (text, "-specs")) skip = 1; else @@ -360,6 +363,11 @@ For more information about these matters cool facility for handling --help and --verbose --help. */ return; + case OPTION_shared: + /* Don't link libfortranbegin.a into shared libraries. */ + use_init = 1; + break; + default: break; }