lto-plugin: mismatch between ld's architecture and GCC's configure --host

Thomas Schwinge thomas@codesourcery.com
Fri Jan 10 12:00:00 GMT 2014


Hi!

Ping, after another month.  I've only received a private note from one
build machinery manintainer who found this beyond his level of expertise,
and wished me luck to find someone else to review.  Any takers in the new
year?

On Sat, 14 Dec 2013 13:12:28 +0100, I wrote:
> Ping, after another month.  Reposting the patches below; freshly
> re-tested, both to cause no change if the new configure options are not
> used, and to do the right thing if they are.
> 
> On Tue, 12 Nov 2013 14:52:37 +0100, I wrote:
> > Could a global maintainer or build machinery maintainer please review the
> > two unreviewed patches posted in this series?
> > 
> > On Mon, 4 Nov 2013 10:13:39 -0800, Cary Coutant <ccoutant@google.com> wrote:
> > > >> Ping.  To sum it up, with these patches applied, there are no changes for
> > > >> a "regular" build (not using the new configure options).  On the other
> > > >> hand, configuring GCC as described, it is possible use the 32-bit x86
> > > >> linker for/with a x86_64 build, and get the very same GCC test results as
> > > >> when using a x86_64 linker.
> > > 
> > > Sorry, I've been hoping someone with more global approval authority
> > > would respond.
> > > 
> > > > Allow overriding the libiberty used for building the LTO plugin.
> > > >
> > > >         lto-plugin/
> > > >         * configure.ac (--with-libiberty): New configure option.
> > > >         * configure: Regenerate.
> > > >         * Makefile.am (libiberty, libiberty_pic): New variables.
> > > >         (liblto_plugin_la_LIBADD, liblto_plugin_la_LDFLAGS)
> > > >         (liblto_plugin_la_DEPENDENCIES): Use them.
> > > >         * Makefile.in: Regenerate.
> > > 
> > > These look OK to me.
> > > 
> > > > Allow for overriding a module's srcdir.
> > > >
> > > >         * Makefile.tpl (configure-[+prefix+][+module+])
> > > >         (configure-stage[+id+]-[+prefix+][+module+]): Allow for
> > > >         overriding a module's srcdir.
> > > >         * Makefile.in: Regenerate.
> > > 
> > > These look OK, but I think a global maintainer or build machinery
> > > maintainer should give approval.
> > > 
> > > > Non-host system configuration for linker plugins.
> > > >
> > > >         * configure.ac (--enable-linker-plugin-flags)
> > > >         (--enable-linker-plugin-configure-flags): New flags.
> > > >         (configdirs): Conditionally add libiberty-linker-plugin.
> > > >         * configure: Regenerate.
> > > >         * Makefile.def (host_modules): Add libiberty-linker-plugin.
> > > >         (host_modules) <lto-plugin>: Pay attention to
> > > >         @extra_linker_plugin_flags@ and
> > > >         @extra_linker_plugin_configure_flags@.
> > > >         (all-lto-plugin): Also depend on all-libiberty-linker-plugin.
> > > >         * Makefile.in: Regenerate.
> > > >         gcc/
> > > >         * doc/install.texi (--enable-linker-plugin-flags)
> > > >         (--enable-linker-plugin-configure-flags): Document new flags.
> > > 
> > > Same here.
> 
> commit d09a4afcf55cde981ec9dad86950be5ade51f9eb
> Author: Thomas Schwinge <thomas@codesourcery.com>
> Date:   Sun Oct 13 16:15:56 2013 +0200
> 
>     Allow overriding the libiberty used for building the LTO plugin.
>     
>     	lto-plugin/
>     	* configure.ac (--with-libiberty): New configure option.
>     	* configure: Regenerate.
>     	* Makefile.am (libiberty, libiberty_pic): New variables.
>     	(liblto_plugin_la_LIBADD, liblto_plugin_la_LDFLAGS)
>     	(liblto_plugin_la_DEPENDENCIES): Use them.
>     	* Makefile.in: Regenerate.
> 
> diff --git lto-plugin/Makefile.am lto-plugin/Makefile.am
> index b24015e..8b7bb54 100644
> --- lto-plugin/Makefile.am
> +++ lto-plugin/Makefile.am
> @@ -15,17 +15,19 @@ libexecsub_LTLIBRARIES = liblto_plugin.la
>  gcc_build_dir = ../$(host_subdir)/gcc
>  in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib))
>  
> -# Can be removed when libiberty becomes a normal convenience library
> -Wc=-Wc,
> -
>  liblto_plugin_la_SOURCES = lto-plugin.c
> +# Note that we intentionally override the bindir supplied by ACX_LT_HOST_FLAGS.
> +liblto_plugin_la_LDFLAGS = $(lt_host_flags) -module -bindir $(libexecsubdir)
> +# Can be simplified when libiberty becomes a normal convenience library.
> +libiberty=$(with_libiberty)/libiberty.a
> +libiberty_pic=$(with_libiberty)/pic/libiberty.a
> +Wc=-Wc,
>  liblto_plugin_la_LIBADD = \
> -	$(if $(wildcard ../libiberty/pic/libiberty.a),$(Wc)../libiberty/pic/libiberty.a,)
> -# Note that we intentionally override the bindir supplied by ACX_LT_HOST_FLAGS
> -liblto_plugin_la_LDFLAGS = $(lt_host_flags) -module -bindir $(libexecsubdir) \
> -	$(if $(wildcard ../libiberty/pic/libiberty.a),,-Wc,../libiberty/libiberty.a)
> -liblto_plugin_la_DEPENDENCIES = $(if $(wildcard \
> -	../libiberty/pic/libiberty.a),../libiberty/pic/libiberty.a,)
> +	$(if $(wildcard $(libiberty_pic)),$(Wc)$(libiberty_pic),)
> +liblto_plugin_la_LDFLAGS += \
> +	$(if $(wildcard $(libiberty_pic)),,-Wc,$(libiberty))
> +liblto_plugin_la_DEPENDENCIES = \
> +	$(if $(wildcard $(libiberty_pic)),$(libiberty_pic),)
>  
>  all-local: $(in_gcc_libs)
>  
> diff --git lto-plugin/Makefile.in lto-plugin/Makefile.in
> [...]
> diff --git lto-plugin/configure lto-plugin/configure
> [...]
> diff --git lto-plugin/configure.ac lto-plugin/configure.ac
> index 9a418d2..b73fabb 100644
> --- lto-plugin/configure.ac
> +++ lto-plugin/configure.ac
> @@ -4,6 +4,11 @@ AC_CANONICAL_SYSTEM
>  GCC_TOPLEV_SUBDIRS
>  AM_INIT_AUTOMAKE([foreign no-dist])
>  AM_MAINTAINER_MODE
> +AC_ARG_WITH(libiberty,
> +  [AS_HELP_STRING([--with-libiberty=PATH],
> +    [specify the directory where to find libiberty [../libiberty]])],
> +  [], with_libiberty=../libiberty)
> +AC_SUBST(with_libiberty)
>  AC_PROG_CC
>  AC_SYS_LARGEFILE
>  ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_lto_plugin_warn_cflags])
> 
> commit c02c5075066e1e4e461efa0752d56eab3ac301de
> Author: Thomas Schwinge <thomas@codesourcery.com>
> Date:   Sun Oct 13 14:36:07 2013 +0200
> 
>     Allow for overriding a module's srcdir.
>     
>     	* Makefile.tpl (configure-[+prefix+][+module+])
>     	(configure-stage[+id+]-[+prefix+][+module+]): If specified, use
>     	"module_srcdir" instead of "module" for locating a module's srcdir.
>     	* Makefile.in: Regenerate.
> 
> diff --git Makefile.in Makefile.in
> [...]
> diff --git Makefile.tpl Makefile.tpl
> index 92f3f61..d505b5e 100644
> --- Makefile.tpl
> +++ Makefile.tpl
> @@ -1002,12 +1002,13 @@ configure-[+prefix+][+module+]: [+ IF bootstrap +][+ ELSE +]
>  	  *) topdir=`echo [+subdir+]/[+module+]/ | \
>  		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
>  	esac; \
> -	srcdiroption="--srcdir=$${topdir}/[+module+]"; \
> -	libsrcdir="$$s/[+module+]"; \
> +	module_srcdir=[+? module_srcdir (get "module_srcdir") (get "module")+]; \
>  	[+ IF no-config-site +]rm -f no-such-file || : ; \
> -	CONFIG_SITE=no-such-file [+ ENDIF +]$(SHELL) $${libsrcdir}/configure \
> +	CONFIG_SITE=no-such-file [+ ENDIF +]$(SHELL) \
> +	  $$s/$$module_srcdir/configure \
> +	  --srcdir=$${topdir}/$$module_srcdir \
>  	  [+args+] --build=${build_alias} --host=[+host_alias+] \
> -	  --target=[+target_alias+] $${srcdiroption} [+extra_configure_flags+] \
> +	  --target=[+target_alias+] [+extra_configure_flags+] \
>  	  || exit 1
>  @endif [+prefix+][+module+]
>  
> @@ -1055,12 +1056,12 @@ configure-stage[+id+]-[+prefix+][+module+]:
>  	  *) topdir=`echo [+subdir+]/[+module+]/ | \
>  		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
>  	esac; \
> -	srcdiroption="--srcdir=$${topdir}/[+module+]"; \
> -	libsrcdir="$$s/[+module+]"; \
> -	$(SHELL) $${libsrcdir}/configure \
> +	module_srcdir=[+? module_srcdir (get "module_srcdir") (get "module")+]; \
> +	$(SHELL) $$s/$$module_srcdir/configure \
> +	  --srcdir=$${topdir}/$$module_srcdir \
>  	  [+args+] --build=${build_alias} --host=[+host_alias+] \
> -	  --target=[+target_alias+] $${srcdiroption} [+ IF prev +]\
> -	  --with-build-libsubdir=$(HOST_SUBDIR) [+ ENDIF prev +]\
> +	  --target=[+target_alias+] \
> +	  [+ IF prev +] --with-build-libsubdir=$(HOST_SUBDIR) [+ ENDIF prev +] \
>  	  $(STAGE[+id+]_CONFIGURE_FLAGS)[+ IF extra_configure_flags +] \
>  	  [+extra_configure_flags+][+ ENDIF extra_configure_flags +]
>  @endif [+prefix+][+module+]-bootstrap
> 
> commit 9292bf8e327e2c729677eaaac2c263456cb77aec
> Author: Thomas Schwinge <thomas@codesourcery.com>
> Date:   Sun Oct 13 20:05:14 2013 +0200
> 
>     Non-host system configuration for linker plugins.
>     
>     	* configure.ac (--enable-linker-plugin-configure-flags)
>     	(--enable-linker-plugin-flags): New flags.
>     	(configdirs): Conditionally add libiberty-linker-plugin.
>     	* configure: Regenerate.
>     	* Makefile.def (host_modules): Add libiberty-linker-plugin.
>     	(host_modules) <lto-plugin>: Pay attention to
>     	@extra_linker_plugin_flags@ and
>     	@extra_linker_plugin_configure_flags@.
>     	(all-lto-plugin): Also depend on all-libiberty-linker-plugin.
>     	* Makefile.in: Regenerate.
>     	gcc/
>     	* doc/install.texi (--enable-linker-plugin-configure-flags)
>     	(--enable-linker-plugin-flags): Document new flags.
> 
> diff --git Makefile.def Makefile.def
> index 32296d1..2a64866 100644
> --- Makefile.def
> +++ Makefile.def
> @@ -85,6 +85,14 @@ host_modules= { module= libdecnumber; bootstrap=true; };
>  host_modules= { module= libgui; };
>  host_modules= { module= libiberty; bootstrap=true;
>  	        extra_configure_flags='@extra_host_libiberty_configure_flags@';};
> +// Linker plugins may need their own build of libiberty; see
> +// gcc/doc/install.texi.  We take care that this build of libiberty doesn't get
> +// installed.  It's a helper library for linker plugins, so we pay attention to
> +// @extra_linker_plugin_flags@ and @extra_linker_plugin_configure_flags@.
> +host_modules= { module= libiberty-linker-plugin; bootstrap=true;
> +		module_srcdir=libiberty;
> +	        extra_configure_flags='@extra_host_libiberty_configure_flags@ --disable-install-libiberty @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
> +		extra_make_flags='@extra_linker_plugin_flags@'; };
>  // We abuse missing to avoid installing anything for libiconv.
>  host_modules= { module= libiconv;
>  		extra_configure_flags='--disable-shared';
> @@ -111,7 +119,8 @@ host_modules= { module= libtermcap; no_check=true;
>  host_modules= { module= utils; no_check=true; };
>  host_modules= { module= gnattools; };
>  host_modules= { module= lto-plugin; bootstrap=true;
> -		extra_configure_flags=--enable-shared; };
> +		extra_configure_flags='--enable-shared @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
> +		extra_make_flags='@extra_linker_plugin_flags@'; };
>  
>  target_modules = { module= libstdc++-v3;
>  		   bootstrap=true;
> @@ -337,7 +346,10 @@ dependencies = { module=all-fixincludes; on=all-libiberty; };
>  
>  dependencies = { module=all-gnattools; on=all-target-libada; };
>  
> +// Depending on the specific configuration, the LTO plugin will either use the
> +// generic libiberty build or the specific build for linker plugins.
>  dependencies = { module=all-lto-plugin; on=all-libiberty; };
> +dependencies = { module=all-lto-plugin; on=all-libiberty-linker-plugin; };
>  
>  dependencies = { module=all-utils; on=all-libiberty; };
>  
> diff --git Makefile.in Makefile.in
> [...]
> diff --git configure configure
> [...]
> diff --git configure.ac configure.ac
> index 30190d6..1fa99c3 100644
> --- configure.ac
> +++ configure.ac
> @@ -1731,6 +1731,19 @@ ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
>    esac
>  ])
>  
> +AC_ARG_ENABLE(linker-plugin-configure-flags,
> +  [AS_HELP_STRING([[--enable-linker-plugin-configure-flags=FLAGS]],
> +    [additional flags for configuring linker plugins @<:@none@:>@])],
> +  extra_linker_plugin_configure_flags=$enableval,
> +  extra_linker_plugin_configure_flags=)
> +AC_SUBST(extra_linker_plugin_configure_flags)
> +AC_ARG_ENABLE(linker-plugin-flags,
> +  [AS_HELP_STRING([[--enable-linker-plugin-flags=FLAGS]],
> +    [additional flags for configuring and building linker plugins @<:@none@:>@])],
> +  extra_linker_plugin_flags=$enableval,
> +  extra_linker_plugin_flags=)
> +AC_SUBST(extra_linker_plugin_flags)
> +
>  
>  # By default, C and C++ are the only stage 1 languages.
>  stage1_languages=,c,
> @@ -2133,6 +2146,21 @@ for i in ${target_configdirs_all} ; do
>    fi
>  done
>  
> +# libiberty-linker-plugin is special: it doesn't have its own source directory,
> +# so we have to add it after the preceding checks.
> +if test x"$extra_linker_plugin_flags$extra_linker_plugin_configure_flags" != x
> +then
> +  case " $configdirs " in
> +    *" libiberty "*)
> +      # If we can build libiberty, we can also build libiberty-linker-plugin.
> +      configdirs="$configdirs libiberty-linker-plugin"
> +      extra_linker_plugin_configure_flags="$extra_linker_plugin_configure_flags \
> +        --with-libiberty=../libiberty-linker-plugin";;
> +    *)
> +      AC_MSG_ERROR([libiberty missing]);;
> +  esac
> +fi
> +
>  # Produce a warning message for the subdirs we can't configure.
>  # This isn't especially interesting in the Cygnus tree, but in the individual
>  # FSF releases, it's important to let people know when their machine isn't
> diff --git gcc/doc/install.texi gcc/doc/install.texi
> index 71aa7fc..19f54c4 100644
> --- gcc/doc/install.texi
> +++ gcc/doc/install.texi
> @@ -1775,6 +1775,25 @@ GLIBC 2.11 or above, otherwise disabled.
>  Enable support for link-time optimization (LTO).  This is enabled by
>  default, and may be disabled using @option{--disable-lto}.
>  
> +@item --enable-linker-plugin-configure-flags=FLAGS
> +@itemx --enable-linker-plugin-flags=FLAGS
> +By default, linker plugins (such as the LTO plugin) are built for the
> +host system architecture.  For the case that the linker has a
> +different (but run-time compatible) architecture, these flags can be
> +specified to build plugins that are compatible to the linker.  For
> +example, if you are building GCC for a 64-bit x86_64
> +(@samp{x86_64-unknown-linux-gnu}) host system, but have a 32-bit x86
> +GNU/Linux (@samp{i686-pc-linux-gnu}) linker executable (which is
> +executable on the former system), you can configure GCC as follows for
> +getting compatible linker plugins:
> +
> +@smallexample
> +% @var{srcdir}/configure \
> +    --host=x86_64-unknown-linux-gnu \
> +    --enable-linker-plugin-configure-flags=--host=i686-pc-linux-gnu \
> +    --enable-linker-plugin-flags='CC=gcc\ -m32\ -Wl,-rpath,[...]/i686-pc-linux-gnu/lib'
> +@end smallexample
> +
>  @item --with-plugin-ld=@var{pathname}
>  Enable an alternate linker to be used at link-time optimization (LTO)
>  link time when @option{-fuse-linker-plugin} is enabled.
> 
> 
> Grüße,
>  Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140110/0767665c/attachment.sig>


More information about the Gcc-patches mailing list