RFC: [build, ada] Centralize PICFLAG configuration

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Mon Aug 15 19:51:00 GMT 2011


Paolo,

> On 08/10/2011 01:42 PM, Rainer Orth wrote:
>> * 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.
>
> That's the simplest alternative.  It would need however a pass through the
> config/ directory for targets that are never used as hosts for GCC (and
> thus libiberty).
>
> Alternatively, the libtool code could be extracted to config/picflag.m4.

I've merged all three, and (as expected) found a couple of
inconsistencies.

* The general approach between libtool and libiberty differs.  Unless
  otherwise specified (PIC is the default or doesn't work for some
  reason), libtool defaults to -fPIC, while libiberty has a strange
  mixture of -fPIC/-fpic and nothing, without explanation and without a
  default.

* git libtool.m4 uses -fno-common on *-*-darwin.  No idea if this is
  required.

* For QNX, it uses -fPIC -shared, which may no longer be necessary and
  is claimed as a g++ workaround.

* For IA64 HP-UX, there's a claim that -fPIC is necessary despite PIC
  code being the default.  I could find no hint in trunk that this is
  true any longer.

* On a few targets (called out in config/picflag.m4), -fpic and -fPIC
  differ.  While libtool always uses -fPIC, libiberty/configure.ac
  preferred -fpic in a few cases.  No idea why.

* For sh*-*-linux* and sh*-*-netbsd*, -fpic is used in
  HOST_LIBGCC2_CFLAGS.  Again, no explanation.  Perhaps this
  could/should be done as a local override in libgcc instead?

* For SPARC, libiberty/configure.ac has

	case "${CFLAGS}" in
	    *-fpic*)
		PICFLAG=-fpic
		;;
	    *)
		PICFLAG=-fPIC
		;;
	esac ;;

  Why is this SPARC-specific?

* There are two platforms that specify -fpic where this doesn't make a
  difference from -fPIC: arm*-*-netbsdelf* and bfin*-elf*,
  bfin*-uclinux*, bfin*-linux-uclibc*.  I've omitted that setting.

>>    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.
>
> Yes, that needs to be done of course.  I'm not sure if we still support
> gnatlib_and_tools to build libada/gnattools.  If so, we would need the
> PICFLAG to be available somehow in the gcc Makefile (perhaps by providing
> GCC_TARGET_PICFLAG in addition to GCC_PICFLAG in picflag.m4).

The only trace I could find is in a install.texi reference to historical
practice.

The patch below has been tested as the previous submissions.

	Rainer


2011-07-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	config:
	* picflag.m4: New file.

	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: Include ../config/picflag.m4.
	(GCC_PICFLAG): Call it.
	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.

	libiberty:
	* aclocal.m4: Include ../config/picflag.m4.
	* configure.ac (GCC_PICFLAG): Call it.
	(enable_shared): Clear PICFLAG unless shared.
	* configure: Regenerate.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: centralize-picflag.patch
Type: text/x-patch
Size: 11805 bytes
Desc: Centralize PICFLAG configuration
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110815/b4a04aef/attachment.bin>
-------------- next part --------------

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


More information about the Gcc-patches mailing list