This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix -fwhole-program part 1
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, rguenther at suse dot de
- Date: Tue, 6 Oct 2009 17:53:17 +0200
- Subject: Fix -fwhole-program part 1
Hi,
gcc.c contains code that strips down -fwhole-program from flags passed to collect2.
This effectivly elliminate any way to enable -fwhole-program optimizations with LTO.
The patch replace it by code adding -fno-whole-program to argument list
when compiling fini/init routines. I don't have host that actually needs them,
but I hope it is sufficient to fix the issue.
Bootstrapped/regtested x86_64-linux, OK?
* gcc.c (set_collect_gcc_options): Do not remove -fwhole-program here.
* collect.c (main): Add -fno-whole-program.
Index: gcc.c
===================================================================
*** gcc.c (revision 152449)
--- gcc.c (working copy)
*************** set_collect_gcc_options (void)
*** 4633,4643 ****
if ((switches[i].live_cond & SWITCH_IGNORE) != 0)
continue;
- /* Don't use -fwhole-program when compiling the init and fini routines,
- since we'd wrongly assume that the routines aren't needed. */
- if (strcmp (switches[i].part1, "fwhole-program") == 0)
- continue;
-
obstack_grow (&collect_obstack, "'-", 2);
q = switches[i].part1;
while ((p = strchr (q, '\'')))
--- 4633,4638 ----
Index: collect2.c
===================================================================
*** collect2.c (revision 152449)
--- collect2.c (working copy)
*************** main (int argc, char **argv)
*** 1439,1444 ****
--- 1439,1445 ----
*c_ptr++ = "-fno-test-coverage";
*c_ptr++ = "-fno-branch-probabilities";
*c_ptr++ = "-fno-exceptions";
+ *c_ptr++ = "-fno-whole-program";
*c_ptr++ = "-w";
/* !!! When GCC calls collect2,