Fix --hierarchical dropping arguments in -f/-F files (#7240).

This commit is contained in:
Wilson Snyder 2026-03-12 07:25:32 -04:00
parent 1198ee919d
commit f2fdc57366
5 changed files with 40 additions and 31 deletions

View File

@ -55,6 +55,7 @@ Verilator 5.047 devel
* Fix enum range constraints missing for rand variables in sub-objects (#7230) (#7235). [Yilou Wang]
* Fix vpi_put_value release on non-continuous signal (#7231) (#7241). [Christian Hecken]
* Fix tracing of typedefed 1D packed arrays with --trace-structs (#7237). [Geza Lore, Testorrent USA, Inc.]
* Fix --hierarchical dropping arguments in -f/-F files (#7240). [Clara Sparks]
Verilator 5.046 2026-02-28

View File

@ -431,40 +431,42 @@ string V3Options::allArgsStringForHierBlock(bool forTop) const {
string out;
bool stripArg = false;
bool stripArgIfNum = false;
for (const string& arg : m_impp->m_lineArgs) {
if (stripArg) {
stripArg = false;
continue;
}
if (stripArgIfNum) {
stripArgIfNum = false;
if (isdigit(arg[0])) continue;
}
int skip = 0;
if (arg.length() >= 2 && arg[0] == '-' && arg[1] == '-') {
skip = 2;
} else if (arg.length() >= 1 && arg[0] == '-') {
skip = 1;
}
if (skip > 0) { // arg is an option
const string opt = arg.substr(skip); // Remove '-' in the beginning
const int numStrip = stripOptionsForChildRun(opt, forTop);
if (numStrip) {
UASSERT(0 <= numStrip && numStrip <= 3, "should be one of 0, 1, 2, 3");
if (numStrip == 2) stripArg = true;
if (numStrip == 3) stripArgIfNum = true;
for (const auto& pair : m_impp->m_allArgs) {
for (const string& arg : pair.first) {
if (stripArg) {
stripArg = false;
continue;
}
} else { // Not an option
if (vFiles.find(arg) != vFiles.end() // Remove HDL
|| m_cppFiles.find(arg) != m_cppFiles.end()) { // Remove C++
continue;
if (stripArgIfNum) {
stripArgIfNum = false;
if (isdigit(arg[0])) continue;
}
int skip = 0;
if (arg.length() >= 2 && arg[0] == '-' && arg[1] == '-') {
skip = 2;
} else if (arg.length() >= 1 && arg[0] == '-') {
skip = 1;
}
if (skip > 0) { // arg is an option
const string opt = arg.substr(skip); // Remove '-' in the beginning
const int numStrip = stripOptionsForChildRun(opt, forTop);
if (numStrip) {
UASSERT(0 <= numStrip && numStrip <= 3, "should be one of 0, 1, 2, 3");
if (numStrip == 2) stripArg = true;
if (numStrip == 3) stripArgIfNum = true;
continue;
}
} else { // Not an option
if (vFiles.find(arg) != vFiles.end() // Remove HDL
|| m_cppFiles.find(arg) != m_cppFiles.end()) { // Remove C++
continue;
}
}
if (out != "") out += " ";
// Don't use opt here because '-' is removed in arg
// Use double quote because arg may contain whitespaces
out += '"' + VString::quoteAny(arg, '"', '\\') + '"';
}
if (out != "") out += " ";
// Don't use opt here because '-' is removed in arg
// Use double quote because arg may contain whitespaces
out += '"' + VString::quoteAny(arg, '"', '\\') + '"';
}
return out;
}

View File

@ -29,7 +29,7 @@ test.compile(
'-pvalue+PARAM_B=200',
'-DPARAM_OVERRIDE', #
'--CFLAGS',
'"-pipe -DCPP_MACRO=cplusplus"'
'"-O0 -pipe -DCPP_MACRO=cplusplus"'
],
threads=(6 if test.vltmt else 1))

View File

@ -4,4 +4,6 @@
# SPDX-FileCopyrightText: 2024 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
+define+T_HIER_TRACE_SUB_VC_DEFINE
t_hier_trace_sub.v

View File

@ -4,6 +4,10 @@
// SPDX-FileCopyrightText: 2024 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
`ifndef T_HIER_TRACE_SUB_VC_DEFINE
`error "Missed T_HIER_TRACE_INC_V from sub.vc file"
`endif
module detail_code (
input clk,
input reset_l