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

Question: How to compile a .so file? #4273

Closed
davidbai13 opened this issue Jun 6, 2023 · 2 comments
Closed

Question: How to compile a .so file? #4273

davidbai13 opened this issue Jun 6, 2023 · 2 comments
Labels
area: configure/compiling Issue involves configuring or compilating Verilator itself resolution: answered Closed; only applies to questions which were answered

Comments

@davidbai13
Copy link

I want to compile the system verilog file into a .so file.
(ex system verilog -> /cpp's -> . /obj_dir/VTop.so )
Or select the files from the generated cpp's that can be used to generate so files and then use gcc to generate the so files.
Is there a way to do this please?
thank you

@davidbai13 davidbai13 added the new New issue not seen by maintainers label Jun 6, 2023
@wsnyder wsnyder added area: configure/compiling Issue involves configuring or compilating Verilator itself status: asked reporter Bug is waiting for reporter to answer a question and removed new New issue not seen by maintainers labels Jun 6, 2023
@wsnyder
Copy link
Member

wsnyder commented Jun 6, 2023

Note C++ may behave badly if a shared object that contains C++ standard library calls (like Verilator uses) isn't loaded into a main program that used the exact same version of C++ standard library. So don't do this if you can't ensure this.

Verilator doesn't have rules to make .so files itself. So you'll need to write your own makefile rule to make the shared object.

You can see all of the .cpp files needed in the generated .mk file. Then you'll need to figure out the right $(LD) command to build a shared object, modeling on the default rule in verilated.mk, e.g. something like (untested)

$(VM_PREFIX)__ALL.so: $(VK_OBJS) $(VM_HIER_LIBS)
   $(LD) $(LDFLAGS) $(LOADLIBES) $(LDLIBS) -shared -o $@ $^

You'll have to experiment with this, shared objects can be complicated to get right.

When you get a rule/process that works here please report back to help the next person.

@wsnyder wsnyder added resolution: answered Closed; only applies to questions which were answered and removed status: asked reporter Bug is waiting for reporter to answer a question labels Jun 17, 2023
@wsnyder
Copy link
Member

wsnyder commented Jun 17, 2023

Closing as answered (with ideas as opposed to exact recipe) but please feel free to follow up with how you did it, etc.

@wsnyder wsnyder closed this as completed Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: configure/compiling Issue involves configuring or compilating Verilator itself resolution: answered Closed; only applies to questions which were answered
Projects
None yet
Development

No branches or pull requests

2 participants