PR lto/42776
* configure.ac (--enable-lto): Refactor handling so libelf tests
are only performed inside then-clause of ACX_ELF_TARGET_IFELSE,
and allow LTO to be explicitly enabled on non-ELF platforms that
are known to support it inside else-clause.
* configure: Regenerate.
gcc/ChangeLog:
PR lto/42776
* configure.ac (gcc_cv_as_section_has_align): Set if installed
binutils supports extended .section directive needed by LTO, or
warn if older binutils found.
(LTO_BINARY_READER): New AC_SUBST'd variable.
(LTO_USE_LIBELF): Likewise.
* gcc/config.gcc (lto_binary_reader): New target-specific configure
variable.
* gcc/Makefile.in (LTO_BINARY_READER): Import AC_SUBST'd autoconf var.
(LTO_USE_LIBELF): Likewise.
* configure: Regenerate.
* collect2.c (is_elf): Rename from this ...
(is_elf_or_coff): ... to this, and recognize and allow i386 COFF
object files in addition to ELF-formatted ones.
(scan_prog_file): Caller updated. Also allow for LTO info marker
symbol to be prefixed or not by an extra underscore.
* config/i386/t-cygming (winnt.o): Also depend on LTO_STREAMER_H.
* config/i386/winnt.c: Also #include lto-streamer.h
(i386_pe_asm_named_section): Specify 1-byte section alignment for
LTO named sections.
(i386_pe_asm_output_aligned_decl_common): Add comment.
(i386_pe_maybe_record_exported_symbol): Allow decl arg to be NULL.
gcc/lto/ChangeLog:
PR lto/42776
* Make-lang.in (LTO_OBJS): Use LTO_BINARY_READER instead of
hardcoding 'lto-elf.o'.
($(LTO_EXE)): Use LTO_USE_LIBELF instead of hardcoding '-lelf'.
* lto-coff.h: New file.
* lto-coff.c: Likewise.
gcc/testsuite/ChangeLog:
PR lto/42776
* lib/lto.exp (lto_prune_vis_warns): New function.
(lto-link-and-maybe-run): Call it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158762
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-04-27 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ PR lto/42776
+ * configure.ac (--enable-lto): Refactor handling so libelf tests
+ are only performed inside then-clause of ACX_ELF_TARGET_IFELSE,
+ and allow LTO to be explicitly enabled on non-ELF platforms that
+ are known to support it inside else-clause.
+ * configure: Regenerate.
+
2010-04-20 Eric Botcazou <ebotcazou@adacore.com>
* configure.ac (BUILD_CONFIG): Redirect output to /dev/null.
# know that we are building the simulator.
# binutils, gas and ld appear in that order because it makes sense to run
# "make check" in that particular order.
-# If --enable-gold is used, "gold" may replace "ld".
+# If --enable-gold is used, "gold" will replace "ld".
host_tools="texinfo byacc flex bison binutils gas ld fixincludes gcc cgen sid sim gdb make patch prms send-pr gprof etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool diff rcs fileutils shellutils time textutils wdiff find uudecode hello tar gzip indent recode release sed utils guile perl gawk findutils gettext zip fastjar gnattools"
# libgcj represents the runtime libraries only used by gcj.
esac
# Handle --enable-gold.
-# --enable-gold Build only gold
-# --disable-gold [default] Build only ld
-# --enable-gold=both Build both gold and ld, ld is default
-# --enable-gold=both/ld Same
-# --enable-gold=both/gold Build both gold and ld, gold is default, ld is renamed ld.bfd
AC_ARG_ENABLE(gold,
-[[ --enable-gold[=ARG] build gold [ARG={both}[/{gold,ld}]]]],
+[ --enable-gold use gold instead of ld],
ENABLE_GOLD=$enableval,
ENABLE_GOLD=no)
- case "${ENABLE_GOLD}" in
- yes|both|both/gold|both/ld)
- # Check for ELF target.
- is_elf=no
- case "${target}" in
- *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
- | *-*-linux* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
- | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-solaris2* | *-*-nto*)
- case "${target}" in
- *-*-linux*aout* | *-*-linux*oldld*)
- ;;
- *)
- is_elf=yes
- ;;
- esac
- esac
-
- if test "$is_elf" = "yes"; then
- # Check for target supported by gold.
+if test "${ENABLE_GOLD}" = "yes"; then
+ # Check for ELF target.
+ is_elf=no
+ case "${target}" in
+ *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
+ | *-*-linux* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
+ | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-solaris2* | *-*-nto*)
case "${target}" in
- i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-*)
- case "${ENABLE_GOLD}" in
- both*)
- configdirs="$configdirs gold"
- ;;
- *)
- configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
- ;;
- esac
- ENABLE_GOLD=yes
+ *-*-linux*aout* | *-*-linux*oldld*)
+ ;;
+ *)
+ is_elf=yes
;;
esac
- fi
- ;;
- no)
- ;;
- *)
- AC_MSG_ERROR([invalid --enable-gold argument])
- ;;
esac
+ if test "$is_elf" = "yes"; then
+ # Check for target supported by gold.
+ case "${target}" in
+ i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-*)
+ configdirs="`echo " ${configdirs} " | sed -e 's/ ld / gold /'`"
+ ;;
+ esac
+ fi
+fi
+
# Configure extra directories which are host specific
case "${host}" in
AC_SUBST(poststage1_ldflags)
# Check for PPL
+ppl_major_version=0
+ppl_minor_version=10
ppllibs=" -lppl_c -lppl -lgmpxx"
pplinc=
if test "x$with_ppl" != "xno" -a "${ENABLE_PPL_CHECK}" = "yes"; then
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $pplinc $gmpinc"
- AC_MSG_CHECKING([for version 0.10 (or later revision) of PPL])
+ AC_MSG_CHECKING([for version $ppl_major_version.$ppl_minor_version of PPL])
AC_TRY_COMPILE([#include "ppl_c.h"],[
- #if PPL_VERSION_MAJOR != 0 || PPL_VERSION_MINOR < 10
+ #if PPL_VERSION_MAJOR != $ppl_major_version || PPL_VERSION_MINOR != $ppl_minor_version
choke me
#endif
], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); ppllibs= ; pplinc= ; with_ppl=no ])
# -flto it won't be needed until after installation anyway.
case $target in
*-cygwin*|*-mingw*) ;;
- *-apple-darwin*) ;;
*) if test x"$enable_lto" = x"yes"; then
AC_MSG_ERROR([LTO support is not enabled for this target.])
fi
# to it. This is right: we don't want to search that directory
# for binaries, but we want the header files in there, so add
# them explicitly.
- FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -isystem $$r/$(HOST_SUBDIR)/gcc/include -isystem $$r/$(HOST_SUBDIR)/gcc/include-fixed'
+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -isystem $$r/$(HOST_SUBDIR)/gcc/include'
# Someone might think of using the pre-installed headers on
# Canadian crosses, in case the installed compiler is not fully
# define SIGCHLD SIGCLD
#endif
-/* TARGET_64BIT may be defined to use driver specific functionality. */
-#undef TARGET_64BIT
-#define TARGET_64BIT TARGET_64BIT_DEFAULT
-
#ifndef LIBRARY_PATH_ENV
#define LIBRARY_PATH_ENV "LIBRARY_PATH"
#endif
int number;
};
-bool vflag; /* true if -v or --version */
+int vflag; /* true if -v */
static int rflag; /* true if -r */
static int strip_flag; /* true if -s */
static const char *demangle_flag;
/* Current LTO mode. */
static enum lto_mode_d lto_mode = LTO_MODE_NONE;
-bool debug; /* true if -debug */
-bool helpflag; /* true if --help */
+int debug; /* true if -debug */
static int shared_obj; /* true if -shared */
if (lto_objects.first)
{
+ const char *opts;
char **lto_c_argv;
const char **lto_c_ptr;
+ const char *cp;
const char **p, **q, **r;
const char **lto_o_ptr;
struct lto_object *list;
if (!lto_wrapper)
fatal ("COLLECT_LTO_WRAPPER must be set.");
- num_lto_c_args++;
-
/* There is at least one object file containing LTO info,
so we need to run the LTO back end and relink. */
+ /* Get compiler options passed down from the parent `gcc' command.
+ These must be passed to the LTO back end. */
+ opts = getenv ("COLLECT_GCC_OPTIONS");
+
+ /* Increment the argument count by the number of inherited options.
+ Some arguments may be filtered out later. Again, an upper bound
+ suffices. */
+
+ cp = opts;
+
+ while (cp && *cp)
+ {
+ extract_string (&cp);
+ num_lto_c_args++;
+ }
+ obstack_free (&temporary_obstack, temporary_firstobj);
+
+ if (debug)
+ num_lto_c_args++;
+
+ /* Increment the argument count by the number of initial
+ arguments added below. */
+ num_lto_c_args += 9;
+
lto_c_argv = (char **) xcalloc (sizeof (char *), num_lto_c_args);
lto_c_ptr = CONST_CAST2 (const char **, char **, lto_c_argv);
*lto_c_ptr++ = lto_wrapper;
+ *lto_c_ptr++ = c_file_name;
+
+ cp = opts;
+
+ while (cp && *cp)
+ {
+ const char *s = extract_string (&cp);
+
+ /* Pass the option or argument to the wrapper. */
+ *lto_c_ptr++ = xstrdup (s);
+ }
+ obstack_free (&temporary_obstack, temporary_firstobj);
+
+ if (debug)
+ *lto_c_ptr++ = xstrdup ("-debug");
/* Add LTO objects to the wrapper command line. */
for (list = lto_objects.first; list; list = list->next)
*lto_c_ptr = NULL;
+ /* Save intermediate WPA files in lto1 if debug. */
+ if (debug)
+ putenv (xstrdup ("WPA_SAVE_LTRANS=1"));
+
/* Run the LTO back end. */
pex = collect_execute (prog, lto_c_argv, NULL, NULL, PEX_SEARCH);
{
for (i = 1; argv[i] != NULL; i ++)
{
if (! strcmp (argv[i], "-debug"))
- debug = true;
+ debug = 1;
else if (! strcmp (argv[i], "-flto") && ! use_plugin)
{
use_verbose = true;
if (use_verbose && *q == '-' && q[1] == 'v' && q[2] == 0)
{
/* Turn on trace in collect2 if needed. */
- vflag = true;
+ vflag = 1;
}
}
obstack_free (&temporary_obstack, temporary_firstobj);
case 'v':
if (arg[2] == '\0')
- vflag = true;
+ vflag = 1;
break;
case '-':
}
else if (strncmp (arg, "--sysroot=", 10) == 0)
target_system_root = arg + 10;
- else if (strncmp (arg, "--version", 9) == 0)
- vflag = true;
- else if (strncmp (arg, "--help", 9) == 0)
- helpflag = true;
break;
}
}
fprintf (stderr, "\n");
}
- if (helpflag)
- {
- fprintf (stderr, "Usage: collect2 [options]\n");
- fprintf (stderr, " Wrap linker and generate constructor code if needed.\n");
- fprintf (stderr, " Options:\n");
- fprintf (stderr, " -debug Enable debug output\n");
- fprintf (stderr, " --help Display this information\n");
- fprintf (stderr, " -v, --version Display this program's version number\n");
- fprintf (stderr, "Overview: http://gcc.gnu.org/onlinedocs/gccint/Collect2.html\n");
- fprintf (stderr, "Report bugs: %s\n", bug_report_url);
-
- collect_exit (0);
- }
-
if (debug)
{
const char *ptr;
if (export_file != 0 && export_file[0])
maybe_unlink (export_file);
#endif
- if (lto_mode != LTO_MODE_NONE)
+ if (lto_mode)
maybe_run_lto_and_relink (ld1_argv, object_lst, object, false);
maybe_unlink (c_file);
\f
#ifdef OBJECT_FORMAT_NONE
-/* Check to make sure the file is an LTO object file. */
+/* Check to make sure the file is an ELF file. LTO objects must
+ be in ELF format. */
static bool
-maybe_lto_object_file (const char *prog_name)
+is_elf_or_coff (const char *prog_name)
{
FILE *f;
- unsigned char buf[4];
- int i;
-
- static unsigned char elfmagic[4] = { 0x7f, 'E', 'L', 'F' };
- static unsigned char coffmagic[2] = { 0x4c, 0x01 };
- static unsigned char coffmagic_x64[2] = { 0x64, 0x86 };
- static unsigned char machomagic[4][4] = {
- { 0xcf, 0xfa, 0xed, 0xfe },
- { 0xce, 0xfa, 0xed, 0xfe },
- { 0xfe, 0xed, 0xfa, 0xcf },
- { 0xfe, 0xed, 0xfa, 0xce }
- };
+ char buf[4];
+ static char magic[4] = { 0x7f, 'E', 'L', 'F' };
+ static char coffmag[2] = { 0x4c, 0x01 };
f = fopen (prog_name, "rb");
if (f == NULL)
if (fread (buf, sizeof (buf), 1, f) != 1)
buf[0] = 0;
fclose (f);
-
- if (memcmp (buf, elfmagic, sizeof (elfmagic)) == 0
- || memcmp (buf, coffmagic, sizeof (coffmagic)) == 0
- || memcmp (buf, coffmagic_x64, sizeof (coffmagic_x64)) == 0)
- return true;
- for (i = 0; i < 4; i++)
- if (memcmp (buf, machomagic[i], sizeof (machomagic[i])) == 0)
- return true;
-
- return false;
+ return memcmp (buf, magic, sizeof (magic)) == 0
+ || memcmp (buf, coffmag, sizeof (coffmag)) == 0;
}
/* Generic version to scan the name list of the loaded program for
/* LTO objects must be in a known format. This check prevents
us from accepting an archive containing LTO objects, which
gcc cannnot currently handle. */
- if (which_pass == PASS_LTOINFO && !maybe_lto_object_file (prog_name))
+ if (which_pass == PASS_LTOINFO && !is_elf_or_coff (prog_name))
return;
/* If we do not have an `nm', complain. */
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 17095 "configure"
+#line 17097 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 17201 "configure"
+#line 17203 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
+2010-04-27 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ PR lto/42776
+ * Make-lang.in (LTO_OBJS): Use LTO_BINARY_READER instead of
+ hardcoding 'lto-elf.o'.
+ ($(LTO_EXE)): Use LTO_USE_LIBELF instead of hardcoding '-lelf'.
+
+ * lto-coff.h: New file.
+ * lto-coff.c: Likewise.
+
2010-04-26 Richard Guenther <rguenther@suse.de>
* lto.c (lto_fixup_type): Deal with non-type TYPE_CONTEXT.
$(CGRAPH_H) $(GGC_H) tree-ssa-operands.h $(TREE_PASS_H) \
langhooks.h vec.h $(BITMAP_H) pointer-set.h $(IPA_PROP_H) \
$(COMMON_H) $(TIMEVAR_H) $(GIMPLE_H) $(LTO_H) $(LTO_TREE_H) \
- $(LTO_TAGS_H) $(LTO_STREAMER_H) gt-lto-lto.h
+ $(LTO_TAGS_H) $(LTO_STREAMER_H)
lto/lto-elf.o: lto/lto-elf.c $(CONFIG_H) coretypes.h $(SYSTEM_H) \
toplev.h $(LTO_H) $(TM_H) $(LIBIBERTY_H) $(GGC_H) $(LTO_STREAMER_H)
lto/lto-coff.o: lto/lto-coff.c $(CONFIG_H) coretypes.h $(SYSTEM_H) \
toplev.h $(LTO_H) $(TM_H) $(LIBIBERTY_H) $(GGC_H) $(LTO_STREAMER_H) \
lto/lto-coff.h
-lto/lto-macho.o: lto/lto-macho.c $(CONFIG_H) coretypes.h $(SYSTEM_H) \
- toplev.h $(LTO_H) $(TM_H) $(LIBIBERTY_H) $(GGC_H) $(LTO_STREAMER_H) \
- lto/lto-macho.h lto/lto-endian.h
return false;
}
- if (mach != IMAGE_FILE_MACHINE_AMD64
- && COFF_CHARACTERISTICS != (COFF_CHARACTERISTICS & charact))
+ if (COFF_CHARACTERISTICS != (COFF_CHARACTERISTICS & charact))
{
- /* ECOFF/XCOFF support not implemented. */
+ /* ECOFF/XCOFF/PE+ support not implemented. */
error ("not a 32-bit COFF object file");
return false;
}
/* COFF header machine codes. */
#define IMAGE_FILE_MACHINE_I386 (0x014c)
-#define IMAGE_FILE_MACHINE_AMD64 (0x8664)
/* Known header magics for validation, as an array initialiser. */
#define COFF_KNOWN_MACHINES \
- { IMAGE_FILE_MACHINE_I386, \
- IMAGE_FILE_MACHINE_AMD64/*, ... add more here when working. */ }
+ { IMAGE_FILE_MACHINE_I386/*, ... add more here when working. */ }
/* COFF object file header, section and symbol flags and types. These are
currently specific to PE-COFF, which is the only LTO-COFF format at the
+2010-04-27 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ PR lto/42776
+ * lib/lto.exp (lto_prune_vis_warns): New function.
+ (lto-link-and-maybe-run): Call it.
+
2010-04-26 H.J. Lu <hongjiu.lu@intel.com>
PR tree-optimization/43904
-# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# Contributed by Diego Novillo <dnovillo@google.com>
-# Prune messages that aren't useful.
+# Prune messages from gcc that aren't useful.
-proc lto_prune_warns { text } {
-
- verbose "lto_prune_warns: entry: $text" 2
+proc lto_prune_vis_warns { text } {
# Many tests that use visibility will still pass on platforms that don't support it.
regsub -all "(^|\n)\[^\n\]*: warning: visibility attribute not supported in this configuration; ignored\[^\n\]*" $text "" text
# And any stray location lines.
regsub -all "(^|\n)\[^\n\]*: In function \[^\n\]*" $text "" text
- regsub -all "(^|\n)In file included from \[^\n\]*" $text "" text
- regsub -all "(^|\n)\[ \t\]*from \[^\n\]*" $text "" text
-
- # Sun ld warns about common symbols with differing sizes. Unlike GNU ld
- # --warn-common (off by default), they cannot be disabled.
- regsub -all "(^|\n)ld: warning: symbol `\[^\n\]*' has differing sizes:" $text "" text
- regsub -all "(^|\n)\[ \t\]*\[\(\]file \[^\n\]* value=\[^\n\]*; file \[^\n\]* value=\[^\n\]*\[)\];" $text "" text
- regsub -all "(^|\n)\[ \t\]*\[^\n\]* definition taken" $text "" text
-
- verbose "lto_prune_warns: exit: $text" 2
+ regsub -all "(^|\n)In file included from :\[^\n\]*" $text "" text
return $text
}
set compiler_conditional_xfail_data $xfaildata
set comp_output [${tool}_target_compile "$source" "$dest" object $options]
- # Prune unimportant visibility warnings before checking output.
- set comp_output [lto_prune_warns $comp_output]
${tool}_check_compile "$testcase $dest assemble" $optstr $dest $comp_output
}
"$options"]
# Prune unimportant visibility warnings before checking output.
- set comp_output [lto_prune_warns $comp_output]
+ set comp_output [lto_prune_vis_warns $comp_output]
if ![${tool}_check_compile "$testcase $testname link" "" \
$dest $comp_output] then {