diff --git a/Changes b/Changes index e3ceb15cd..18badb1a8 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 663776c07..c09ca5418 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -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; } diff --git a/test_regress/t/t_hier_block.py b/test_regress/t/t_hier_block.py index 1eea403ac..294b5139a 100755 --- a/test_regress/t/t_hier_block.py +++ b/test_regress/t/t_hier_block.py @@ -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)) diff --git a/test_regress/t/t_hier_trace_sub/sub.vc b/test_regress/t/t_hier_trace_sub/sub.vc index 59df44421..6702fa493 100644 --- a/test_regress/t/t_hier_trace_sub/sub.vc +++ b/test_regress/t/t_hier_trace_sub/sub.vc @@ -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 diff --git a/test_regress/t/t_hier_trace_sub/t_hier_trace_sub.v b/test_regress/t/t_hier_trace_sub/t_hier_trace_sub.v index a73317bcc..9ee9037ea 100644 --- a/test_regress/t/t_hier_trace_sub/t_hier_trace_sub.v +++ b/test_regress/t/t_hier_trace_sub/t_hier_trace_sub.v @@ -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