Reputation: 301
I am trying to compile and link the runtime support code for Verilator (veripool.org). It builds fine, but for some reason there are a couple of methods which aren't showing up in the pertinent object file, Verilated::timeunit(int)
and Verilated::timeprecision(int)
.
Those are ostensibly defined in include/verilated.h:
static int timeunit() VL_MT_SAFE { return Verilated::threadContextp()->timeunit(); }
static int timeprecision() VL_MT_SAFE { return Verilated::threadContextp()->timeprecision(); }
Now, you can see that there is a parameter to both methods of type int
in the calling function which shows up in the linking step:
ld: /home/jon/controlix/src/nuttx/nuttx/staging/libcontrols.a(Vhello_world__ALL.o): in function `Vhello_world::__Vconfigure(Vhello_world__Syms*, bool)':
Vhello_world__ALL.cpp:(.text+0x15): undefined reference to `Verilated::timeunit(int)'
Vhello_world__ALL.cpp:(.text+0x15): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `Verilated::timeunit(int)'
ld: Vhello_world__ALL.cpp:(.text+0x20): undefined reference to `Verilated::timeprecision(int)'
Vhello_world__ALL.cpp:(.text+0x20): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `Verilated::timeprecision(int)'
l
I have tried changing the method declarations in verilated.h
to take an int as a parameter even though lack of that should cause a compile-time error, but still those two method declarations don't show up in the symbol table for verilated.cpp
. Other methods in the Verilated::
class show up just fine.
What am I missing?
Upvotes: 2
Views: 338
Reputation: 238361
Why is a c++ method which is defined static in a header file not showing up in a symbol table
Edit: Initially, I assumed that those are non-member functions such as in your quote. Looking at the source, I find that they are member functions. But what I also find is:
#ifndef VL_NO_LEGACY // Deprecated static int timeunit() VL_MT_SAFE { return Verilated::threadContextp()->timeunit(); } static int timeprecision() VL_MT_SAFE { return Verilated::threadContextp()->timeprecision(); }
If the macro VL_NO_LEGACY
is defined, then those functions won't be defined nor declared. This would explain the lack of their symbols.
Verilated::timeunit(int)
andVerilated::timeprecision(int)
.Those are ostensibly defined in include/verilated.h:
static int timeunit() VL_MT_SAFE { return Verilated::threadContextp()->timeunit(); } static int timeprecision() VL_MT_SAFE { return Verilated::threadContextp()->timeprecision(); }
No, those are definitely not definitions of the functions declared above. Note the different parameter list.
even though lack of that should cause a compile-time error
Not necessarily. The definition of static int timeunit()
won't hinder the declaration of Verilated::timeunit(int)
.
Upvotes: 3