This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING^3] Re: [PATCH 1/2] Add -B support to gcc-ar/ranlib/nm
- From: Andi Kleen <andi at firstfloor dot org>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Andi Kleen <andi at firstfloor dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 30 Aug 2014 18:32:01 +0200
- Subject: Re: [PING^3] Re: [PATCH 1/2] Add -B support to gcc-ar/ranlib/nm
- Authentication-results: sourceware.org; auth=none
- References: <1407557156-12737-1-git-send-email-andi at firstfloor dot org> <87a96vkok0 dot fsf at tassilo dot jf dot intel dot com> <8761hekpvf dot fsf_-_ at tassilo dot jf dot intel dot com> <CAFiYyc2ETqYdtJfU43jtaFNDzQaX9RUNXTaGSpwc8Oz+yBwAHQ at mail dot gmail dot com>
Hi Richard,
On Thu, Aug 28, 2014 at 10:18:22AM +0200, Richard Biener wrote:
> This also matches joined -B/foo
>
> >>> + {
> >>> + const char *arg = av[i] + 2;
> >>> + const char *end;
> >>> +
> >>> + memmove (av + i, av + i + 1, sizeof (char *) * ((ac + 1) - i));
> >>> + ac--;
> >>> + if (*arg == 0)
> >>> + {
> >>> + arg = av[i + 1];
> >>> + if (!arg)
> >>> + {
>
> But this doesn't handle it? common.opt has -B as Joined Separate option
> thus allowing both.
I believe it handles both cases. For the joined case (*arg == 0) is
false and the earlier (arg = av[i] + 2) assignment is used.
>
> >>> + fprintf (stderr, "Usage: gcc-ar [-B prefix] ar arguments ...\n");
> >>> + exit (EXIT_FAILURE);
> >>> + }
> >>> + memmove (av + i, av + i + 1, sizeof (char *) * ((ac + 1) - i));
> >>> + ac--;
> >>> + i++;
> >>> + }
> >>> +
> >>> + for (end = arg; *end; end++)
> >>> + ;
> >>> + end--;
> >>> + if (end > arg && *end != '/')
> >>> + {
> >>> + char *newarg = (char *)xmalloc (strlen(arg) + 2);
> >>> +
> >>> + strcpy (newarg, arg);
> >>> + strcat (newarg, "/");
> >>> + arg = newarg;
> >>> + }
>
> Why the above? And why open-coded instead of using strlen?
I assume you mean the for loop.
I always had strange errors later if the paths were not ending
with /, so I'm force adding it.
> >>> +
> >>> + add_prefix (&path, arg);
> >>> + add_prefix (&target_path, arg);
>
> This adds the -B path to the _end_ of the prefix list. Does that match
> gcc driver behavior? The gcc driver uses PREFIX_PRIORITY_B_OPT
> as argument to add_prefix which ends up adding -B prefixes to the
> beginning of the prefix list.
Ok.
-andi