Skip to content

Commit

Permalink
support -flto
Browse files Browse the repository at this point in the history
  • Loading branch information
bebbo committed Jan 13, 2019
1 parent 627f272 commit 2fff171
Show file tree
Hide file tree
Showing 11 changed files with 661 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .settings/language.settings.xml
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin" console="false" env-hash="1193008743258704772" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cygwin" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin" console="false" env-hash="-1643496762141181171" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cygwin" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1284202475555273847" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1284625475479736847" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion .settings/org.eclipse.cdt.core.prefs
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
environment/project/cdt.managedbuild.config.gnu.cross.exe.debug.452878522/PATH/delimiter=;
environment/project/cdt.managedbuild.config.gnu.cross.exe.debug.452878522/PATH/operation=replace
environment/project/cdt.managedbuild.config.gnu.cross.exe.debug.452878522/PATH/value=C\:\\WINDOWS\\system32;C\:\\WINDOWS;C\:\\Program Files\\SlikSvn\\bin;C\:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0;c\:\\cygwin\\bin;D\:\\develop\\workspaces\\c1\\amigaos-cross-toolchain\\m68k-amigaos\\bin
environment/project/cdt.managedbuild.config.gnu.cross.exe.debug.452878522/PATH/value=C\:\\WINDOWS\\system32;C\:\\WINDOWS;C\:\\Program Files\\SlikSvn\\bin;C\:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0;c\:\\cygwin\\bin;c\:\\cygwin\\opt\\amiga\\bin
environment/project/cdt.managedbuild.config.gnu.cross.exe.debug.452878522/append=true
environment/project/cdt.managedbuild.config.gnu.cross.exe.debug.452878522/appendContributed=true
org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=18
Expand Down
2 changes: 1 addition & 1 deletion gcc/DATESTAMP
@@ -1 +1 @@
20190106170304
20190113212543
79 changes: 59 additions & 20 deletions gcc/collect2.c
Expand Up @@ -1307,6 +1307,8 @@ main (int argc, char **argv)
/* Do not pass LTO flag to the linker. */
ld1--;
ld2--;

lto_mode = LTO_MODE_LTO;
#else
error ("LTO support has not been enabled in this "
"configuration");
Expand Down Expand Up @@ -1670,7 +1672,7 @@ main (int argc, char **argv)
expect the relevant tables to be dragged together with their associated
functions from precise cross reference insertions by the compiler. */

if (early_exit || ld1_filter != SCAN_NOTHING)
if (early_exit || (ld1_filter != SCAN_NOTHING && lto_mode != LTO_MODE_LTO))
do_tlink (ld1_argv, object_lst);

if (early_exit)
Expand Down Expand Up @@ -2333,28 +2335,65 @@ maybe_lto_object_file (const char *prog_name)
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 },
{ 0xcf, 0xfa, 0xed, 0xfe },
{ 0xce, 0xfa, 0xed, 0xfe },
{ 0xfe, 0xed, 0xfa, 0xcf },
{ 0xfe, 0xed, 0xfa, 0xce }
};

f = fopen (prog_name, "rb");
if (f == NULL)
return false;
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;
bool r = false;
do
{ // while (0)

f = fopen (prog_name, "rb");
if (f == NULL)
break;
if (fread (buf, sizeof(buf), 1, f) != 1)
break;

if (memcmp (buf, elfmagic, sizeof(elfmagic)) == 0
|| memcmp (buf, coffmagic, sizeof(coffmagic)) == 0
|| memcmp (buf, coffmagic_x64, sizeof(coffmagic_x64)) == 0)
{
r = true;
break;
}
for (i = 0; i < 4; i++)
if (memcmp (buf, machomagic[i], sizeof(machomagic[i])) == 0)
{
r = true;
break;
}

#ifdef TARGET_AMIGA
if (buf[0] == 0 && buf[1] == 0 && buf[2] == 3 && buf[3] == 0xe7)
{
// skip file name
if (fread (buf, sizeof(buf), 1, f) != 1)
break;
unsigned len = (buf[1] << 16) | (buf[2] << 8) | buf[3];
if (fseek(f, len * 4 + 0x34, SEEK_CUR))
break;

if (fread (buf, sizeof(buf), 1, f) != 1)
break;
// symbol
if (buf[0] != 0x82)
break;
len = (buf[1] << 16) | (buf[2] << 8) | buf[3];
if (len != 4)
break;
char name[16];
if (fread (name, sizeof(name), 1, f) != 1)
break;
r = 0 == strcmp("___gnu_lto_v1", name);
}
#endif
}
while (0);
if (f)
fclose (f);
return r;
}

/* Generic version to scan the name list of the loaded program for
Expand Down
47 changes: 26 additions & 21 deletions gcc/config/m68k/amigaos.c
Expand Up @@ -674,8 +674,10 @@ amiga_named_section (const char *name, unsigned int flags, tree decl )

if (0 == strncmp(".data", name, 5) && (!DECL_INITIAL (decl) || initializer_zerop (DECL_INITIAL (decl))))
fprintf (asm_out_file, "\t.bss%s\n", name + 5);
else
else if (0 == strncmp(".section ", name, 8) || 0 == strncmp(".text", name, 5) || 0 == strncmp(".data", name, 5) || 0 == strncmp(".bss", name, 4))
fprintf (asm_out_file, "\t%s\n", name);
else
fprintf (asm_out_file, "\t.section %s\n", name);
}
#else
extern void
Expand All @@ -690,26 +692,29 @@ amiga_named_section (const char *name, unsigned int flags, tree decl ATTRIBUTE_U
}
else
{
if (0 == strncmp(".data", name, 5) && (!DECL_INITIAL (decl) || initializer_zerop (DECL_INITIAL (decl)))) {
fprintf (asm_out_file, "\tsection .bss%s%s,bss\n", name[5]==0 ? "" : "_", name + 5);
} else {
if (0 == strncmp(".datafar", name, 8))
{
fprintf (asm_out_file, "\tsection .data_far,data\n");
}
else if (0 == strncmp(".datachip", name, 9))
{
fprintf (asm_out_file, "\tsection .data_chip,data,chip\n");
}
else if (0 == strncmp(".bsschip", name, 8))
{
fprintf (asm_out_file, "\tsection .bss_chip,bss,chip\n");
}
else
{
fprintf (asm_out_file, "\tsection %s\n", name);
}
}
if (0 == strncmp(".data", name, 5) && (!DECL_INITIAL (decl) || initializer_zerop (DECL_INITIAL (decl))))
{
fprintf (asm_out_file, "\tsection .bss%s%s,bss\n", name[5]==0 ? "" : "_", name + 5);
}
else
{
if (0 == strncmp(".datafar", name, 8))
{
fprintf (asm_out_file, "\tsection .data_far,data\n");
}
else if (0 == strncmp(".datachip", name, 9))
{
fprintf (asm_out_file, "\tsection .data_chip,data,chip\n");
}
else if (0 == strncmp(".bsschip", name, 8))
{
fprintf (asm_out_file, "\tsection .bss_chip,bss,chip\n");
}
else
{
fprintf (asm_out_file, "\tsection %s\n", name);
}
}
}
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions gcc/config/m68k/m68kamigaos.h
Expand Up @@ -585,6 +585,7 @@ if (target_flags & (MASK_RESTORE_A4|MASK_ALWAYS_RESTORE_A4)) \
"%{!nostdlib:%{!nodefaultlibs:%L}} " \
"%{!A:%{!nostdlib:%{!nostartfiles:%E}}} " \
"%{!nostdlib:%{!nodefaultlibs:%G}} " \
"%{flto} " \
"%{T*} }}}}}} "
#else
#define LINK_COMMAND_SPEC \
Expand All @@ -601,6 +602,7 @@ if (target_flags & (MASK_RESTORE_A4|MASK_ALWAYS_RESTORE_A4)) \
"%{!nostdlib:%{!nodefaultlibs:%L}} " \
"%{!A:%{!nostdlib:%{!nostartfiles:%E}}} " \
"%{!nostdlib:%{!nodefaultlibs:%G}} " \
"%{flto} " \
"%{T*} }}}}}} "
#endif

Expand Down Expand Up @@ -685,6 +687,8 @@ amigaos_prelink_hook((const char **)(LD1_ARGV), (STRIP))
#define COLLECT2_POSTLINK_HOOK(OUTPUT_FILE) amigaos_postlink_hook(OUTPUT_FILE)
/* end-GG-local */

#define USE_COLLECT2

#undef MAX_OFILE_ALIGNMENT
#define MAX_OFILE_ALIGNMENT ((1 << 15)*BITS_PER_UNIT)

Expand Down
4 changes: 4 additions & 0 deletions gcc/lto-compress.c
Expand Up @@ -266,7 +266,11 @@ lto_end_uncompression (struct lto_compression_stream *stream)
gcc_assert (!stream->is_compression);
timevar_push (TV_IPA_LTO_DECOMPRESS);

#ifdef TARGET_AMIGA
while (remaining > 3)
#else
while (remaining > 0)
#endif
{
z_stream in_stream;
size_t out_bytes;
Expand Down
15 changes: 13 additions & 2 deletions libiberty/Makefile.in
Expand Up @@ -148,7 +148,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \
random.c regex.c rename.c rindex.c \
safe-ctype.c setenv.c setproctitle.c sha1.c sigsetmask.c \
simple-object.c simple-object-coff.c simple-object-elf.c \
simple-object-mach-o.c simple-object-xcoff.c \
simple-object-mach-o.c simple-object-xcoff.c simple-object-amigahunk.c \
snprintf.c sort.c \
spaces.c splay-tree.c stack-limit.c stpcpy.c stpncpy.c \
strcasecmp.c strchr.c strdup.c strerror.c strncasecmp.c \
Expand Down Expand Up @@ -186,7 +186,7 @@ REQUIRED_OFILES = \
./safe-ctype.$(objext) \
./simple-object.$(objext) ./simple-object-coff.$(objext) \
./simple-object-elf.$(objext) ./simple-object-mach-o.$(objext) \
./simple-object-xcoff.$(objext) \
./simple-object-xcoff.$(objext) ./simple-object-amigahunk.$(objext) \
./sort.$(objext) ./spaces.$(objext) \
./splay-tree.$(objext) ./stack-limit.$(objext) \
./strerror.$(objext) ./strsignal.$(objext) \
Expand Down Expand Up @@ -1282,6 +1282,17 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir
else true; fi
$(COMPILE.c) $(srcdir)/simple-object-xcoff.c $(OUTPUT_OPTION)

./simple-object-amigahunk.$(objext): $(srcdir)/simple-object-amigahunk.c config.h \
$(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
$(srcdir)/simple-object-common.h $(INCDIR)/simple-object.h
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(srcdir)/simple-object-amigahunk.c -o pic/$@; \
else true; fi
if [ x"$(NOASANFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/simple-object-amigahunk.c -o noasan/$@; \
else true; fi
$(COMPILE.c) $(srcdir)/simple-object-amigahunk.c $(OUTPUT_OPTION)

./simple-object.$(objext): $(srcdir)/simple-object.c config.h \
$(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
$(srcdir)/simple-object-common.h $(INCDIR)/simple-object.h
Expand Down

0 comments on commit 2fff171

Please sign in to comment.