https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91244

            Bug ID: 91244
           Summary: gcc-ar prepends --plugin option thus triggers binutils
                    getopt_long bug 13256
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: szotsaki at gmail dot com
  Target Milestone: ---

"ar" seemingly doesn't accept options after a longopt (in our case "--plugin")
which makes it impossible to read instructions from command line or from a file
if "--plugin" is the first parameter. See
https://sourceware.org/bugzilla/show_bug.cgi?id=13256 for details.

Therefore I suggest appending the "--plugin" parameter to the command line
arguments.

Here is a quick patch against 9.1.0 to show what I thought of:

--- gcc/gcc-ar.c        2019-07-22 17:03:21.267931991 +0200
+++ gcc/gcc-ar.c        2019-07-24 09:41:27.168851170 +0200
@@ -211,13 +211,13 @@
   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] != '-')
     av[1] = concat ("-", av[1], NULL);
   for (k = 1; k < ac; k++)
-    nargv[2 + k] = av[k];
-  nargv[2 + k] = NULL;
+    nargv[k] = av[k];
+  nargv[k + 0] = "--plugin";
+  nargv[k + 1] = plugin;
+  nargv[k + 2] = NULL;
 #else
   if (is_ar && av[1] && av[1][0] != '-')
     av[1] = concat ("-", av[1], NULL);

A somehow related ticket for @file reading: Bug 77576

Reply via email to