This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add --enable-host-shared configuration option


On 10/09/13 18:25, David Malcolm wrote:
My JIT branch requires embedding GCC's code as a shared library on the
host.  To do requires building the host code as position-independent,
which unfortunately incurs a small speed hit.
Obviously this is an opt-in right now, so I'm not terribly concerned.


My first time attempt at this handled --enable-host-shared by detecting
it in each child "configure" script (as generated from configure.ac) and
conditionally appending -fPIC to makefile variables such as CFLAGS,
CXXFLAGS and LDFLAGS.

This worked when invoking "make" from each subdirectory, but not when
running "make" in the top-level directory: the top-level make would
pass in "CFLAGS=-g -O2" to the child makes, overriding their CFLAGS,
thus erroneously omitting the "-fPIC" flag.
Yea. This stuff (particularly the overriding of flags) is a mess and far from obvious IMHO. But I don't think fixing that is "in scope" for what you're working on.


This patch instead adds a PICFLAG variable, set up in the child
configure scripts, to contain -fPIC if configured with
--enable-host-shared.  The PICFLAG variable is then added to an
appropriate variable in each child makefile to ensure that it is used
when building host code.
Seems reasonable -- particularly since you've tested it both with a toplevel invocation and invocations in subdirectories.


There's precedent for both "PICFLAG" and "PIC_FLAG" in the source tree:
libiberty uses "PICFLAG", libbacktrace usss "PIC_FLAG".  I went with
"PICFLAG" for the new flags.
But of course...


The patch uses -fPIC rather than -fpic.
Right.



Successfully bootstrapped and regtesting on x86_64-unknown-linux.

OK for trunk?

ChangeLog follows inline:

/
	* configure.ac: Add --enable-host-shared
	* configure: Regenerate.

gcc/
	* Makefile.in (PICFLAG): New.
	(enable_host_shared): New.
	(INTERNAL_CFLAGS): Use PICFLAG.
	(LIBIBERTY): Use pic build of libiberty.a if configured with
	--enable-host-shared.
	* configure.ac: Add --enable-host-shared, setting up new
	PICFLAG variable.
	* configure: Regenerate.

libbacktrace/
	* configure.ac: Add --enable-host-shared, setting up
	pre-existing PIC_FLAG variable within Makefile.am et al.
	* configure: Regenerate.

libcpp/
	* Makefile.in (PICFLAG): New.
	(ALL_CFLAGS): Add PICFLAG.
	(ALL_CXXFLAGS): Likewise.
	* configure.ac: Add --enable-host-shared, setting up new
	PICFLAG variable.
	* configure: Regenerate.

libdecnumber/
	* Makefile.in (PICFLAG): New.
	(ALL_CFLAGS): Add PICFLAG.
	* configure.ac: Add --enable-host-shared, setting up new
	PICFLAG variable.
	* configure: Regenerate.

libiberty/
	* configure.ac: If --enable-host-shared, use -fPIC.
	* configure: Regenerate.

zlib/
	* configure.ac: Add --enable-host-shared, setting up new
	PICFLAG variable.
	* Makefile.am: Add PICFLAG to libz_a_CFLAGS.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
Presumably other host libraries we depend on such as gmp, mpc, etc are available in shared (or at least PIC) form as well? Obviously these are out of our source tree and largely out of our control, but I'm a bit curious if there's other host libraries that may cause you headaches in the future.

This is fine with the install.texi changes Joseph wanted.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]