On Sat, Aug 18, 2018 at 11:02 PM Iain Sandoe <i...@sandoe.co.uk> wrote: > > > Hi, > > The LTO wrappers are built and installed whether a plug-in is built or not. > > If one then tries to do --version or --help on those tools, it fails because > the > plugin is missing. A simple solution is not to try and invoke --plugin xxxx > when > we’re not building it. > > OK for trunk?
OK. Though maybe we shouldn't build & install those tools when LTO plugin support is missing... Richard. > Iain > > gcc/ > > * gcc-ar.c (main): Don’t try to invoke the plug-in if we’re not > building it. > > --- > gcc/gcc-ar.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c > index 83a9e34b7a..82e0e69ab7 100644 > --- a/gcc/gcc-ar.c > +++ b/gcc/gcc-ar.c > @@ -126,7 +126,9 @@ int > main (int ac, char **av) > { > const char *exe_name; > +#if HAVE_LTO_PLUGIN > 0 > char *plugin; > +#endif > int k, status, err; > const char *err_msg; > const char **nargv; > @@ -177,7 +179,7 @@ main (int ac, char **av) > break; > } > > - > +#if HAVE_LTO_PLUGIN > 0 > /* Find the GCC LTO plugin */ > plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK); > if (!plugin) > @@ -185,6 +187,7 @@ main (int ac, char **av) > fprintf (stderr, "%s: Cannot find plugin '%s'\n", av[0], > LTOPLUGINSONAME); > exit (1); > } > +#endif > > /* Find the wrapped binutils program. */ > exe_name = find_a_file (&target_path, PERSONALITY, X_OK); > @@ -203,9 +206,11 @@ main (int ac, char **av) > } > } > > - /* Create new command line with plugin */ > + /* Create new command line with plugin - if we have one, otherwise just > + copy the command through. */ > nargv = XCNEWVEC (const char *, ac + 4); > nargv[0] = exe_name; > +#if HAVE_LTO_PLUGIN > 0 > nargv[1] = "--plugin"; > nargv[2] = plugin; > if (is_ar && av[1] && av[1][0] != '-') > @@ -213,6 +218,13 @@ main (int ac, char **av) > for (k = 1; k < ac; k++) > nargv[2 + k] = av[k]; > nargv[2 + k] = NULL; > +#else > + if (is_ar && av[1] && av[1][0] != '-') > + av[1] = concat ("-", av[1], NULL); > + for (k = 1; k < ac; k++) > + nargv[k] = av[k]; > + nargv[k] = NULL; > +#endif > > /* Run utility */ > /* ??? the const is misplaced in pex_one's argv? */ > -- > 2.17.1 > >