Verilator simulation fails after upgrading to chiseltest 0.5.0-RC1

143 views
Skip to first unread message

sam...@gmail.com

unread,
Nov 28, 2021, 10:22:42 PM11/28/21
to chisel-users

Hi all,

I’ve upgraded chiseltest from 0.3.3 of chisel-template to 0.5.0-RC1 to try out the iVerilog backend.
By adding .withAnnotations to GCDSpec in the chisel-template, both the treadle and iVerilog backend works as expected. However, the Verilator backend, which worked back in chiseltest 0.3.3, now fails with these errors:

/usr/bin/ld: ../verilated.o: relocation R_X86_64_PC32 against symbol `_ZN12VerilatedImp3s_sE' can not be used when making a shared object; recompile with -fPIC

/usr/bin/ld: final link failed: Bad value

collect2: error: ld returned 1 exit status

make: *** [VDecoupledGcd] Error 1 

- should Gcd should calculate proper greatest common denominator in Verilator *** FAILED *** 

  os.SubprocessException: CommandResult 2
 make: Entering directory '/local/samh/repos/dsk3.hkg/ssag/test_run_dir/should_Gcd_should_calculate_proper_greatest_common_denominator_in_Verilator/verilated'
 g++  -I.  -MMD -I/usr/local/share/verilator/include -I/usr/local/share/verilator/include/vltstd -DVM_COVERAGE=1 -DVM_SC=0 -DVM_TRACE=0 -faligned-new -Wno-bool-operation -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow     -O1 -DVL_USER_FINISH -DTOP_TYPE=VDecoupledGcd -include VDecoupledGcd.h -fPIC -shared -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -fvisibility=hidden   -c -o DecoupledGcd-harness.o ../DecoupledGcd-harness.cpp
 g++  -I.  -MMD -I/usr/local/share/verilator/include -I/usr/local/share/verilator/include/vltstd -DVM_COVERAGE=1 -DVM_SC=0 -DVM_TRACE=0 -faligned-new -Wno-bool-operation -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow     -O1 -DVL_USER_FINISH -DTOP_TYPE=VDecoupledGcd -include VDecoupledGcd.h -fPIC -shared -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -fvisibility=hidden   -c -o verilated_cov.o /usr/local/share/verilator/include/verilated_cov.cpp /usr/bin/perl /usr/local/share/verilator/bin/verilator_includer -DVL_INCLUDE_OPT=include VDecoupledGcd.cpp > VDecoupledGcd__ALLfast.cpp /usr/bin/perl /usr/local/share/verilator/bin/verilator_includer -DVL_INCLUDE_OPT=include VDecoupledGcd__Syms.cpp > VDecoupledGcd__ALLslow.cpp
 g++  -I.  -MMD -I/usr/local/share/verilator/include -I/usr/local/share/verilator/include/vltstd -DVM_COVERAGE=1 -DVM_SC=0 -DVM_TRACE=0 -faligned-new -Wno-bool-operation -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow     -O1 -DVL_USER_FINISH -DTOP_TYPE=VDecoupledGcd -include VDecoupledGcd.h -fPIC -shared -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -fvisibility=hidden   -c -o VDecoupledGcd__ALLfast.o VDecoupledGcd__ALLfast.cpp
 g++  -I.  -MMD -I/usr/local/share/verilator/include -I/usr/local/share/verilator/include/vltstd -DVM_COVERAGE=1 -DVM_SC=0 -DVM_TRACE=0 -faligned-new -Wno-bool-operation -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow     -O1 -DVL_USER_FINISH -DTOP_TYPE=VDecoupledGcd -include VDecoupledGcd.h -fPIC -shared -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -fvisibility=hidden   -c -o VDecoupledGcd__ALLslow.o VDecoupledGcd__ALLslow.cpp ar -cr VDecoupledGcd__ALL.a VDecoupledGcd__ALLfast.o VDecoupledGcd__ALLslow.o ranlib VDecoupledGcd__ALL.a
 g++    DecoupledGcd-harness.o ../verilated.o verilated_cov.o VDecoupledGcd__ALL.a   -shared -dynamiclib -fvisibility=hidden  -o VDecoupledGcd  
 VDecoupledGcd.mk:65: recipe for target 'VDecoupledGcd' failed
make: Leaving directory '/local/samh/repos/dsk3.hkg/ssag/test_run_dir/should_Gcd_should_calculate_proper_greatest_common_denominator_in_Verilator/verilated' 

  at os.proc.call(ProcessOps.scala:85) 

  at chiseltest.simulator.VerilatorSimulator$.compileSimulation(VerilatorSimulator.scala:141) 

  at chiseltest.simulator.VerilatorSimulator$.createContextFromScratch(VerilatorSimulator.scala:113) 

  at chiseltest.simulator.VerilatorSimulator$.$anonfun$createContext$1(VerilatorSimulator.scala:69) 

  at chiseltest.simulator.Caching$.cacheSimulationBin(Caching.scala:22) 

  at chiseltest.simulator.VerilatorSimulator$.createContext(VerilatorSimulator.scala:69) 

  at chiseltest.internal.BackendExecutive$.start(BackendExecutive.scala:36) 

  at chiseltest.defaults.package$.createDefaultTester(defaults.scala:25) 

  at chiseltest.ChiselScalatestTester$TestBuilder.apply(ChiselScalatestTester.scala:37) 

  at gcd.GCDSpec.$anonfun$new$1(GCDSpec.scala:69)

The link error on the 1st line seemed odd, I did see the -fPIC flag being passed in in several places.
Any ideas?

Best regards,
Sam

sam...@gmail.com

unread,
Nov 28, 2021, 11:51:23 PM11/28/21
to chisel-users

Hi all,

Turns out the verilated.o was not compiled with -fPIC flag, so I just launched the test with

USER_CPPFLAGS="-fPIC" sbt "testOnly gcd.GCDSpec"

and things worked as expected.

Thanks,
Sam

Kevin Laeufer

unread,
Nov 29, 2021, 12:14:15 AM11/29/21
to chisel...@googlegroups.com
Hi Sam,

Thanks for figuring out a fix!

Would you mind sharing some info about your OS and the exact version of Verilator you are using?

I would like to investigate why our CI did not catch this (we run all supported verilator versions on Ubuntu).

Regards,
Kevin


On Nov 28, 2021, at 20:51, sam...@gmail.com <sam...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "chisel-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chisel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/fd640f69-d008-478f-b027-d1c9c8c9ab1an%40googlegroups.com.

sam...@gmail.com

unread,
Nov 29, 2021, 1:36:59 AM11/29/21
to chisel-users
Hi Kevin,

Sure. 
OS: Ubuntu 18.04.5 LTS
Verilator: 4.034, compiled from tag "v4.034" of repo "http://git.veripool.org/git/verilator"
g++: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

Thanks,
Sam
Reply all
Reply to author
Forward
0 new messages