This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PING^3] Re: [PATCH 1/2] Add -B support to gcc-ar/ranlib/nm


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]