Fix shortened module names when searching for files (#5196) (#5246)

This commit is contained in:
Tim Hutt 2024-08-09 22:23:00 +01:00 committed by GitHub
parent 367249ec84
commit c812a9b18f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 76 additions and 49 deletions

View File

@ -553,7 +553,7 @@ string V3Options::filePath(FileLine* fl, const string& modname, const string& la
// Find a filename to read the specified module name,
// using the incdir and libext's.
// Return "" if not found.
const string filename = V3Os::filenameCleanup(modname);
const string filename = V3Os::filenameCleanup(VName::dehash(modname));
if (!V3Os::filenameIsRel(filename)) {
// filename is an absolute path, so can find getStdPackagePath()
string exists = filePathCheckOneDir(filename, "");
@ -585,8 +585,8 @@ void V3Options::filePathLookedMsg(FileLine* fl, const string& modname) {
static bool shown_notfound_msg = false;
if (modname.find("__Vhsh") != string::npos) {
std::cerr << V3Error::warnMoreStandalone()
<< "... Unsupported: Name is longer than 127 characters;"
<< " automatic file lookup not supported.\n";
<< "... Note: Name is longer than 127 characters; automatic"
<< " file lookup may have failed due to OS filename length limits.\n";
std::cerr << V3Error::warnMoreStandalone()
<< "... Suggest putting filename with this module/package"
<< " onto command line instead.\n";

58
test_regress/t/t_inst_long.pl Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
use IO::File;
use strict;
use vars qw($Self);
scenarios(vlt => 1);
my $length = 200;
my $long = "long_" x (($length + 4) / 5);
sub gen_top {
my $filename = shift;
my $fh = IO::File->new(">$filename")
or $Self->error("Can't write $filename");
$fh->print("// Generated by t_inst_long.pl\n");
$fh->print("module t;\n");
$fh->print("\n");
$fh->print(" ${long} inst ();\n");
$fh->print("\n");
$fh->print("endmodule\n");
$fh->close;
}
sub gen_sub {
my $filename = shift;
my $fh = IO::File->new(">$filename")
or $Self->error("Can't write $filename");
$fh->print("// Generated by t_inst_long.pl\n");
$fh->print("module ${long};\n");
$fh->print("\n");
$fh->print(" initial begin\n");
$fh->print(" \$write(\"*-* All Finished *-*\\n\");\n");
$fh->print(" \$finish;\n");
$fh->print(" end\n");
$fh->print("endmodule\n");
$fh->close;
}
top_filename("$Self->{obj_dir}/t_inst_long.v", $long);
gen_top($Self->{top_filename});
gen_sub("$Self->{obj_dir}/${long}.v");
compile();
ok(1);
1;

View File

@ -1,6 +1,6 @@
%Error: obj_vlt/t_inst_long_bad/t_inst_long.v:4:3: Cannot find file containing module: 'long_long_long_long_long_long___Vhsh1JZCXQVBM1QiASYlLmgTuAXYyUr7VAbJYwVHfiAD'
4 | long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_ inst ();
%Error: t/t_inst_long_bad.v:9:3: Cannot find file containing module: 'long_long_long_long_long_long___Vhsh1JZCXQVBM1QiASYlLmgTuAXYyUr7VAbJYwVHfiAD'
9 | long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_ inst ();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... Unsupported: Name is longer than 127 characters; automatic file lookup not supported.
... Note: Name is longer than 127 characters; automatic file lookup may have failed due to OS filename length limits.
... Suggest putting filename with this module/package onto command line instead.
%Error: Exiting due to

View File

@ -8,49 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
use IO::File;
use strict;
use vars qw($Self);
scenarios(vlt => 1);
my $length = 200;
my $long = "long_" x (($length + 4) / 5);
sub gen_top {
my $filename = shift;
my $fh = IO::File->new(">$filename")
or $Self->error("Can't write $filename");
$fh->print("// Generated by t_inst_long.pl\n");
$fh->print("module t;\n");
$fh->print("\n");
$fh->print(" ${long} inst ();\n");
$fh->print("\n");
$fh->print("endmodule\n");
$fh->close;
}
sub gen_sub {
my $filename = shift;
my $fh = IO::File->new(">$filename")
or $Self->error("Can't write $filename");
$fh->print("// Generated by t_inst_long.pl\n");
$fh->print("module ${long};\n");
$fh->print("\n");
$fh->print(" initial begin\n");
$fh->print(" \$write(\"*-* All Finished *-*\\n\");\n");
$fh->print(" \$finish;\n");
$fh->print(" end\n");
$fh->print("endmodule\n");
$fh->close;
}
top_filename("$Self->{obj_dir}/t_inst_long.v", $long);
gen_top($Self->{top_filename});
gen_sub("$Self->{obj_dir}/${long}.v");
scenarios(linter => 1);
lint(
fails => 1,

View File

@ -0,0 +1,11 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2012 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t;
long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_ inst ();
endmodule