SystemC 2.3.0 does not work with Verilator tests
I've just discovered that the Verilator tests (make test) do not work with the new SystemC 2.3.0, failing due to lack of a -pthread library specification. Here is the failure
g++ -L/opt/systemc/lib-linux64 -g sc_main.o verilated.o verilated_vcd_c.o verilated_vcd_sc.o Vtop__ALL.a /opt/systemc/lib-linux64/libsystemc.a -o simx -lsystemc -lm -lstdc++ 2>&1 | c++filt /opt/systemc/lib-linux64/libsystemc.a(sc_prim_channel.o): In function `sc_core::sc_host_mutex::trylock()': sc_prim_channel.cpp:(.text._ZN7sc_core13sc_host_mutex7trylockEv[sc_core::sc_host_mutex::trylock()]+0x9): undefined reference to `pthread_mutex_trylock' collect2: ld returned 1 exit status make: Leaving directory `/home/verilator/src/test_sc/obj_dir' obj_dir/simx make: obj_dir/simx: Command not found make: *** [run] Error 127 make: Leaving directory `/home/verilator/src/test_sc' make: *** [test_sc] Error 2
Manually rerunning the g++ command with -lpthread added cures the problem. There is no problem when using SystemC 2.2.0.
I have no urgent need for this - I just noticed it when running on a new System, where I installed the latest SystemC. I'm quite happy to keep using 2.2.0 for the time being.
#1 Updated by Wilson Snyder over 1 year ago
Yes, you need to
Annoyingly that wasn't needed in the pre-released 2.3.0.
Verilator can't easily assume -pthread as it's platform specific, and depends on how SystemC was built. There's probably a way to write a fancy configure.ac rule to detect if this is needed or not automatically. If you'd like to attempt it, that would probably help others.