Message ID | 1407557156-12737-1-git-send-email-andi@firstfloor.org |
---|---|
State | New |
Headers | show |
Andi Kleen <andi@firstfloor.org> writes: Ping! > From: Andi Kleen <ak@linux.intel.com> > > To use gcc-{ar,ranlib} for boot strap we need to add a -B option > to the tool. Since ar has weird and unusual argument conventions > implement the code by hand instead of using any libraries. > > v2: Fix typo > > gcc/: > > 2014-08-04 Andi Kleen <ak@linux.intel.com> > > * gcc-ar.c (main): Support -B option. > --- > gcc/gcc-ar.c | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c > index aebaa92..70bf222 100644 > --- a/gcc/gcc-ar.c > +++ b/gcc/gcc-ar.c > @@ -132,9 +132,50 @@ main (int ac, char **av) > const char **nargv; > bool is_ar = !strcmp (PERSONALITY, "ar"); > int exit_code = FATAL_EXIT_CODE; > + int i; > > setup_prefixes (av[0]); > > + /* Not using getopt for now. */ > + for (i = 0; i < ac; i++) > + if (!strncmp (av[i], "-B", 2)) > + { > + 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) > + { > + 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; > + } > + > + add_prefix (&path, arg); > + add_prefix (&target_path, arg); > + break; > + } > + > + > /* Find the GCC LTO plugin */ > plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK); > if (!plugin)
Andi Kleen <andi@firstfloor.org> writes: PING^2 ! Would be nice to make slim bootstrap work, it really speeds it up quite a bit. > From: Andi Kleen <ak@linux.intel.com> > > To use gcc-{ar,ranlib} for boot strap we need to add a -B option > to the tool. Since ar has weird and unusual argument conventions > implement the code by hand instead of using any libraries. > > v2: Fix typo > > gcc/: > > 2014-08-04 Andi Kleen <ak@linux.intel.com> > > * gcc-ar.c (main): Support -B option. > --- > gcc/gcc-ar.c | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c > index aebaa92..70bf222 100644 > --- a/gcc/gcc-ar.c > +++ b/gcc/gcc-ar.c > @@ -132,9 +132,50 @@ main (int ac, char **av) > const char **nargv; > bool is_ar = !strcmp (PERSONALITY, "ar"); > int exit_code = FATAL_EXIT_CODE; > + int i; > > setup_prefixes (av[0]); > > + /* Not using getopt for now. */ > + for (i = 0; i < ac; i++) > + if (!strncmp (av[i], "-B", 2)) > + { > + 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) > + { > + 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; > + } > + > + add_prefix (&path, arg); > + add_prefix (&target_path, arg); > + break; > + } > + > + > /* Find the GCC LTO plugin */ > plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK); > if (!plugin)
Andi Kleen <andi@firstfloor.org> writes: PING! > Andi Kleen <andi@firstfloor.org> writes: > > PING^2 ! > > Would be nice to make slim bootstrap work, it really speeds it up quite > a bit. > >> From: Andi Kleen <ak@linux.intel.com> >> >> To use gcc-{ar,ranlib} for boot strap we need to add a -B option >> to the tool. Since ar has weird and unusual argument conventions >> implement the code by hand instead of using any libraries. >> >> v2: Fix typo >> >> gcc/: >> >> 2014-08-04 Andi Kleen <ak@linux.intel.com> >> >> * gcc-ar.c (main): Support -B option. >> --- >> gcc/gcc-ar.c | 41 +++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 41 insertions(+) >> >> diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c >> index aebaa92..70bf222 100644 >> --- a/gcc/gcc-ar.c >> +++ b/gcc/gcc-ar.c >> @@ -132,9 +132,50 @@ main (int ac, char **av) >> const char **nargv; >> bool is_ar = !strcmp (PERSONALITY, "ar"); >> int exit_code = FATAL_EXIT_CODE; >> + int i; >> >> setup_prefixes (av[0]); >> >> + /* Not using getopt for now. */ >> + for (i = 0; i < ac; i++) >> + if (!strncmp (av[i], "-B", 2)) >> + { >> + 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) >> + { >> + 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; >> + } >> + >> + add_prefix (&path, arg); >> + add_prefix (&target_path, arg); >> + break; >> + } >> + >> + >> /* Find the GCC LTO plugin */ >> plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK); >> if (!plugin)
On Wed, Aug 27, 2014 at 3:45 PM, Andi Kleen <andi@firstfloor.org> wrote: > Andi Kleen <andi@firstfloor.org> writes: > > PING! > >> Andi Kleen <andi@firstfloor.org> writes: >> >> PING^2 ! >> >> Would be nice to make slim bootstrap work, it really speeds it up quite >> a bit. >> >>> From: Andi Kleen <ak@linux.intel.com> >>> >>> To use gcc-{ar,ranlib} for boot strap we need to add a -B option >>> to the tool. Since ar has weird and unusual argument conventions >>> implement the code by hand instead of using any libraries. >>> >>> v2: Fix typo >>> >>> gcc/: >>> >>> 2014-08-04 Andi Kleen <ak@linux.intel.com> >>> >>> * gcc-ar.c (main): Support -B option. >>> --- >>> gcc/gcc-ar.c | 41 +++++++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 41 insertions(+) >>> >>> diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c >>> index aebaa92..70bf222 100644 >>> --- a/gcc/gcc-ar.c >>> +++ b/gcc/gcc-ar.c >>> @@ -132,9 +132,50 @@ main (int ac, char **av) >>> const char **nargv; >>> bool is_ar = !strcmp (PERSONALITY, "ar"); >>> int exit_code = FATAL_EXIT_CODE; >>> + int i; >>> >>> setup_prefixes (av[0]); >>> >>> + /* Not using getopt for now. */ >>> + for (i = 0; i < ac; i++) >>> + if (!strncmp (av[i], "-B", 2)) 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. >>> + 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? Also instead of testing for '/' this should test for IS_DIR_SEPARATOR. Without comments all this code is hard to decipher. >>> + >>> + 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. Thanks, Richard. >>> + break; >>> + } >>> + >>> + >>> /* Find the GCC LTO plugin */ >>> plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK); >>> if (!plugin) > > -- > ak@linux.intel.com -- Speaking for myself only
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
diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c index aebaa92..70bf222 100644 --- a/gcc/gcc-ar.c +++ b/gcc/gcc-ar.c @@ -132,9 +132,50 @@ main (int ac, char **av) const char **nargv; bool is_ar = !strcmp (PERSONALITY, "ar"); int exit_code = FATAL_EXIT_CODE; + int i; setup_prefixes (av[0]); + /* Not using getopt for now. */ + for (i = 0; i < ac; i++) + if (!strncmp (av[i], "-B", 2)) + { + 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) + { + 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; + } + + add_prefix (&path, arg); + add_prefix (&target_path, arg); + break; + } + + /* Find the GCC LTO plugin */ plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK); if (!plugin)
From: Andi Kleen <ak@linux.intel.com> To use gcc-{ar,ranlib} for boot strap we need to add a -B option to the tool. Since ar has weird and unusual argument conventions implement the code by hand instead of using any libraries. v2: Fix typo gcc/: 2014-08-04 Andi Kleen <ak@linux.intel.com> * gcc-ar.c (main): Support -B option. --- gcc/gcc-ar.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)