djg / verilated-rs

Verilator Porcelain
Apache License 2.0
35 stars 13 forks source link

Example fails to build #9

Open TheZoq2 opened 2 years ago

TheZoq2 commented 2 years ago

This seems like a super cool project, unfortunately, the example in the repo fails to build on my machine, with a missing cpp file:

    Updating crates.io index
   Compiling unicode-xid v0.1.0
   Compiling memchr v2.5.0
   Compiling regex-syntax v0.6.26
   Compiling cc v1.0.73
   Compiling fnv v1.0.7
   Compiling proc-macro2 v0.3.8
   Compiling quote v0.5.2
   Compiling syn v0.13.11
   Compiling aho-corasick v0.7.18
   Compiling regex v1.5.6
   Compiling verilator v0.1.6 (/tmp/verilated-rs/verilator)
   Compiling verilated v0.1.2 (/tmp/verilated-rs/verilated)
   Compiling example v0.0.0 (/tmp/verilated-rs/example)
   Compiling verilated-module v0.1.1 (/tmp/verilated-rs/verilated-module)
The following warnings were emitted during compilation:

warning: cc1plus: fatal error: /tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop__Slow.cpp: No such file or directory
warning: compilation terminated.

error: failed to run custom build command for `example v0.0.0 (/tmp/verilated-rs/example)`

Caused by:
  process didn't exit successfully: `/tmp/verilated-rs/target/debug/build/example-47864a376f1eeb3a/build-script-build` (exit status: 1)
  --- stdout
  6 items
  cargo:rerun-if-changed=src/main.rs
  running: "/usr/bin/verilator_bin" "--getenv" "VERILATOR_ROOT"
  verilator root: "/usr/share/verilator"
  running: "/usr/bin/verilator_bin" "--cc" "-Mdir" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out" "--top-module" "top" "--coverage" "--trace" "+1364-2001ext+v" "rtl/counter.v" "+1364-2001ext+v" "rtl/top.v" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/top.cpp"
  OPT_LEVEL = Some("0")
  CXX_x86_64-unknown-linux-gnu = None
  CXX_x86_64_unknown_linux_gnu = None
  HOST_CXX = None
  CXX = None
  CXXFLAGS_x86_64-unknown-linux-gnu = None
  CXXFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CXXFLAGS = None
  CXXFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/usr/share/verilator/include" "-I" "/usr/share/verilator/include/vltstd" "-I" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out" "-Wall" "-Wextra" "-std=gnu++17" "-faligned-new" "-Wno-bool-operation" "-Wno-sign-compare" "-Wno-uninitialized" "-Wno-unused-but-set-variable" "-Wno-unused-parameter" "-Wno-unused-variable" "-Wno-shadow" "-DVL_PRINTF=printf" "-DVM_COVERAGE=1" "-DVM_TRACE=1" "-o" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop.o" "-c" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/usr/share/verilator/include" "-I" "/usr/share/verilator/include/vltstd" "-I" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out" "-Wall" "-Wextra" "-std=gnu++17" "-faligned-new" "-Wno-bool-operation" "-Wno-sign-compare" "-Wno-uninitialized" "-Wno-unused-but-set-variable" "-Wno-unused-parameter" "-Wno-unused-variable" "-Wno-shadow" "-DVL_PRINTF=printf" "-DVM_COVERAGE=1" "-DVM_TRACE=1" "-o" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop__Syms.o" "-c" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop__Syms.cpp"
  exit status: 0
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/usr/share/verilator/include" "-I" "/usr/share/verilator/include/vltstd" "-I" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out" "-Wall" "-Wextra" "-std=gnu++17" "-faligned-new" "-Wno-bool-operation" "-Wno-sign-compare" "-Wno-uninitialized" "-Wno-unused-but-set-variable" "-Wno-unused-parameter" "-Wno-unused-variable" "-Wno-shadow" "-DVL_PRINTF=printf" "-DVM_COVERAGE=1" "-DVM_TRACE=1" "-o" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop__Slow.o" "-c" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop__Slow.cpp"
  cargo:warning=cc1plus: fatal error: /tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop__Slow.cpp: No such file or directory
  cargo:warning=compilation terminated.
  exit status: 1

  --- stderr

  error occurred: Command "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/usr/share/verilator/include" "-I" "/usr/share/verilator/include/vltstd" "-I" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out" "-Wall" "-Wextra" "-std=gnu++17" "-faligned-new" "-Wno-bool-operation" "-Wno-sign-compare" "-Wno-uninitialized" "-Wno-unused-but-set-variable" "-Wno-unused-parameter" "-Wno-unused-variable" "-Wno-shadow" "-DVL_PRINTF=printf" "-DVM_COVERAGE=1" "-DVM_TRACE=1" "-o" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop__Slow.o" "-c" "/tmp/verilated-rs/target/debug/build/example-04a0d54f79755afe/out/Vtop__Slow.cpp" with args "c++" did not execute successfully (status code exit status: 1).

warning: build failed, waiting for other jobs to finish...
error: build failed

Trying to build with rust 1.59 and verilator version 4.222

djg commented 2 years ago

Thanks for the report.

djg commented 2 years ago

It looks like verilator changed the default naming scheme for the generated C++ source somewhere between 4.108 and 4.222.

tommythorn commented 1 year ago

I just repulled again (and switched to main). At efab3b3275bc49e2204053192a4306463da25dec cargo build fails with

  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-I" "/usr/share/verilator/include" "-I" "/usr/share/verilator/include/vltstd" "-Wall" "-Wextra" "-std=gnu++17" "-faligned-new" "-Wno-bool-operation" "-Wno-sign-compare" "-Wno-uninitialized" "-Wno-unused-but-set-variable" "-Wno-unused-parameter" "-Wno-unused-variable" "-Wno-shadow" "-DVERILATOR_VERSION_MAJOR=4" "-DVERILATOR_VERSION_MINOR=226" "-o" "/home/tommy/projects/verilated-rs/target/debug/build/verilated-2b7a9d3a2d6377b6/out/src/verilatedvcdc_shim.o" "-c" "src/verilatedvcdc_shim.cpp"
  cargo:warning=src/verilatedvcdc_shim.cpp: In function ‘void verilatedvcdc_rollover_mb(VerilatedVcdC*, size_t)’:
  cargo:warning=src/verilatedvcdc_shim.cpp:47:10: error: ‘class VerilatedVcdC’ has no member named ‘rolloverMB’; did you mean ‘rolloverSize’?
  cargo:warning=   47 |     vcd->rolloverMB(rolloverMB);
  cargo:warning=      |          ^~~~~~~~~~
  cargo:warning=      |          rolloverSize

on Asahi Linux (fully up-to-date).

On up-to-date Ubuntu/RISC-V it fails with

...
   Compiling memchr v2.5.0
/home/tommy/.rustup.riscv64-linux/toolchains/stable-riscv64gc-unknown-linux-gnu/bin/../lib/librustc_driver-ac972a4e10c98556.so(+0xc3d810)[0x3f93eb4810]
linux-vdso.so.1(__vdso_rt_sigreturn+0x0)[0x3f9a94a800]
...
/home/tommy/.rustup.riscv64-linux/toolchains/stable-riscv64gc-unknown-linux-gnu/bin/../lib/libstd-f41102d4d21d2c30.so(rust_metadata_std_ac92b06979af539e+0xa0542)[0x3f7e30c542]
/lib/riscv64-linux-gnu/libc.so.6(+0x6a450)[0x3f7e197450]
error: could not compile `unicode-xid`

Caused by:
  process didn't exit successfully: `rustc --crate-name unicode_xid /home/tommy/.cargo.riscv64-linux/registry/src/github.com-1ecc6299db9ec823/unicode-xid-0.1.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -idory ea,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=86b26df15dd8bbd4 -C extra-filename=-86b26df15dd8bbd4 --out-dir /home/tommy/projects/verilated-rs/target/debug/deps -L dependency=/home/tommy/projects/verilated-rs/target/debug/deps --cap-lints allow` (signal: 1 IEG:iv11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: could not compile `memchr`

In all cases Rust is fully updated to version 1.64

Maybe it would make sense to include verilator as a submodule so we are building a known-good version?

tommythorn commented 1 year ago

FWIW, current version (version 0.1.6) builds and runs perfectly for me with Rust 1.64 on Ubuntu 22.10/{Arm64,AMD64,RISC-V}

(However clippy has something to say).

Also FWIW, it still fails to build on Asahi-Linux/M1, but I'm not sure that's the fault of verilated-rs.

I think we can close?

Anillc commented 8 months ago

Executing verilator with --lib-create and using make -f V{top_module}.mk to build instead of calling cc manually may be the better solution.

And verilator renamed rolloverMB to rolloverSize (verilator/verilator#3570).