msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.22k stars 1.19k forks source link

Verilator Mdir fails with absolute path if perl is installed as well #14895

Open eactor opened 1 year ago

eactor commented 1 year ago

Description / Steps to reproduce the issue

Using a absolute path for the Mdir option in verilator fails if also mingw-w64-x86_64-perl is installed on the system. Reproduce:

pacman -S mingw-w64-x86_64-perl mingw-w64-x86_64-verilator
verilator --sc --top-module counter counter.sv --Mdir C:/workspace/verilator_workdir

Notes: Looking into other environments it seems verilator always has dependencies to perl which are installed, but not within msys2. Uninstalling perl fixes the issue as well but might not be an option. Last version that worked for me 4.106 stopped working 4.226 or earlier.

Simple System Verilog - Example:

module counter    (
output reg [7:0] out,
input  wire      clk,
input  wire      rst
);

always_ff @(posedge clk)
if (rst) begin
  out <= 8'b0 ;
end else begin
  out <= out +8'b1;
end
endmodule 

Expected behavior

Run without error.

Actual behavior

XYZ@PC MINGW64 /c/workspace/sv_example $ verilator --version Verilator 5.002 2022-10-29 rev UNKNOWN.REV $ which verilator /mingw64/bin/verilator verilator --sc --top-module counter --pins-sc-uint counter.sv --Mdir C:/workspaces/verilator_workdir %Error: Cannot write C\:/workspaces/verilator_workdir//Vcounter__Syms.cpp

Verification

Windows Version

MINGW64_NT-10.0-19045

MINGW environments affected

Are you willing to submit a PR?

No response

Biswa96 commented 1 year ago

I got different message like the following

$ verilator --sc --top-module counter --pins-sc-uint counter.sv --Mdir C:/workspaces/verilator_workdir
%Error: Need $SYSTEMC_INCLUDE in environment or when Verilator configured,
and need $SYSTEMC_LIBDIR in environment or when Verilator configured
Probably System-C isn't installed, see http://www.systemc.org

Is it the right output? Could you make sure that antivirus software is not blocking the process by excluding msys2 installation directory in that software?

I am using same Windows 10 build 19045 and MINGW64. I have created the C:/workspaces/verilator_workdir directory before running the verilator command.

eactor commented 1 year ago

Thanks for looking into the problem. Could you please replace --sc with --cc to create C++ output instead of SystemC. The error message only says that you don't have SystemC available.

Biswa96 commented 1 year ago

replace --sc with --cc to create C++ output instead of SystemC.

After doing that, the command worked fine. No error or normal message output.

Biswa96 commented 1 year ago

Oh, wait a sec. I missed the point "if perl is installed". After installing mingw-w64-x86_64-perl I got the same error as you got.

$ verilator --cc --top-module counter --pins-sc-uint counter.sv --Mdir C:/workspaces/verilator_workdir
The system cannot find the path specified.
%Error: Cannot write C\:/workspaces/verilator_workdir/Vcounter__Syms.cpp

I shall try to debug it.

stevenclarke9 commented 1 year ago

hi guys i've got verilator to install and I used the command to compile the counter.sv file. I only have the msys-perl installed. all the counter files are written into the C:/workspaces/verilator_workdir. verilator.txt

Biswa96 commented 1 year ago

The msys2 perl package does not create the issue which I did in first comment. This issue seems to happen only when mingw perl is installed.

Biswa96 commented 1 year ago

I have found the cause. The file "verilator" is a perl script which has this shebang line #!/usr/bin/env perl . The env perl command returns /mingw64/bin/perl.exe. If mingw perl is not installed the "verilator" perl script is interpreted by /usr/bin/perl.exe without any issue. So, the main issue may be the difference between mingw perl and msys perl and their interpretation of Windows paths in that verilator script. Sadly, I am not familiar with perl language. @umarcor may provide some helpful info.

BTW, the verilator perl script executes verilator_bin which is the actual Win32 exe. So, the later one works.

$ verilator --cc --top-module counter --pins-sc-uint counter.sv --Mdir C:/workspaces/verilator_workdir
The system cannot find the path specified.
%Error: Cannot write C\:/workspaces/verilator_workdir/Vcounter__Syms.cpp

$ verilator_bin --cc --top-module counter --pins-sc-uint counter.sv --Mdir C:/workspaces/verilator_workdir

$ echo $?
0
eactor commented 1 year ago

This explains my observation that verilator always installs perl in other environments. As the msys perl is always installed as pacman dependency.