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

            Bug ID: 98275
           Summary: -flto=auto fails if nthreads_var is zero, must not
                    pass -j0
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: p...@gcc-bugzilla.mail.kapsi.fi
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---
              Host: mingw64

Hi. 

When using `-flto=auto' if the number of threads is not detected, i.e.
`nthreads_var' equals to zero, lto-wrapper must not pass -j0 to GNU make as -j
expects a positive, non-zero integer (if any given).

>From GNU make manual: ``If the ā€˜-jā€™ option is followed by an integer, this is
the number of recipes to execute at once; this is called the number of job
slots. If there is nothing looking like an integer after the ā€˜-jā€™ option, there
is no limit on the number of job slots.''.

gcc/lto-wrapper.c:
2001               snprintf (jobs, 31, "-j%ld",
2002                         auto_parallel ? nthreads_var : parallel);

$ make -j0
make: the '-j' option requires a positive integer argument

Tried GNU make 4.2.1 (2016 vintage) and 4.2.93 (2020).  For the latest trunk
argument parsing happens at src/main.c around line 2961 [1];  It basically does
``int i = atoi(arg); if (i < 1 || not-all-chars-are-digits) { handle-bad-arg
}''.


[1] https://git.savannah.gnu.org/cgit/make.git/tree/src/main.c#n2961

Reply via email to