Fix make jobserver with submakes (#3758).

This commit is contained in:
Wilson Snyder 2022-12-11 14:19:40 -05:00
parent 722e38f532
commit afc66f6a85
6 changed files with 20 additions and 1 deletions

View File

@ -27,6 +27,7 @@ Verilator 5.003 devel
* Fix return type of $countbits functions to int (#3725). [Ryszard Rozak, Antmicro Ltd]
* Fix missing UNUSED warnings with --coverage (#3736). [alejandro-castro-ortegon]
* Fix tracing parameters overridden with -G (#3723). [Iztok Jeras]
* Fix make jobserver with submakes (#3758). [Gus Smith]
* Fix wait 0.
* Fix comparing ranged slices of unpacked arrays.
* Fix empty string literals converting to string types (#3774). [miree]

View File

@ -20,6 +20,12 @@ associated programs.
this variable to launch GNU make. If this variable is not specified,
"make" is used.
.. option:: MAKEFLAGS
Flags created by :command:`make` to pass to submakes. Verilator searches
this variable to determine if a jobserver is used; see
:vlopt:`--build-jobs`.
.. option:: OBJCACHE
Optionally specifies a caching or distribution program to place in front

View File

@ -144,6 +144,10 @@ Summary:
be a positive integer specifying the maximum number of parallel build
jobs.
This forms the :command:`make` option ``-j`` value, unless the
:option:`MAKEFLAGS` environment variable contains ``-jobserver-auth``,
in which case Verilator assumes that make's jobserver is being used.
See also :vlopt:`-j`.
.. option:: --cc

View File

@ -624,6 +624,10 @@ string V3Options::getenvMAKE() { return V3Os::getenvStr("MAKE", "gmake"); }
string V3Options::getenvMAKE() { return V3Os::getenvStr("MAKE", "make"); }
#endif
string V3Options::getenvMAKEFLAGS() { //
return V3Os::getenvStr("MAKEFLAGS", "");
}
string V3Options::getenvPERL() { //
return V3Os::getenvStr("PERL", "perl");
}

View File

@ -660,6 +660,7 @@ public:
// Also add to V3Options::showVersion()
static string getenvBuiltins(const string& var);
static string getenvMAKE();
static string getenvMAKEFLAGS();
static string getenvPERL();
static string getenvSYSTEMC();
static string getenvSYSTEMC_ARCH();

View File

@ -686,7 +686,10 @@ static string buildMakeCmd(const string& makefile, const string& target) {
cmd << v3Global.opt.getenvMAKE();
cmd << " -C " << v3Global.opt.makeDir();
cmd << " -f " << makefile;
if (jobs > 0) cmd << " -j " << jobs;
// Unless using make's jobserver, do a -j
if (v3Global.opt.getenvMAKEFLAGS().find("-jobserver-auth") == string::npos) {
if (jobs > 0) cmd << " -j " << jobs;
}
for (const string& flag : makeFlags) cmd << ' ' << flag;
if (!target.empty()) cmd << ' ' << target;