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]

[PATCH][RFC] Enable -flto during bootstrap


This patch automatically enables -flto for all host binaries and libraries
via BOOT_CFLAGS and BOOT_LDFLAGS when lto is enabled.  It also adds
lto to the set of stage1 languages.

Before applying this patch we should fix PR41079, the linker aggregating
all lto sections from static libraries into the final executable.

I will followup with a bootstrap time comparison.

Any suggestions on how to do this patch more properly?  (On trunk we'd
conditionalize this on for example --enable-intermodule)

Thanks,
Richard.

2009-08-19  Richard Guenther  <rguenther@suse.de>

	* configure.ac: Substitute lto_BOOT_CFLAGS and lto_BOOT_LDFLAGS.
	Set them to -flto if lto is enabled.  Add lto to stage1 languages.
	* Makefile.tpl (BOOT_CFLAGS): Append lto_BOOT_CFLAGS.
	(BOOT_LDFLAGS): Append lto_BOOT_LDFLAGS.

	* Makefile.in: Re-generate.
	* configure: Likewise.

Index: configure.ac
===================================================================
*** configure.ac	(revision 150850)
--- configure.ac	(working copy)
*************** AC_ARG_ENABLE(lto,
*** 1614,1619 ****
--- 1614,1623 ----
  enable_lto=$enableval,
  enable_lto=yes; default_enable_lto=yes)
  
+ # Flags to bootstrap with -flto
+ AC_SUBST(lto_BOOT_CFLAGS)
+ AC_SUBST(lto_BOOT_LDFLAGS)
+ 
  if test x"$enable_lto" = x"yes" ; then
    # Make sure that libelf.h and gelf.h are available.
    AC_ARG_WITH(libelf, [  --with-libelf=PATH       Specify prefix directory for the installed libelf package
*************** stage1_languages=,c,
*** 1695,1700 ****
--- 1699,1712 ----
  # Target libraries that we bootstrap.
  bootstrap_target_libs=,target-libgcc,
  
+ # If we are building LTO do it as a stage1 language and bootstrap gcc
+ # with -flto
+ if test x"$enable_lto" = x"yes" ; then
+   stage1_languages=,c,lto,
+   lto_BOOT_CFLAGS=-flto
+   lto_BOOT_LDFLAGS=-flto
+ fi
+ 
  # Figure out what language subdirectories are present.
  # Look if the user specified --enable-languages="..."; if not, use
  # the environment variable $LANGUAGES if defined. $LANGUAGES might
Index: Makefile.tpl
===================================================================
*** Makefile.tpl	(revision 150850)
--- Makefile.tpl	(working copy)
*************** BUILD_PREFIX_1 = @BUILD_PREFIX_1@
*** 339,346 ****
  
  # Flags to pass to stage2 and later makes.  They are defined
  # here so that they can be overridden by Makefile fragments.
! BOOT_CFLAGS= -g -O2
! BOOT_LDFLAGS=
  BOOT_ADAFLAGS=-gnatpg -gnata
  
  BISON = @BISON@
--- 339,346 ----
  
  # Flags to pass to stage2 and later makes.  They are defined
  # here so that they can be overridden by Makefile fragments.
! BOOT_CFLAGS= -g -O2 @lto_BOOT_CFLAGS@
! BOOT_LDFLAGS= @lto_BOOT_LDFLAGS@
  BOOT_ADAFLAGS=-gnatpg -gnata
  
  BISON = @BISON@


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