Message ID | 20120207091130.GV18768@tyan-ft48-01.lab.bos.redhat.com |
---|---|
State | New |
Headers | show |
On Tue, Feb 7, 2012 at 10:11 AM, Jakub Jelinek <jakub@redhat.com> wrote: > Hi! > > In Fedora (but several other distros do the same) we ship cpp > as a separate package, unfortunately the lto plugin support means (IMHO > unnecessarily) that the plugin needs to be included in the cpp package > rather than gcc, because the driver looks for the plugin and complains > if not found even when the driver is cpp (or for gcc -E/-S/-c). > I think we only need it when actually linking, so this patch should save > some unnecessary syscalls on every -E/-S/-c preprocessing/compilation > as well as make /usr/bin/cpp only need cc1 and no other files. > have_c is a variable used in a couple of places earlier. Ok. Thanks, Richard. > 2012-02-07 Jakub Jelinek <jakub@redhat.com> > > * gcc.c (main): Don't look for lto-wrapper or lto-wrapper > or LTOPLUGINSONAME if have_c. > > --- gcc/gcc.c.jj 2012-01-30 00:10:01.000000000 +0100 > +++ gcc/gcc.c 2012-02-07 10:03:44.777138464 +0100 > @@ -6447,7 +6447,11 @@ main (int argc, char **argv) > > /* Set up to remember the pathname of the lto wrapper. */ > > - lto_wrapper_file = find_a_file (&exec_prefixes, "lto-wrapper", X_OK, false); > + if (have_c) > + lto_wrapper_file = NULL; > + else > + lto_wrapper_file = find_a_file (&exec_prefixes, "lto-wrapper", > + X_OK, false); > if (lto_wrapper_file) > { > lto_wrapper_spec = lto_wrapper_file; > @@ -6821,39 +6825,46 @@ warranty; not even for MERCHANTABILITY o > if (num_linker_inputs > 0 && !seen_error () && print_subprocess_help < 2) > { > int tmp = execution_count; > + > + if (! have_c) > + { > #if HAVE_LTO_PLUGIN > 0 > #if HAVE_LTO_PLUGIN == 2 > - const char *fno_use_linker_plugin = "fno-use-linker-plugin"; > + const char *fno_use_linker_plugin = "fno-use-linker-plugin"; > #else > - const char *fuse_linker_plugin = "fuse-linker-plugin"; > + const char *fuse_linker_plugin = "fuse-linker-plugin"; > #endif > #endif > > - /* We'll use ld if we can't find collect2. */ > - if (! strcmp (linker_name_spec, "collect2")) > - { > - char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false); > - if (s == NULL) > - linker_name_spec = "ld"; > - } > + /* We'll use ld if we can't find collect2. */ > + if (! strcmp (linker_name_spec, "collect2")) > + { > + char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false); > + if (s == NULL) > + linker_name_spec = "ld"; > + } > > #if HAVE_LTO_PLUGIN > 0 > #if HAVE_LTO_PLUGIN == 2 > - if (!switch_matches (fno_use_linker_plugin, > - fno_use_linker_plugin + strlen (fno_use_linker_plugin), 0)) > + if (!switch_matches (fno_use_linker_plugin, > + fno_use_linker_plugin > + + strlen (fno_use_linker_plugin), 0)) > #else > - if (switch_matches (fuse_linker_plugin, > - fuse_linker_plugin + strlen (fuse_linker_plugin), 0)) > + if (switch_matches (fuse_linker_plugin, > + fuse_linker_plugin > + + strlen (fuse_linker_plugin), 0)) > #endif > - { > - linker_plugin_file_spec = find_a_file (&exec_prefixes, > - LTOPLUGINSONAME, R_OK, > - false); > - if (!linker_plugin_file_spec) > - fatal_error ("-fuse-linker-plugin, but %s not found", LTOPLUGINSONAME); > - } > + { > + linker_plugin_file_spec = find_a_file (&exec_prefixes, > + LTOPLUGINSONAME, R_OK, > + false); > + if (!linker_plugin_file_spec) > + fatal_error ("-fuse-linker-plugin, but %s not found", > + LTOPLUGINSONAME); > + } > #endif > - lto_gcc_spec = argv[0]; > + lto_gcc_spec = argv[0]; > + } > > /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables > for collect. */ > > Jakub
--- gcc/gcc.c.jj 2012-01-30 00:10:01.000000000 +0100 +++ gcc/gcc.c 2012-02-07 10:03:44.777138464 +0100 @@ -6447,7 +6447,11 @@ main (int argc, char **argv) /* Set up to remember the pathname of the lto wrapper. */ - lto_wrapper_file = find_a_file (&exec_prefixes, "lto-wrapper", X_OK, false); + if (have_c) + lto_wrapper_file = NULL; + else + lto_wrapper_file = find_a_file (&exec_prefixes, "lto-wrapper", + X_OK, false); if (lto_wrapper_file) { lto_wrapper_spec = lto_wrapper_file; @@ -6821,39 +6825,46 @@ warranty; not even for MERCHANTABILITY o if (num_linker_inputs > 0 && !seen_error () && print_subprocess_help < 2) { int tmp = execution_count; + + if (! have_c) + { #if HAVE_LTO_PLUGIN > 0 #if HAVE_LTO_PLUGIN == 2 - const char *fno_use_linker_plugin = "fno-use-linker-plugin"; + const char *fno_use_linker_plugin = "fno-use-linker-plugin"; #else - const char *fuse_linker_plugin = "fuse-linker-plugin"; + const char *fuse_linker_plugin = "fuse-linker-plugin"; #endif #endif - /* We'll use ld if we can't find collect2. */ - if (! strcmp (linker_name_spec, "collect2")) - { - char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false); - if (s == NULL) - linker_name_spec = "ld"; - } + /* We'll use ld if we can't find collect2. */ + if (! strcmp (linker_name_spec, "collect2")) + { + char *s = find_a_file (&exec_prefixes, "collect2", X_OK, false); + if (s == NULL) + linker_name_spec = "ld"; + } #if HAVE_LTO_PLUGIN > 0 #if HAVE_LTO_PLUGIN == 2 - if (!switch_matches (fno_use_linker_plugin, - fno_use_linker_plugin + strlen (fno_use_linker_plugin), 0)) + if (!switch_matches (fno_use_linker_plugin, + fno_use_linker_plugin + + strlen (fno_use_linker_plugin), 0)) #else - if (switch_matches (fuse_linker_plugin, - fuse_linker_plugin + strlen (fuse_linker_plugin), 0)) + if (switch_matches (fuse_linker_plugin, + fuse_linker_plugin + + strlen (fuse_linker_plugin), 0)) #endif - { - linker_plugin_file_spec = find_a_file (&exec_prefixes, - LTOPLUGINSONAME, R_OK, - false); - if (!linker_plugin_file_spec) - fatal_error ("-fuse-linker-plugin, but %s not found", LTOPLUGINSONAME); - } + { + linker_plugin_file_spec = find_a_file (&exec_prefixes, + LTOPLUGINSONAME, R_OK, + false); + if (!linker_plugin_file_spec) + fatal_error ("-fuse-linker-plugin, but %s not found", + LTOPLUGINSONAME); + } #endif - lto_gcc_spec = argv[0]; + lto_gcc_spec = argv[0]; + } /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables for collect. */