diff options
author | David Malcolm <dmalcolm@redhat.com> | 2013-10-07 11:53:21 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2013-10-07 11:53:21 -0400 |
commit | 11f23e6248339c3bad498a7618cfde96338a1d3c (patch) | |
tree | fdfe4fafcb3fa990ca0cd57e8b23302b6cafbf89 | |
parent | f0a26c404c271a621078c6277169d48f271697cb (diff) | |
download | gcc-11f23e6248339c3bad498a7618cfde96338a1d3c.tar.gz |
Fix how --enable-host-shared adds -fPIC to compilation flags.
The --enable-host-shared configuration option is meant to add -fPIC to
compilation flags for code meant to run on the host.
Previously, I implemented this by detecting the --enable-host-shared
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.
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.
This ensures that -fPIC is present if requested, when building both
from the top-level directory, and from the child directories.
gcc/
* Makefile.in: Set PICFLAG from configure script; add it to
INTERNAL_CFLAGS.
* configure.ac (--enable-host-shared): Set up PICFLAG rather
than attempting to append -fPIC to CFLAGS, CXXFLAGS, LDFLAGS.
* configure: Regenerate.
libcpp/
* Makefile.in: Set PICFLAG from configure script; add it to
ALL_CFLAGS.
* configure.ac (--enable-host-shared): Set up PICFLAG rather
than attempting to append -fPIC to CFLAGS, CXXFLAGS, LDFLAGS.
* configure: Regenerate.
libdecnumber/
* Makefile.in: Set PICFLAG from configure script; add it to
ALL_CFLAGS.
* configure.ac (--enable-host-shared): Set up PICFLAG rather
than attempting to append -fPIC to CFLAGS, CXXFLAGS, LDFLAGS.
* configure: Regenerate.
zlib/
* Makefile.am: Add PICFLAG to libz_a_CFLAGS.
* configure.ac (--enable-host-shared): Set up PICFLAG rather
than attempting to append -fPIC to CFLAGS.
* Makefile.in: Regenerate.
* configure: Regenerate.
-rw-r--r-- | gcc/ChangeLog.jit | 8 | ||||
-rw-r--r-- | gcc/Makefile.in | 5 | ||||
-rwxr-xr-x | gcc/configure | 14 | ||||
-rw-r--r-- | gcc/configure.ac | 7 | ||||
-rw-r--r-- | libcpp/ChangeLog.jit | 8 | ||||
-rw-r--r-- | libcpp/Makefile.in | 5 | ||||
-rwxr-xr-x | libcpp/configure | 6 | ||||
-rw-r--r-- | libcpp/configure.ac | 5 | ||||
-rw-r--r-- | libdecnumber/ChangeLog.jit | 8 | ||||
-rw-r--r-- | libdecnumber/Makefile.in | 3 | ||||
-rwxr-xr-x | libdecnumber/configure | 7 | ||||
-rw-r--r-- | libdecnumber/configure.ac | 5 | ||||
-rw-r--r-- | zlib/ChangeLog.jit | 8 | ||||
-rw-r--r-- | zlib/Makefile.am | 2 | ||||
-rw-r--r-- | zlib/Makefile.in | 3 | ||||
-rwxr-xr-x | zlib/configure | 10 | ||||
-rw-r--r-- | zlib/configure.ac | 3 |
17 files changed, 76 insertions, 31 deletions
diff --git a/gcc/ChangeLog.jit b/gcc/ChangeLog.jit index 5b4faf16369..e846c08625a 100644 --- a/gcc/ChangeLog.jit +++ b/gcc/ChangeLog.jit @@ -1,3 +1,11 @@ +2013-10-07 David Malcolm <dmalcolm@redhat.com> + + * Makefile.in: Set PICFLAG from configure script; add it to + INTERNAL_CFLAGS. + * configure.ac (--enable-host-shared): Set up PICFLAG rather + than attempting to append -fPIC to CFLAGS, CXXFLAGS, LDFLAGS. + * configure: Regenerate. + 2013-10-03 David Malcolm <dmalcolm@redhat.com> * Makefile.in (LIBIBERTY): Use pic build of libiberty.a if diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 30585538268..eca1500e7a1 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -135,6 +135,9 @@ CFLAGS = @CFLAGS@ CXXFLAGS = @CXXFLAGS@ LDFLAGS = @LDFLAGS@ +# Should we build position-independent host code? +PICFLAG = @PICFLAG@ + # Flags to determine code coverage. When coverage is disabled, this will # contain the optimization flags, as you normally want code coverage # without optimization. @@ -957,7 +960,7 @@ CONTEXT_H = context.h # programs built during a bootstrap. # autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a # cross compiler which does not use the native headers and libraries. -INTERNAL_CFLAGS = -DIN_GCC @CROSS@ +INTERNAL_CFLAGS = -DIN_GCC $(PICFLAG) @CROSS@ # This is the variable actually used when we compile. If you change this, # you probably want to update BUILD_CFLAGS in configure.ac diff --git a/gcc/configure b/gcc/configure index 672ae129f92..40043bb6e75 100755 --- a/gcc/configure +++ b/gcc/configure @@ -600,6 +600,7 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS LIBOBJS +PICFLAG enable_host_shared enable_plugin pluginlibs @@ -17896,7 +17897,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17899 "configure" +#line 17900 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18002,7 +18003,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18005 "configure" +#line 18006 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -27697,17 +27698,18 @@ $as_echo "#define ENABLE_PLUGIN 1" >>confdefs.h fi -# Enable --enable-host-shared, adding -fPIC +# Enable --enable-host-shared # Check whether --enable-host-shared was given. if test "${enable_host_shared+set}" = set; then : - enableval=$enable_host_shared; CFLAGS="$CFLAGS -fPIC" - CXXFLAGS="$CXXFLAGS -fPIC" - LDFLAGS="$LDFLAGS -fPIC" + enableval=$enable_host_shared; PICFLAG=-fPIC +else + PICFLAG= fi + # Check whether --enable-libquadmath-support was given. if test "${enable_libquadmath_support+set}" = set; then : enableval=$enable_libquadmath_support; ENABLE_LIBQUADMATH_SUPPORT=$enableval diff --git a/gcc/configure.ac b/gcc/configure.ac index f1455ddb78f..5111109af48 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5399,14 +5399,13 @@ if test x"$enable_plugin" = x"yes"; then fi -# Enable --enable-host-shared, adding -fPIC +# Enable --enable-host-shared AC_ARG_ENABLE(host-shared, [AS_HELP_STRING([--enable-host-shared], [build host code as shared libraries])], -[CFLAGS="$CFLAGS -fPIC" - CXXFLAGS="$CXXFLAGS -fPIC" - LDFLAGS="$LDFLAGS -fPIC"], []) +[PICFLAG=-fPIC], [PICFLAG=]) AC_SUBST(enable_host_shared) +AC_SUBST(PICFLAG) AC_ARG_ENABLE(libquadmath-support, diff --git a/libcpp/ChangeLog.jit b/libcpp/ChangeLog.jit index fff6241658a..6f497d4888b 100644 --- a/libcpp/ChangeLog.jit +++ b/libcpp/ChangeLog.jit @@ -1,3 +1,11 @@ +2013-10-07 David Malcolm <dmalcolm@redhat.com> + + * Makefile.in: Set PICFLAG from configure script; add it to + ALL_CFLAGS. + * configure.ac (--enable-host-shared): Set up PICFLAG rather + than attempting to append -fPIC to CFLAGS, CXXFLAGS, LDFLAGS. + * configure: Regenerate. + 2013-10-03 David Malcolm <dmalcolm@redhat.com> * configure.ac: Add --enable-host-shared. diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in index 2353c9c043b..30bf8963cd8 100644 --- a/libcpp/Makefile.in +++ b/libcpp/Makefile.in @@ -57,6 +57,7 @@ CCDEPMODE = @CCDEPMODE@ CXXDEPMODE = @CXXDEPMODE@ DEPDIR = @DEPDIR@ NOEXCEPTION_FLAGS = @noexception_flags@ +PICFLAG = @PICFLAG@ datarootdir = @datarootdir@ datadir = @datadir@ @@ -72,9 +73,9 @@ depcomp = $(SHELL) $(srcdir)/../depcomp INCLUDES = -I$(srcdir) -I. -I$(srcdir)/../include @INCINTL@ \ -I$(srcdir)/include -ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) +ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(PICFLAG) ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(NOEXCEPTION_FLAGS) $(INCLUDES) \ - $(CPPFLAGS) + $(CPPFLAGS) $(PICFLAG) # The name of the compiler to use. COMPILER = $(CXX) diff --git a/libcpp/configure b/libcpp/configure index d2eaea05aeb..782a7105ac3 100755 --- a/libcpp/configure +++ b/libcpp/configure @@ -592,6 +592,7 @@ ac_includes_default="\ #endif" ac_subst_vars='LTLIBOBJS +PICFLAG MAINT USED_CATALOGS PACKAGE @@ -7209,12 +7210,13 @@ esac # Enable --enable-host-shared. # Check whether --enable-host-shared was given. if test "${enable_host_shared+set}" = set; then : - enableval=$enable_host_shared; CFLAGS="-fPIC $CFLAGS"; CXXFLAGS="-fPIC $CXXFLAGS" + enableval=$enable_host_shared; PICFLAG=-fPIC +else + PICFLAG= fi - # Output. ac_config_headers="$ac_config_headers config.h:config.in" diff --git a/libcpp/configure.ac b/libcpp/configure.ac index 1b4920bb48a..a70603c95a6 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -224,9 +224,8 @@ esac AC_ARG_ENABLE(host-shared, [AS_HELP_STRING([--enable-host-shared], [build host code as shared libraries])], -[CFLAGS="-fPIC $CFLAGS"; CXXFLAGS="-fPIC $CXXFLAGS"], []) -AC_SUBST(CFLAGS) -AC_SUBST(CXXFLAGS) +[PICFLAG=-fPIC], [PICFLAG=]) +AC_SUBST(PICFLAG) # Output. diff --git a/libdecnumber/ChangeLog.jit b/libdecnumber/ChangeLog.jit index fff6241658a..6f497d4888b 100644 --- a/libdecnumber/ChangeLog.jit +++ b/libdecnumber/ChangeLog.jit @@ -1,3 +1,11 @@ +2013-10-07 David Malcolm <dmalcolm@redhat.com> + + * Makefile.in: Set PICFLAG from configure script; add it to + ALL_CFLAGS. + * configure.ac (--enable-host-shared): Set up PICFLAG rather + than attempting to append -fPIC to CFLAGS, CXXFLAGS, LDFLAGS. + * configure: Regenerate. + 2013-10-03 David Malcolm <dmalcolm@redhat.com> * configure.ac: Add --enable-host-shared. diff --git a/libdecnumber/Makefile.in b/libdecnumber/Makefile.in index e67ff272f72..b6f3842b0d2 100644 --- a/libdecnumber/Makefile.in +++ b/libdecnumber/Makefile.in @@ -40,6 +40,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBICONV = @LIBICONV@ PACKAGE = @PACKAGE@ +PICFLAG = @PICFLAG@ RANLIB = @RANLIB@ SHELL = @SHELL@ objext = @OBJEXT@ @@ -57,7 +58,7 @@ enable_decimal_float= @enable_decimal_float@ INCLUDES = -I$(srcdir) -I. -ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) +ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(PICFLAG) bid_OBJS = bid2dpd_dpd2bid.$(objext) host-ieee32.$(objext) \ host-ieee64.$(objext) host-ieee128.$(objext) diff --git a/libdecnumber/configure b/libdecnumber/configure index 61438ec148e..2720f46ff7f 100755 --- a/libdecnumber/configure +++ b/libdecnumber/configure @@ -593,7 +593,7 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS LIBOBJS -CXXFLAGS +PICFLAG ADDITIONAL_OBJS enable_decimal_float target_os @@ -4895,12 +4895,13 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h # Enable --enable-host-shared. # Check whether --enable-host-shared was given. if test "${enable_host_shared+set}" = set; then : - enableval=$enable_host_shared; CFLAGS="-fPIC $CFLAGS"; CXXFLAGS="-fPIC $CXXFLAGS" + enableval=$enable_host_shared; PICFLAG=-fPIC +else + PICFLAG= fi - # Output. ac_config_headers="$ac_config_headers config.h:config.in" diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac index e2f0c92bf97..dd0499c43f6 100644 --- a/libdecnumber/configure.ac +++ b/libdecnumber/configure.ac @@ -99,9 +99,8 @@ AC_C_BIGENDIAN AC_ARG_ENABLE(host-shared, [AS_HELP_STRING([--enable-host-shared], [build host code as shared libraries])], -[CFLAGS="-fPIC $CFLAGS"; CXXFLAGS="-fPIC $CXXFLAGS"], []) -AC_SUBST(CFLAGS) -AC_SUBST(CXXFLAGS) +[PICFLAG=-fPIC], [PICFLAG=]) +AC_SUBST(PICFLAG) # Output. diff --git a/zlib/ChangeLog.jit b/zlib/ChangeLog.jit index fff6241658a..0ffd0681896 100644 --- a/zlib/ChangeLog.jit +++ b/zlib/ChangeLog.jit @@ -1,3 +1,11 @@ +2013-10-07 David Malcolm <dmalcolm@redhat.com> + + * Makefile.am: Add PICFLAG to libz_a_CFLAGS. + * configure.ac (--enable-host-shared): Set up PICFLAG rather + than attempting to append -fPIC to CFLAGS. + * Makefile.in: Regenerate. + * configure: Regenerate. + 2013-10-03 David Malcolm <dmalcolm@redhat.com> * configure.ac: Add --enable-host-shared. diff --git a/zlib/Makefile.am b/zlib/Makefile.am index a9c42cb2cf5..82f709d9ec7 100644 --- a/zlib/Makefile.am +++ b/zlib/Makefile.am @@ -16,7 +16,7 @@ libzgcj_convenience_la_SOURCES = $(ZLIB_SOURCES) else toolexeclib_LIBRARIES = libz.a libz_a_SOURCES = $(ZLIB_SOURCES) -libz_a_CFLAGS = $(AM_CFLAGS) +libz_a_CFLAGS = $(AM_CFLAGS) $(PICFLAG) endif # Work around what appears to be a GNU make bug handling MAKEFLAGS diff --git a/zlib/Makefile.in b/zlib/Makefile.in index f5ef37a647f..3c8fd5978c8 100644 --- a/zlib/Makefile.in +++ b/zlib/Makefile.in @@ -177,6 +177,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PICFLAG = @PICFLAG@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -255,7 +256,7 @@ zconf.h.in zlib.h zutil.c zutil.h @TARGET_LIBRARY_TRUE@libzgcj_convenience_la_SOURCES = $(ZLIB_SOURCES) @TARGET_LIBRARY_FALSE@toolexeclib_LIBRARIES = libz.a @TARGET_LIBRARY_FALSE@libz_a_SOURCES = $(ZLIB_SOURCES) -@TARGET_LIBRARY_FALSE@libz_a_CFLAGS = $(AM_CFLAGS) +@TARGET_LIBRARY_FALSE@libz_a_CFLAGS = $(AM_CFLAGS) $(PICFLAG) # Work around what appears to be a GNU make bug handling MAKEFLAGS # values defined in terms of make variables, as is the case for CC and diff --git a/zlib/configure b/zlib/configure index 0edbe05fd83..32e33e7a6fa 100755 --- a/zlib/configure +++ b/zlib/configure @@ -602,6 +602,7 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +PICFLAG TARGET_LIBRARY_FALSE TARGET_LIBRARY_TRUE toolexeclibdir @@ -10402,7 +10403,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10405 "configure" +#line 10406 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10508,7 +10509,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10511 "configure" +#line 10512 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11206,10 +11207,13 @@ fi # Check whether --enable-host-shared was given. if test "${enable_host_shared+set}" = set; then : - enableval=$enable_host_shared; CFLAGS="-fPIC $CFLAGS" + enableval=$enable_host_shared; PICFLAG=-fPIC +else + PICFLAG= fi + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF diff --git a/zlib/configure.ac b/zlib/configure.ac index c2540d9aa03..fb8d943905e 100644 --- a/zlib/configure.ac +++ b/zlib/configure.ac @@ -122,7 +122,8 @@ fi AC_ARG_ENABLE(host-shared, [AS_HELP_STRING([--enable-host-shared], [build host code as shared libraries])], -[CFLAGS="-fPIC $CFLAGS"], []) +[PICFLAG=-fPIC], [PICFLAG=]) +AC_SUBST(PICFLAG) AC_CONFIG_FILES([Makefile]) AC_OUTPUT |