On Wed, May 6, 2020 at 3:09 PM Martin Liška <mli...@suse.cz> wrote:
>
> On 5/6/20 2:52 PM, Richard Biener wrote:
> > On Wed, May 6, 2020 at 2:08 PM Martin Liška <mli...@suse.cz> wrote:
> >>
> >> Hi.
> >>
> >> The patch splits arguments in getenv ("MAKE") so that one can use:
> >>
> >> $ MAKE="make -s" gcc main.o -flto=16
> >>
> >> Right now it fails due to:
> >> [pid  6004] execve("/home/marxin/Programming/script-misc/make -s", ["make 
> >> -s", "-f", "/tmp/ccNpRBlZ.mk", "-j16", "all"], 0x4b69b0 /* 82 vars */) = 
> >> -1 ENOENT (No such file or directory)
> >>
> >> I've tested the patch for lto.exp and now I'm doing a proper bootstrap.
> >> Ready after tests?
> >
> > +         const char *make = getenv ("MAKE");
> > +         unsigned argc = 0;
> > +         struct obstack make_argv_obstack;
> > +         obstack_init (&make_argv_obstack);
> > +
> > +         if (make)
> > +           {
> > +             argv = buildargv (make);
> >
> > you are overwriting the argv parameter here, I suggest to use a new
> > local variable here.
>
> Oh.
>
> >
> > buildargv can fail in which case it returns NULL so I suggest
> > to fall back to "make" in that case.
> >
> > +             for (; argv[argc]; argc++)
> > +               obstack_ptr_grow (&make_argv_obstack, argv[argc]);
> >
> > argc is only used in this scope so declare it in the for() loop?
> >
> > btw, I suggest to simply re-use argv_obstack here.
>
> Done.
>
> >
> > +         const char **argv = XOBFINISH (&make_argv_obstack, const char **);
> >
> > you are shadowing argv here, what's wrong with using new_argv?
>
> The shadowing in the function is really bad, it's a long function.
>
> >
> > +
> > +         pex = collect_execute (argv[0], CONST_CAST (char **, argv),
> >                                   NULL, NULL, PEX_SEARCH, false);
> > -         do_wait (new_argv[0], pex);
> > +         do_wait (argv[0], pex);
> > +         obstack_free (&make_argv_obstack, NULL);
> >
> > after pex is finished the argv allocated via buildargv should be freed
> > with freeargv
>
> Done.
>
> I hope it's better now?

Perfect if you checked freeargv is happy with a NULL argument!

OK.

Thanks,
Richard.

> Martin
>
> >
> > Richard.
> >
> > +           }
> >
> >
> >> Thanks,
> >> Martin
> >>
> >> gcc/ChangeLog:
> >>
> >> 2020-05-06  Martin Liska  <mli...@suse.cz>
> >>
> >>          * lto-wrapper.c: Split arguments of MAKE environment
> >>          variable.
> >> ---
> >>    gcc/lto-wrapper.c | 35 ++++++++++++++++++++++++-----------
> >>    1 file changed, 24 insertions(+), 11 deletions(-)
> >>
> >>
>

Reply via email to