From patchwork Wed Aug 10 11:42:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 109371 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 240A5B7150 for ; Wed, 10 Aug 2011 21:42:39 +1000 (EST) Received: (qmail 2970 invoked by alias); 10 Aug 2011 11:42:36 -0000 Received: (qmail 2960 invoked by uid 22791); 10 Aug 2011 11:42:34 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Aug 2011 11:42:19 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id B05D5FA2; Wed, 10 Aug 2011 13:42:17 +0200 (CEST) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id P-abs-RuFz0d; Wed, 10 Aug 2011 13:42:12 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 265BCFA1; Wed, 10 Aug 2011 13:42:12 +0200 (CEST) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id p7ABgBZT005408; Wed, 10 Aug 2011 13:42:11 +0200 (MEST) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Paolo Bonzini , Ralf Wildenhues , Arnaud Charlet , "Joseph S. Myers" Subject: RFC: [build, ada] Centralize PICFLAG configuration Date: Wed, 10 Aug 2011 13:42:11 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 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 As has been mentioned before, one impediment to complete the toplevel libgcc move is libada's use of TARGET_LIBGCC2_CFLAGS. AFAICS, it is primarily used for gnatlib-*shared targets, so I assume that this was done mostly (exclusively?) to get the flags necessary for PIC code generation. Since those flags aren't used for the static libgnat.a, it were strange that the non-PIC flags were actually required, given that all gnat.dg and ada/acats testing is only done with the static library. If this is true, then we need two things: * Change gcc-interface/Makefile.in and libada/Makefile.in to use PICFLAG instead of TARGET_LIBGCC2_CFLAGS. This is what the patch below does. * Centralize the determination of PICFLAG. Currently, three libraries inside the gcc tree are built PIC without libtool: libgcc, libiberty, and libgnat/libgnarl. libiberty/configure.ac has a hardcoded list of PICFLAG that could be moved to a toplevel config/picflag.m4. Alternatively, one could think about using libtool --config | grep pic_flag to determine the flag without actually using libtool. Last, one completely could go for libtool, but I very much doubt such a suggestion would get much traction. My current plan is to merge the PICFLAG information from libiberty and libgcc into picflag.m4 and use that. I've used the patch below as a proof-of-concept to complete the toplevel libgcc move. Together with companion patches to actually move all the LIBGCC2* and LIB2* variables and corresponding files to toplevel libgcc, I've sucessfully bootstrapped on i386-pc-solaris2.11. Comments, suggestions? Rainer 2011-07-31 Rainer Orth gcc/ada: * gcc-interface/Makefile.in (GNATLIBCFLAGS_FOR_C): Replace TARGET_LIBGCC2_CFLAGS by PICFLAG. (gnatlib-shared-default, gnatlib-shared-dual-win32, gnatlib-shared-win32, gnatlib-shared-darwin, gnatlib-shared, gnatlib-sjlj, gnatlib-zcx): Likewise. libada: * configure.ac (PICFLAG): Set. Substitute. * configure: Regenerate. * Makefile.in (TARGET_LIBGCC2_CFLAGS): Replace by PICFLAG. (GNATLIBCFLAGS_FOR_C): Replace TARGET_LIBGCC2_CFLAGS by PICFLAG. (LIBADA_FLAGS_TO_PASS): Likewise. Don't include $(GCC_DIR)/libgcc.mvars. diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -114,7 +114,7 @@ GNATLIBCFLAGS = -g -O2 # Pretend that _Unwind_GetIPInfo is available for the target by default. This # should be autodetected during the configuration of libada and passed down to # here, but we need something for --disable-libada and hope for the best. -GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \ +GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(PICFLAG) -fexceptions \ -DIN_RTS -DHAVE_GETIPINFO ALL_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS) MOST_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(SOME_ADAFLAGS) @@ -2482,7 +2482,7 @@ gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../ gnatlib-shared-default: $(MAKE) $(FLAGS_TO_PASS) \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \ + GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG)" \ GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ @@ -2490,14 +2490,14 @@ gnatlib-shared-default: $(RM) $(RTSDIR)/libgna*$(soext) cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \ - $(TARGET_LIBGCC2_CFLAGS) \ + $(PICFLAG) \ -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(MISCLIB) -lm cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \ - $(TARGET_LIBGCC2_CFLAGS) \ + $(PICFLAG) \ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_TASKING_OBJS) \ $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ @@ -2529,7 +2529,7 @@ gnatlib-shared-dual: gnatlib-shared-dual-win32: $(MAKE) $(FLAGS_TO_PASS) \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \ + GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG)" \ GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ @@ -2552,7 +2552,7 @@ gnatlib-shared-dual-win32: gnatlib-shared-win32: $(MAKE) $(FLAGS_TO_PASS) \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \ + GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG)" \ GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ @@ -2560,13 +2560,13 @@ gnatlib-shared-win32: $(RM) $(RTSDIR)/libgna*$(soext) cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \ - $(TARGET_LIBGCC2_CFLAGS) \ + $(PICFLAG) \ -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB) cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \ - $(TARGET_LIBGCC2_CFLAGS) \ + $(PICFLAG) \ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_TASKING_OBJS) \ $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ @@ -2575,21 +2575,21 @@ gnatlib-shared-win32: gnatlib-shared-darwin: $(MAKE) $(FLAGS_TO_PASS) \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \ + GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG)" \ GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) -fno-common" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ gnatlib $(RM) $(RTSDIR)/libgnat$(soext) $(RTSDIR)/libgnarl$(soext) cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ - | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \ + | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(PICFLAG) \ -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ $(SO_OPTS) \ -Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(MISCLIB) -lm cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ - | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \ + | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(PICFLAG) \ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_TASKING_OBJS) \ $(SO_OPTS) \ @@ -2638,7 +2638,7 @@ gnatlib-shared: GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ - TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \ + PICFLAG="$(PICFLAG)" \ $(GNATLIB_SHARED) gnatlib-sjlj: @@ -2653,7 +2653,7 @@ gnatlib-sjlj: GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ - TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" gnatlib + PICFLAG="$(PICFLAG)" gnatlib gnatlib-zcx: $(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="-gcc" \ @@ -2667,7 +2667,7 @@ gnatlib-zcx: GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ - TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" gnatlib + PICFLAG="$(PICFLAG)" gnatlib # .s files for cross-building gnat-cross: force diff --git a/libada/Makefile.in b/libada/Makefile.in --- a/libada/Makefile.in +++ b/libada/Makefile.in @@ -1,5 +1,5 @@ # Makefile for libada. -# Copyright 2003, 2004, 2009, 2010 Free Software Foundation, Inc. +# Copyright 2003, 2004, 2009, 2010, 2011 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -56,15 +56,13 @@ LOOSE_WARN = -W -Wall -Wwrite-strings -W GCC_WARN_CFLAGS = $(LOOSE_WARN) WARN_CFLAGS = @warn_cflags@ -TARGET_LIBGCC2_CFLAGS= +PICFLAG = @PICFLAG@ GNATLIBCFLAGS= -g -O2 -GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \ +GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(PICFLAG) -fexceptions \ -DIN_RTS @have_getipinfo@ -# Get target-specific overrides for TARGET_LIBGCC2_CFLAGS. host_subdir = @host_subdir@ GCC_DIR=$(MULTIBUILDTOP)../../$(host_subdir)/gcc -include $(GCC_DIR)/libgcc.mvars target_noncanonical:=@target_noncanonical@ version := $(shell cat $(srcdir)/../gcc/BASE-VER) @@ -83,7 +81,7 @@ LIBADA_FLAGS_TO_PASS = \ "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS)" \ "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS)" \ "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS)" \ - "TARGET_LIBGCC2_CFLAGS=$(TARGET_LIBGCC2_CFLAGS)" \ + "PICFLAG=$(PICFLAG)" \ "THREAD_KIND=$(THREAD_KIND)" \ "TRACE=$(TRACE)" \ "MULTISUBDIR=$(MULTISUBDIR)" \ diff --git a/libada/configure.ac b/libada/configure.ac --- a/libada/configure.ac +++ b/libada/configure.ac @@ -117,6 +117,9 @@ case $enable_shared in esac ], [enable_shared=yes]) AC_SUBST([enable_shared]) +# FIXME: Configure. +PICFLAG=-fPIC +AC_SUBST([PICFLAG]) # These must be passed down, or are needed by gcc/libgcc.mvars AC_PROG_AWK