Skip to content

Yosys not reporting non-existing files #5013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MrJake222 opened this issue Apr 10, 2025 · 3 comments · Fixed by #5073
Closed

Yosys not reporting non-existing files #5013

MrJake222 opened this issue Apr 10, 2025 · 3 comments · Fixed by #5073
Assignees

Comments

@MrJake222
Copy link

Version

Yosys 0.51+125 (git sha1 cc8fd3e, g++ 12.2.0-14 -fPIC -O3)

On which OS did this happen?

Linux

Reproduction Steps

  1. Run yosys on non-existent files: yosys nonexistent.v

Expected Behavior

Yosys reports the files as missing / non-existent.

Actual Behavior

Yosys doesn't report missing files. It happily concludes the parsing with Successfully finished Verilog frontend. despite the file not being there.

$ ls nonexistent.v
ls: cannot access 'nonexistent.v': No such file or directory
$ yosys nonexistent.v

 /----------------------------------------------------------------------------\
 |  yosys -- Yosys Open SYnthesis Suite                                       |
 |  Copyright (C) 2012 - 2025  Claire Xenia Wolf <[email protected]>         |
 |  Distributed under an ISC-like license, type "license" to see terms        |
 \----------------------------------------------------------------------------/
 Yosys 0.51+125 (git sha1 cc8fd3efc, g++ 12.2.0-14 -fPIC -O3)

-- Parsing `nonexistent.v' using frontend ` -vlog2k' --

1. Executing Verilog-2005 frontend: nonexistent.v
Parsing Verilog input from `nonexistent.v' to AST representation.
Successfully finished Verilog frontend.

yosys> 
exit

End of script. Logfile hash: 277a437cbe, CPU: user 0.00s system 0.01s, MEM: 15.56 MB peak
Yosys 0.51+125 (git sha1 cc8fd3efc, g++ 12.2.0-14 -fPIC -O3)
Time spent: 93% 2x read_verilog (0 sec), 6% 1x read (0 sec)
@MrJake222 MrJake222 added the pending-verification This issue is pending verification and/or reproduction label Apr 10, 2025
@KrystalDelusion
Copy link
Member

It looks like this bug snuck in with #4834

 Yosys 0.50 (git sha1 b5170e139, ccache clang++ 18.1.8 -fPIC -O3)

yosys> read_verilog bad.v
ERROR: Can't open input file `bad.v' for reading: No such file or directory

@KrystalDelusion KrystalDelusion self-assigned this Apr 22, 2025
@KrystalDelusion KrystalDelusion added bug regression and removed pending-verification This issue is pending verification and/or reproduction labels Apr 22, 2025
@KrystalDelusion
Copy link
Member

@widlarizer Can you take a look at this? The other users of Yosys::uncompressed() look like:

std::istream* f = uncompressed(liberty_file.c_str());
yosys_input_files.insert(liberty_file);
if (f->fail())
	log_cmd_error("Can't open liberty file `%s': %s\n", liberty_file.c_str(), strerror(errno));

while register.cc is:

f = uncompressed(filename, bin_input ? std::ifstream::binary : std::ifstream::in);
if (f == NULL)
	log_cmd_error("Can't open input file `%s' for reading: %s\n", filename.c_str(), strerror(errno));

And I'm not sure if the correct solution is to return nullptr and change the lib users to test f == NULL, or change register.cc to check f == NULL || f->fail()).

@sdjasj
Copy link
Contributor

sdjasj commented May 7, 2025

@KrystalDelusion Hi, I just came across this issue and found it quite interesting, so I did some additional testing. I noticed that when using read_verilog to read an existing directory, it doesn't report an error, even though it's not a valid Verilog file. I'm not sure if this behavior is expected.

mkdir temp && yosys -p "read_verilog temp"

 /----------------------------------------------------------------------------\
 |  yosys -- Yosys Open SYnthesis Suite                                       |
 |  Copyright (C) 2012 - 2025  Claire Xenia Wolf <[email protected]>         |
 |  Distributed under an ISC-like license, type "license" to see terms        |
 \----------------------------------------------------------------------------/
 Yosys 0.52+137 (git sha1 aa30589c1, clang++ 14.0.0-1ubuntu1.1 -Og -fPIC -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address,undefined,leak)

-- Running command `read_verilog temp' --

1. Executing Verilog-2005 frontend: temp
Parsing Verilog input from `temp' to AST representation.
Successfully finished Verilog frontend.

End of script. Logfile hash: 405974766d, CPU: user 0.03s system 0.04s, MEM: 84.32 MB peak
Yosys 0.52+137 (git sha1 aa30589c1, clang++ 14.0.0-1ubuntu1.1 -Og -fPIC -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address,undefined,leak)
Time spent: 100% 2x read_verilog (0 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants