Allow both -MMD and --no-MMD, and --no/--skip-identical to override default

This commit is contained in:
Wilson Snyder 2019-10-31 20:59:52 -04:00
parent 4b5f0fd173
commit 8f6efdaf5c
5 changed files with 86 additions and 28 deletions

View File

@ -964,9 +964,11 @@ If the design is not to be completely Verilated see also the --bbox-sys and
--bbox-unsup options. --bbox-unsup options.
=item --MMD =item --MMD
=item --no-MMD
Enable creation of .d dependency files, used for make dependency detection, Enable/disable creation of .d dependency files, used for make dependency
similar to gcc -MMD option. On by default, use --no-MMD to disable. detection, similar to gcc -MMD option. By default this option is enabled
for --cc or --sp modes.
=item --MP =item --MP
@ -1017,9 +1019,11 @@ with extra loads and stores to handle the (imaginary) aliasing. Using only
'vlTOPp->' references allows these old compilers to produce tight code. 'vlTOPp->' references allows these old compilers to produce tight code.
=item --no-skip-identical =item --no-skip-identical
=item --skip-identical
Rarely needed. Disables skipping execution of Verilator if all source Rarely needed. Disables or enables skipping execution of Verilator if all
files are identical, and all output files exist with newer dates. source files are identical, and all output files exist with newer dates.
By default this option is enabled for --cc or --sp modes only.
=item +notimingchecks =item +notimingchecks

View File

@ -528,11 +528,12 @@ string V3Options::getenvVERILATOR_ROOT() {
void V3Options::notify() { void V3Options::notify() {
// Notify that all arguments have been passed and final modification can be made. // Notify that all arguments have been passed and final modification can be made.
if (!outFormatOk() if (!outFormatOk()
&& !preprocOnly() && !cdc()
&& !dpiHdrOnly()
&& !lintOnly() && !lintOnly()
&& !xmlOnly() && !preprocOnly()
&& !cdc()) { && !xmlOnly()) {
v3fatal("verilator: Need --cc, --sc, --cdc, --lint-only, --xml_only or --E option"); v3fatal("verilator: Need --cc, --sc, --cdc, --dpi-hdr-only, --lint-only, --xml-only or --E option");
} }
// Make sure at least one make system is enabled // Make sure at least one make system is enabled
@ -559,6 +560,22 @@ void V3Options::notify() {
+V3Error::warnMore()+"... Suggest remove --vpi."); +V3Error::warnMore()+"... Suggest remove --vpi.");
} }
} }
// Default some options if not turned on or off
if (v3Global.opt.skipIdentical().isDefault()) {
v3Global.opt.m_skipIdentical.setTrueOrFalse(
!v3Global.opt.cdc()
&& !v3Global.opt.dpiHdrOnly()
&& !v3Global.opt.lintOnly()
&& !v3Global.opt.preprocOnly());
}
if (v3Global.opt.makeDepend().isDefault()) {
v3Global.opt.m_makeDepend.setTrueOrFalse(
!v3Global.opt.cdc()
&& !v3Global.opt.dpiHdrOnly()
&& !v3Global.opt.lintOnly()
&& !v3Global.opt.preprocOnly());
}
} }
//###################################################################### //######################################################################
@ -638,6 +655,15 @@ bool V3Options::onoff(const char* sw, const char* arg, bool& flag) {
else if (0==strncmp(sw, "-no-", 4) && (0==strcmp(sw+4, arg+1))) { flag = false; return true; } else if (0==strncmp(sw, "-no-", 4) && (0==strcmp(sw+4, arg+1))) { flag = false; return true; }
return false; return false;
} }
bool V3Options::onoffb(const char* sw, const char* arg, VOptionBool& bflag) {
bool flag;
if (onoff(sw, arg, flag/*ref*/)) {
bflag.setTrueOrFalse(flag);
return true;
} else {
return false;
}
}
bool V3Options::suffixed(const string& sw, const char* arg) { bool V3Options::suffixed(const string& sw, const char* arg) {
if (strlen(arg) > sw.length()) return false; if (strlen(arg) > sw.length()) return false;
@ -696,12 +722,13 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
else if (argv[i][0]=='-') { else if (argv[i][0]=='-') {
const char *sw = argv[i]; const char *sw = argv[i];
bool flag = true; bool flag = true;
VOptionBool bflag;
// Allow gnu -- switches // Allow gnu -- switches
if (sw[0]=='-' && sw[1]=='-') ++sw; if (sw[0]=='-' && sw[1]=='-') ++sw;
if (0) {} if (0) {}
// Single switches // Single switches
else if (!strcmp(sw, "-E")) { m_preprocOnly = true; } else if (!strcmp(sw, "-E")) { m_preprocOnly = true; }
else if ( onoff (sw, "-MMD", flag/*ref*/)) { m_makeDepend = flag; } else if ( onoffb(sw, "-MMD", bflag/*ref*/)) { m_makeDepend = bflag; }
else if ( onoff (sw, "-MP", flag/*ref*/)) { m_makePhony = flag; } else if ( onoff (sw, "-MP", flag/*ref*/)) { m_makePhony = flag; }
else if (!strcmp(sw, "-P")) { m_preprocNoLine = true; } else if (!strcmp(sw, "-P")) { m_preprocNoLine = true; }
else if ( onoff (sw, "-assert", flag/*ref*/)) { m_assert = flag; } else if ( onoff (sw, "-assert", flag/*ref*/)) { m_assert = flag; }
@ -748,13 +775,13 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
else if ( onoff (sw, "-protect-ids", flag/*ref*/)) { m_protectIds = flag; } else if ( onoff (sw, "-protect-ids", flag/*ref*/)) { m_protectIds = flag; }
else if ( onoff (sw, "-public", flag/*ref*/)) { m_public = flag; } else if ( onoff (sw, "-public", flag/*ref*/)) { m_public = flag; }
else if ( onoff (sw, "-public-flat-rw", flag/*ref*/) ) { m_publicFlatRW = flag; v3Global.dpi(true); } else if ( onoff (sw, "-public-flat-rw", flag/*ref*/) ) { m_publicFlatRW = flag; v3Global.dpi(true); }
else if (!strncmp(sw, "-pvalue+", strlen("-pvalue+"))) { addParameter(string(sw+strlen("-pvalue+")), false); } else if (!strncmp(sw, "-pvalue+", strlen("-pvalue+"))) { addParameter(string(sw+strlen("-pvalue+")), false); }
else if ( onoff (sw, "-relative-cfuncs", flag/*ref*/)) { m_relativeCFuncs = flag; } else if ( onoff (sw, "-relative-cfuncs", flag/*ref*/)) { m_relativeCFuncs = flag; }
else if ( onoff (sw, "-relative-includes", flag/*ref*/)) { m_relativeIncludes = flag; } else if ( onoff (sw, "-relative-includes", flag/*ref*/)) { m_relativeIncludes = flag; }
else if ( onoff (sw, "-report-unoptflat", flag/*ref*/)) { m_reportUnoptflat = flag; } else if ( onoff (sw, "-report-unoptflat", flag/*ref*/)) { m_reportUnoptflat = flag; }
else if ( onoff (sw, "-savable", flag/*ref*/)) { m_savable = flag; } else if ( onoff (sw, "-savable", flag/*ref*/)) { m_savable = flag; }
else if (!strcmp(sw, "-sc")) { m_outFormatOk = true; m_systemC = true; } else if (!strcmp(sw, "-sc")) { m_outFormatOk = true; m_systemC = true; }
else if ( onoff (sw, "-skip-identical", flag/*ref*/)) { m_skipIdentical = flag; } else if ( onoffb(sw, "-skip-identical", bflag/*ref*/)) { m_skipIdentical = bflag; }
else if ( onoff (sw, "-stats", flag/*ref*/)) { m_stats = flag; } else if ( onoff (sw, "-stats", flag/*ref*/)) { m_stats = flag; }
else if ( onoff (sw, "-stats-vars", flag/*ref*/)) { m_statsVars = flag; m_stats |= flag; } else if ( onoff (sw, "-stats-vars", flag/*ref*/)) { m_statsVars = flag; m_stats |= flag; }
else if (!strcmp(sw, "-sv")) { m_defaultLanguage = V3LangCode::L1800_2005; } else if (!strcmp(sw, "-sv")) { m_defaultLanguage = V3LangCode::L1800_2005; }
@ -1420,7 +1447,6 @@ V3Options::V3Options() {
m_inhibitSim = false; m_inhibitSim = false;
m_lintOnly = false; m_lintOnly = false;
m_gmake = false; m_gmake = false;
m_makeDepend = true;
m_makePhony = false; m_makePhony = false;
m_orderClockDly = true; m_orderClockDly = true;
m_outFormatOk = false; m_outFormatOk = false;
@ -1440,7 +1466,6 @@ V3Options::V3Options() {
m_relativeIncludes = false; m_relativeIncludes = false;
m_reportUnoptflat = false; m_reportUnoptflat = false;
m_savable = false; m_savable = false;
m_skipIdentical = true;
m_stats = false; m_stats = false;
m_statsVars = false; m_statsVars = false;
m_systemC = false; m_systemC = false;

View File

@ -37,6 +37,39 @@ class FileLine;
//###################################################################### //######################################################################
class VOptionBool {
// Class to track options that are either not specified (and default
// true/false), versus user setting the option to true or false
public:
enum en {
OPT_DEFAULT_FALSE = 0,
OPT_DEFAULT_TRUE,
OPT_TRUE,
OPT_FALSE,
_ENUM_END
};
enum en m_e;
inline VOptionBool() : m_e(OPT_DEFAULT_FALSE) {}
// cppcheck-suppress noExplicitConstructor
inline VOptionBool(en _e) : m_e(_e) {}
explicit inline VOptionBool(int _e) : m_e(static_cast<en>(_e)) {}
operator en() const { return m_e; }
bool isDefault() const { return m_e == OPT_DEFAULT_FALSE || m_e == OPT_DEFAULT_TRUE; }
bool isTrue() const { return m_e == OPT_TRUE || m_e == OPT_DEFAULT_TRUE; }
bool isFalse() const { return m_e == OPT_FALSE || m_e == OPT_DEFAULT_FALSE; }
void setTrueOrFalse(bool flag) { m_e = flag ? OPT_TRUE : OPT_FALSE; }
const char* ascii() const {
static const char* const names[] = {
"DEFAULT_FALSE", "DEFAULT_TRUE", "TRUE", "FALSE"};
return names[m_e]; }
};
inline bool operator==(VOptionBool lhs, VOptionBool rhs) { return (lhs.m_e == rhs.m_e); }
inline bool operator==(VOptionBool lhs, VOptionBool::en rhs) { return (lhs.m_e == rhs); }
inline bool operator==(VOptionBool::en lhs, VOptionBool rhs) { return (lhs == rhs.m_e); }
inline std::ostream& operator<<(std::ostream& os, const VOptionBool& rhs) { return os<<rhs.ascii(); }
//######################################################################
class TraceFormat { class TraceFormat {
public: public:
enum en { enum en {
@ -101,7 +134,6 @@ class V3Options {
bool m_preprocOnly; // main switch: -E bool m_preprocOnly; // main switch: -E
bool m_makeDepend; // main switch: -MMD
bool m_makePhony; // main switch: -MP bool m_makePhony; // main switch: -MP
bool m_preprocNoLine;// main switch: -P bool m_preprocNoLine;// main switch: -P
bool m_assert; // main switch: --assert bool m_assert; // main switch: --assert
@ -145,7 +177,6 @@ class V3Options {
bool m_reportUnoptflat; // main switch: --report-unoptflat bool m_reportUnoptflat; // main switch: --report-unoptflat
bool m_savable; // main switch: --savable bool m_savable; // main switch: --savable
bool m_systemC; // main switch: --sc: System C instead of simple C++ bool m_systemC; // main switch: --sc: System C instead of simple C++
bool m_skipIdentical;// main switch: --skip-identical
bool m_stats; // main switch: --stats bool m_stats; // main switch: --stats
bool m_statsVars; // main switch: --stats-vars bool m_statsVars; // main switch: --stats-vars
bool m_threadsCoarsen; // main switch: --threads-coarsen bool m_threadsCoarsen; // main switch: --threads-coarsen
@ -167,11 +198,13 @@ class V3Options {
int m_gateStmts; // main switch: --gate-stmts int m_gateStmts; // main switch: --gate-stmts
int m_ifDepth; // main switch: --if-depth int m_ifDepth; // main switch: --if-depth
int m_inlineMult; // main switch: --inline-mult int m_inlineMult; // main switch: --inline-mult
VOptionBool m_makeDepend; // main switch: -MMD
int m_moduleRecursion;// main switch: --module-recursion-depth int m_moduleRecursion;// main switch: --module-recursion-depth
int m_outputSplit; // main switch: --output-split int m_outputSplit; // main switch: --output-split
int m_outputSplitCFuncs;// main switch: --output-split-cfuncs int m_outputSplitCFuncs;// main switch: --output-split-cfuncs
int m_outputSplitCTrace;// main switch: --output-split-ctrace int m_outputSplitCTrace;// main switch: --output-split-ctrace
int m_pinsBv; // main switch: --pins-bv int m_pinsBv; // main switch: --pins-bv
VOptionBool m_skipIdentical; // main switch: --skip-identical
int m_threads; // main switch: --threads (0 == --no-threads) int m_threads; // main switch: --threads (0 == --no-threads)
int m_threadsMaxMTasks; // main switch: --threads-max-mtasks int m_threadsMaxMTasks; // main switch: --threads-max-mtasks
int m_traceDepth; // main switch: --trace-depth int m_traceDepth; // main switch: --trace-depth
@ -239,6 +272,7 @@ class V3Options {
void showVersion(bool verbose); void showVersion(bool verbose);
void coverage(bool flag) { m_coverageLine = m_coverageToggle = m_coverageUser = flag; } void coverage(bool flag) { m_coverageLine = m_coverageToggle = m_coverageUser = flag; }
bool onoff(const char* sw, const char* arg, bool& flag); bool onoff(const char* sw, const char* arg, bool& flag);
bool onoffb(const char* sw, const char* arg, VOptionBool& flag);
bool suffixed(const string& sw, const char* arg); bool suffixed(const string& sw, const char* arg);
string parseFileArg(const string& optdir, const string& relfilename); string parseFileArg(const string& optdir, const string& relfilename);
bool parseLangExt(const char* swp, const char* langswp, const V3LangCode& lc); bool parseLangExt(const char* swp, const char* langswp, const V3LangCode& lc);
@ -268,7 +302,6 @@ class V3Options {
// ACCESSORS (options) // ACCESSORS (options)
bool preprocOnly() const { return m_preprocOnly; } bool preprocOnly() const { return m_preprocOnly; }
bool makeDepend() const { return m_makeDepend; }
bool makePhony() const { return m_makePhony; } bool makePhony() const { return m_makePhony; }
bool preprocNoLine() const { return m_preprocNoLine; } bool preprocNoLine() const { return m_preprocNoLine; }
bool underlineZero() const { return m_underlineZero; } bool underlineZero() const { return m_underlineZero; }
@ -277,7 +310,6 @@ class V3Options {
bool systemC() const { return m_systemC; } bool systemC() const { return m_systemC; }
bool usingSystemCLibs() const { return !lintOnly() && systemC(); } bool usingSystemCLibs() const { return !lintOnly() && systemC(); }
bool savable() const { return m_savable; } bool savable() const { return m_savable; }
bool skipIdentical() const { return m_skipIdentical; }
bool stats() const { return m_stats; } bool stats() const { return m_stats; }
bool statsVars() const { return m_statsVars; } bool statsVars() const { return m_statsVars; }
bool assertOn() const { return m_assert; } // assertOn as __FILE__ may be defined bool assertOn() const { return m_assert; } // assertOn as __FILE__ may be defined
@ -338,11 +370,13 @@ class V3Options {
int gateStmts() const { return m_gateStmts; } int gateStmts() const { return m_gateStmts; }
int ifDepth() const { return m_ifDepth; } int ifDepth() const { return m_ifDepth; }
int inlineMult() const { return m_inlineMult; } int inlineMult() const { return m_inlineMult; }
VOptionBool makeDepend() const { return m_makeDepend; }
int moduleRecursionDepth() const { return m_moduleRecursion; } int moduleRecursionDepth() const { return m_moduleRecursion; }
int outputSplit() const { return m_outputSplit; } int outputSplit() const { return m_outputSplit; }
int outputSplitCFuncs() const { return m_outputSplitCFuncs; } int outputSplitCFuncs() const { return m_outputSplitCFuncs; }
int outputSplitCTrace() const { return m_outputSplitCTrace; } int outputSplitCTrace() const { return m_outputSplitCTrace; }
int pinsBv() const { return m_pinsBv; } int pinsBv() const { return m_pinsBv; }
VOptionBool skipIdentical() const { return m_skipIdentical; }
int threads() const { return m_threads; } int threads() const { return m_threads; }
int threadsMaxMTasks() const { return m_threadsMaxMTasks; } int threadsMaxMTasks() const { return m_threadsMaxMTasks; }
bool mtasks() const { return (m_threads > 1); } bool mtasks() const { return (m_threads > 1); }

View File

@ -607,10 +607,7 @@ int main(int argc, char** argv, char** env) {
// Can we skip doing everything if times are ok? // Can we skip doing everything if times are ok?
V3File::addSrcDepend(v3Global.opt.bin()); V3File::addSrcDepend(v3Global.opt.bin());
if (v3Global.opt.skipIdentical() if (v3Global.opt.skipIdentical().isTrue()
&& !v3Global.opt.preprocOnly()
&& !v3Global.opt.lintOnly()
&& !v3Global.opt.cdc()
&& V3File::checkTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix() && V3File::checkTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()
+"__verFiles.dat", argString)) { +"__verFiles.dat", argString)) {
UINFO(1,"--skip-identical: No change to any source files, exiting\n"); UINFO(1,"--skip-identical: No change to any source files, exiting\n");
@ -648,13 +645,10 @@ int main(int argc, char** argv, char** env) {
V3Global::dumpCheckGlobalTree("final", 990, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); V3Global::dumpCheckGlobalTree("final", 990, v3Global.opt.dumpTreeLevel(__FILE__) >= 3);
V3Error::abortIfWarnings(); V3Error::abortIfWarnings();
if (!v3Global.opt.lintOnly() && !v3Global.opt.cdc() if (v3Global.opt.makeDepend().isTrue()) {
&& !v3Global.opt.dpiHdrOnly() && v3Global.opt.makeDepend()) {
V3File::writeDepend(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__ver.d"); V3File::writeDepend(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__ver.d");
} }
if (!v3Global.opt.lintOnly() && !v3Global.opt.cdc() if (v3Global.opt.skipIdentical().isTrue() || v3Global.opt.makeDepend().isTrue()) {
&& !v3Global.opt.dpiHdrOnly()
&& (v3Global.opt.skipIdentical() || v3Global.opt.makeDepend())) {
V3File::writeTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix() V3File::writeTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()
+"__verFiles.dat", argString); +"__verFiles.dat", argString);
} }

View File

@ -17,14 +17,15 @@ top_filename("t/t_dpi_import.v");
my $tmp_dir = File::Temp->newdir(); my $tmp_dir = File::Temp->newdir();
compile( compile(
verilator_flags2 => ["-Wall -Wno-DECLFILENAME -Mdir " . $tmp_dir . " --dpi-hdr-only"], # Override default flags also
verilator_flags => ["-Wall -Wno-DECLFILENAME -Mdir " . $tmp_dir . " --dpi-hdr-only"],
verilator_make_gmake => 0, verilator_make_gmake => 0,
); );
my @files = glob($tmp_dir . "/*"); my @files = glob($tmp_dir . "/*");
error("Did not produce DPI header") if scalar(@files) == 0; error("Did not produce DPI header") if scalar(@files) == 0;
error("Too many files created") if scalar(@files) > 1; error("Too many files created:".join(', ', @files)) if scalar(@files) > 1;
my $tmp_header = $files[0]; my $tmp_header = $files[0];
print("============".$tmp_header."\n"); print("============".$tmp_header."\n");