This doesn't get very far yet, but it's the start of what I imagine the
lto-wrapper changes will look like.
Bernd
Index: gomp-4_0-branch/gcc/lto-wrapper.c
===================================================================
--- gomp-4_0-branch.orig/gcc/lto-wrapper.c
+++ gomp-4_0-branch/gcc/lto-wrapper.c
@@ -47,6 +47,8 @@ along with GCC; see the file COPYING3.
#include "options.h"
#include "simple-object.h"
#include "lto-section-names.h"
+#include "vec.h"
+#include "out-targets.h"
/* End of lto-streamer.h copy. */
@@ -443,6 +445,34 @@ merge_and_complain (struct cl_decoded_op
}
}
+static int
+mark_out_targets (void *, const char *name, off_t, off_t)
+{
+ size_t len = strlen (LTO_TARGET_SECTION_NAME_PREFIX);
+ if (strncmp (name, LTO_TARGET_SECTION_NAME_PREFIX, len) != 0)
+ return 1;
+ name += len;
+ unsigned i;
+ target_machine *m;
+ bool matched = false;
+ FOR_EACH_VEC_ELT (target_machines, i, m)
+ {
+ size_t tlen = strlen (m->triplet);
+ if (tlen == 0)
+ continue;
+ if (strncmp (name, m->triplet, tlen) == 0)
+ {
+ m->used = true;
+ matched = true;
+ printf ("found target %s in section %s\n", m->triplet, name);
+ }
+ }
+ if (!matched)
+ fatal ("unrecognized output target found in LTO input section %s", name);
+
+ return 1;
+}
+
/* Execute gcc. ARGC is the number of arguments. ARGV contains the arguments. */
static void
@@ -511,6 +541,8 @@ run_gcc (unsigned argc, char *argv[])
close (fd);
continue;
}
+
+ simple_object_find_sections (sobj, mark_out_targets, NULL, &err);
if (!simple_object_find_section (sobj, LTO_SECTION_NAME_PREFIX "." "opts",
&offset, &length, &errmsg, &err))
{
@@ -937,6 +969,8 @@ main (int argc, char *argv[])
gcc_init_libintl ();
+ init_out_targets ();
+
diagnostic_initialize (global_dc, 0);
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
Index: gomp-4_0-branch/gcc/Makefile.in
===================================================================
--- gomp-4_0-branch.orig/gcc/Makefile.in
+++ gomp-4_0-branch/gcc/Makefile.in
@@ -1906,9 +1907,10 @@ collect2$(exeext): $(COLLECT2_OBJS) $(LI
CFLAGS-collect2.o += -DTARGET_MACHINE=\"$(target_noncanonical)\" \
@TARGET_SYSTEM_ROOT_DEFINE@
-lto-wrapper$(exeext): lto-wrapper.o ggc-none.o libcommon-target.a $(LIBDEPS)
+lto-wrapper$(exeext): lto-wrapper.o out-targets.o ggc-none.o \
+ libcommon-target.a $(LIBDEPS)
+$(LINKER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o T$@ \
- lto-wrapper.o ggc-none.o libcommon-target.a $(LIBS)
+ lto-wrapper.o out-targets.o ggc-none.o libcommon-target.a $(LIBS)
mv -f T$@ $@
# Files used by all variants of C or by the stand-alone pre-processor.