Skip to content
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

Example fails to build #9

Open
TheZoq2 opened this issue May 25, 2022 · 7 comments
Open

Example fails to build #9

TheZoq2 opened this issue May 25, 2022 · 7 comments

Comments

@TheZoq2
Copy link

TheZoq2 commented May 25, 2022

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
Copy link
Owner

djg commented Jun 1, 2022

Thanks for the report.

@djg
Copy link
Owner

djg commented Jun 1, 2022

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

cchalmers added a commit to cchalmers/verilated-rs that referenced this issue Aug 20, 2022
Fixes djg#9. Might not always work, but it does for the current example. Tested with verilator 4.222.
@tommythorn
Copy link

I just repulled again (and switched to main). At efab3b3 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
Copy link

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
Copy link

Anillc commented Nov 7, 2023

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).

Anillc added a commit to Anillc/verilated-rs that referenced this issue Nov 7, 2023
Anillc added a commit to Anillc/verilated-rs that referenced this issue Dec 9, 2023
ngildenhuys added a commit to ngildenhuys/verilated-rs that referenced this issue Jul 22, 2024
@tommythorn
Copy link

Has this crate been abandoned? There are four pull requests with not even a comment

@ethanuppal
Copy link

@tommythorn Has this crate been abandoned? There are four pull requests with not even a comment

Perhaps, I'm looking into maybe writing a more general set of bindings, potentially also handling cxxrtl. I did similar work for Calyx (think LLVM for hardware) by writing bindings to Calyx's hand rolled simulator.

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

No branches or pull requests

5 participants