From a7a5c9f5481acb652f730803af1a74c71cf36f7f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 10 Mar 2026 08:55:51 -0400 Subject: [PATCH] Improve not-found message to show cwd --- src/V3EmitMk.cpp | 3 +-- src/V3Options.cpp | 4 ++-- src/V3Os.h | 1 + test_regress/driver.py | 8 ++++---- test_regress/t/t_gen_missing_bad.out | 1 + test_regress/t/t_gen_nonconst_bad.out | 1 + test_regress/t/t_hier_block_type_param_notfound_bad.out | 1 + test_regress/t/t_package_dup_bad2.out | 1 + test_regress/t/t_preproc_inc_notfound_bad.out | 1 + 9 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 17caa16c2..cb580a212 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -806,9 +806,8 @@ class EmitMkHierVerilation final { const V3HierGraph* const m_graphp; const string m_makefile; // path of this makefile void emitCommonOpts(V3OutMkFile& of) const { - const string cwd = V3Os::filenameRealPath("."); of.puts("# Verilation of hierarchical blocks are executed in this directory\n"); - of.puts("VM_HIER_RUN_DIR := " + cwd + "\n"); + of.puts("VM_HIER_RUN_DIR := " + V3Os::cwd() + "\n"); of.puts("# Common options for hierarchical blocks\n"); const string fullpath_bin = V3Os::filenameRealPath(v3Global.opt.buildDepBin()); const string verilator_wrapper = V3Os::filenameDir(fullpath_bin) + "/verilator"; diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 71c4dc375..663776c07 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -702,6 +702,8 @@ string V3Options::filePathLookedMsg(FileLine* fl, const string& modname) { ss << V3Error::warnMore() << " " << fn << "\n"; } } + ss << V3Error::warnMore() << "... With current working directory '" << V3Os::cwd() + << "'\n"; } return ss.str(); } @@ -1954,8 +1956,6 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, parser.finalize(); - const std::string cwd = V3Os::filenameRealPath("."); - for (int i = 0; i < argc;) { UINFO(9, " Option: " << argv[i]); diff --git a/src/V3Os.h b/src/V3Os.h index 72d36b7d9..d37caeb18 100644 --- a/src/V3Os.h +++ b/src/V3Os.h @@ -31,6 +31,7 @@ class V3Os final { public: // METHODS (environment) + static string cwd() { return filenameRealPath("."); } static string getenvStr(const string& envvar, const string& defaultValue); static void setenvStr(const string& envvar, const string& value, const string& why); diff --git a/test_regress/driver.py b/test_regress/driver.py index 75ee49219..5fb8d3e5e 100755 --- a/test_regress/driver.py +++ b/test_regress/driver.py @@ -2431,11 +2431,11 @@ class VlTest: line = re.sub(r'CPU Time: +[0-9.]+ seconds[^\n]+', 'CPU Time: ###', line) line = re.sub(r'\?v=[0-9.]+', '?v=latest', line) # warning URL line = re.sub(r'_h[0-9a-f]{8}_', '_h########_', line) - line = re.sub(r'%Error: /[^: ]+/([^/:])', r'%Error: .../\1', - line) # Avoid absolute paths - line = re.sub(r'("file://)/[^: ]+/([^/:])', r'\1/.../\2', - line) # Avoid absolute paths + # Avoid absolute paths + line = re.sub(r'%Error: /[^: ]+/([^/:])', r'%Error: .../\1', line) + line = re.sub(r'("file://)/[^: ]+/([^/:])', r'\1/.../\2', line) line = re.sub(r' \/[^ ]+\/verilated_std.sv', ' verilated_std.sv', line) + line = re.sub(r'(With current working directory \')[^\']+\'', r"\1...'", line) # (line, n) = re.subn(r'Exiting due to.*', r"Exiting due to", line) if n: diff --git a/test_regress/t/t_gen_missing_bad.out b/test_regress/t/t_gen_missing_bad.out index dbb9b7cae..e2177eaf0 100644 --- a/test_regress/t/t_gen_missing_bad.out +++ b/test_regress/t/t_gen_missing_bad.out @@ -12,4 +12,5 @@ obj_vlt/t_gen_missing_bad/foo_not_needed obj_vlt/t_gen_missing_bad/foo_not_needed.v obj_vlt/t_gen_missing_bad/foo_not_needed.sv + ... With current working directory '...' %Error: Exiting due to diff --git a/test_regress/t/t_gen_nonconst_bad.out b/test_regress/t/t_gen_nonconst_bad.out index c8040c249..59219cbc9 100644 --- a/test_regress/t/t_gen_nonconst_bad.out +++ b/test_regress/t/t_gen_nonconst_bad.out @@ -10,4 +10,5 @@ obj_dir/nfound obj_dir/nfound.v obj_dir/nfound.sv + ... With current working directory '...' %Error: Exiting due to diff --git a/test_regress/t/t_hier_block_type_param_notfound_bad.out b/test_regress/t/t_hier_block_type_param_notfound_bad.out index f1267fb24..99f25a45e 100644 --- a/test_regress/t/t_hier_block_type_param_notfound_bad.out +++ b/test_regress/t/t_hier_block_type_param_notfound_bad.out @@ -10,4 +10,5 @@ obj_vlt/t_hier_block_type_param_notfound_bad//does-not-exist obj_vlt/t_hier_block_type_param_notfound_bad//does-not-exist.v obj_vlt/t_hier_block_type_param_notfound_bad//does-not-exist.sv + ... With current working directory '...' %Error: Exiting due to diff --git a/test_regress/t/t_package_dup_bad2.out b/test_regress/t/t_package_dup_bad2.out index 599412e6f..05bc38230 100644 --- a/test_regress/t/t_package_dup_bad2.out +++ b/test_regress/t/t_package_dup_bad2.out @@ -20,4 +20,5 @@ obj_vlt/t_package_dup_bad2/IOBUF obj_vlt/t_package_dup_bad2/IOBUF.v obj_vlt/t_package_dup_bad2/IOBUF.sv + ... With current working directory '...' %Error: Exiting due to diff --git a/test_regress/t/t_preproc_inc_notfound_bad.out b/test_regress/t/t_preproc_inc_notfound_bad.out index 9e956aff5..a523fae01 100644 --- a/test_regress/t/t_preproc_inc_notfound_bad.out +++ b/test_regress/t/t_preproc_inc_notfound_bad.out @@ -12,4 +12,5 @@ obj_vlt/t_preproc_inc_notfound_bad/this_file_is_not_found.vh obj_vlt/t_preproc_inc_notfound_bad/this_file_is_not_found.vh.v obj_vlt/t_preproc_inc_notfound_bad/this_file_is_not_found.vh.sv + ... With current working directory '...' %Error: Exiting due to