-
Notifications
You must be signed in to change notification settings - Fork 9
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
Visibility of symbols (version-script, shared, etc.) #2
Comments
I updated https://github.com/umarcor/ghdl-cosim/blob/symbols/vhpidirect/shared/shghdl/run.sh to include multiple tests for Non-working (
Working:
Notes:
Ideally, wither /cc @RocketRoss |
So the easiest solution is to automatically insert |
That would be a step forward, but I'm afraid it'd be a partial fix for For instance, in https://github.com/VUnit/cosim/blob/master/cosim/vhpidirect/c/grt.ver, 8 additional functions are defined. These are used from Python (https://github.com/VUnit/cosim/blob/master/examples/buffer/corun.py#L80), in order to share pointers to simulation data from Python, C/C++ and VHDL/GHDL at the same time (which is the underlaying topic in this conversation: VUnit/vunit#603). The build procedure that we are currently using is gcc -shared -Wl,`ghdl --list-link tb` -Wl,--version-script=../../vhpidirect.ver -o tb.so which should be equivalent to: ghdl -e -Wl,-shared -Wl,-Wl,--version-script=../../vhpidirect.ver -o tb.so tb As per ghdl/ghdl#800 (comment). However, when I tried it in order to document it, it does not work (as reported above). For reference, a year ago you already explained that adding |
So the easiest solution is to automatically insert -Wl,-u,ghdl_main when -shared is used.
That would be a step forward, but I'm afraid it'd be a partial fix for ghdl_main only. It would allow to build a shared library (hopefully a DLL on MSYS2; didn't try it yet), which can be dynamically loaded in order to execute a GHDL simulation. Unfortunately, it would still hide other functions which might be defined in the same library, wouldn't it?
If we don't use a version script, all (public) symbols will be exported. So no function will be hidden.
The issue with ghdl_main is different: this symbol is defined in libgrt.a but not undefined by the .so, so by default not included in the .so. By adding -u ghdl_main, it gets linked in the .so.
For reference, a year ago you already explained that adding -shared to GHDL itself might not be desirable: ghdl/ghdl#800 (comment). Some months later, there was this conversation about making GHDL a shared lib by default, and providing a CLI to interact with it: ghdl/ghdl#840 (comment). Hence, I am ok with this not being a priority at all. I'd just like to know whether this should work by finding the correct set of options for GCC, or if you expect some further feature to be required inside GHDL (such as building a SYM table explicitly).
We could revisit this choice and maybe build a libgrt.so
|
I run another set of tests, including another C function (
Hence:
Hence, yes, it would make sense to add So, the recommended procedure will be ghdl -e -Wl,shared -Wl,--version-script=./test.ver -Wl,-u,ghdl_main -o tb.so tb
gcc test.c -shared -Wl,`ghdl --list-link tb` -Wl,--version-script=./test.ver -Wl,-u,ghdl_main -o tb.so
First off, the answer to my doubt was that I was overthinking 😄 . There is already a suitable set of GCC arguments, and it is not as cumbersome as I thought. Nonetheless, I believe that Regarding building and distributing
|
So, the recommended procedure will be ghdl -e -shared -o tb.so tb, and any of the following will provide similar artifacts but with filtered symbols. Is it correct?
ghdl -e -Wl,shared -Wl,--version-script=./test.ver -Wl,-u,ghdl_main -o tb.so tb
gcc test.c -shared -Wl,
`ghdl --list-link tb` -Wl,--version-script=./test.ver -Wl,-u,ghdl_main -o tb.so
Yes, that's correct.
• Would all the binaries generated by LLVM/GCC backends dynamically load libgrt, instead of having it embedded?
I am not sure about that. Building self-contained binaries is easier for users.
• Would this modify distribution restrictions (due to licensing) of binaries generated by GHDL? In a sense, it would allow alternative implementation of libgrt.so to be used at runtime (should any exist).
We could move to LGPL, but I am not sure the distribution restrictions are really a problem.
• If that is the new default, would there be a -static option to preserve the current binary type (with embedded grt but runtime dependent on libgnat)? So, the default would be a binary using libgrt; -shared would be a shared lib using libgrt; and -static would be a binary with embedded ligrt.
Currently there is no dependency on libgnat. I am not sure about all these possibilities.
|
Awesome.
There is the use case to distribute behavioural/functional executable models of a given non-open hardware design. As a matter of fact, this is how ARM uses Verilator. Design Simulation Models (DSMs) are said to be generated from the actual Verilog sources (which you don't get to see). By the same token, Verilator is presented as an alternative to distribution of encrypted bitstreams for the same evaluation purposes. The claim is that there is so much obfuscation from Verilog to C++/SystemC that it is not possible to reverse engineer the netlist. I believe that many of the companies in https://www.veripool.org/wiki/verilator use it and endorse it for similar purposes. Anyway, on the one hand, GPL does not require sources to be shipped with the binary, they can be made available upon demand through access to a private server. On the other hand, as you said, there is the plan to add a new backend/elaborator to plug VHDL into Verilator (or to generate compatible C++/SystemC sources?). That would be a solution for BSD-alike users.
Good to know!
It's ok. If the default is not going to change, there is no need to think about it. |
This issue is to work on documenting the multiple approaches to modify/customise which symbols are visible/hidden when a binary or shared library is generated using VHPIDIRECT/C. Precisely, to enhance https://ghdl.github.io/ghdl-cosim/vhpidirect/examples/shared.html#shghdl
WIP: https://github.com/umarcor/ghdl-cosim/tree/symbols
Refs:
ghdl --list-link
ghdl#640/cc @RocketRoss
The text was updated successfully, but these errors were encountered: