Conversation
|
I'm curious to learn more about what you're trying to achieve. I have a feeling I'll like it in the end, but please tell us more about it. |
|
Currently, the documented way to write C stubs doesn't work with Functions that use |
|
I don't think the CAML_noreturn part is related to the CAMLprim change - please could they be separate commits. I like the look of that change, but I wonder if there are exotic platforms where this could be a problem. For the CAMLprim change, AppVeyor seems to be failing - I haven't looked in detail, but is this change appropriate for Windows/Cygwin given FlexDLL? |
CAMLprim and CAMLexport currently expand to nothing, but it can be made to export the associated declaration even when -fvisibility=hidden is used.
CAMLnoreturn_end expands to an __attribute__ annotation when a GNU-compatible compiler is in use, and nothing otherwise. But attributes can also go before a declaration, where CAMLnoreturn_start is placed. Therefore, moving the __attribute__ to before the declaration allows eliminating CAMLnoreturn_end on all platforms.
c529eef to
bafd5b6
Compare
This allows writing OCaml primitives in C++ without having to manually place extern "C" around them.
|
The Windows build is still broken. Thanks for splitting the original commit, although with the extra one you have added, this now feels like 3 pull requests merged into one. What happens with the change for C++ for C++ which have already manually annotated |
|
Concerning |
|
Concerning Windows support, I'm still concerned that the |
|
dllexport instructs the linker to put the symbol in the export table when generating the PE image (.exe/.dll). I think this is equivalent to creating a .def file which collects all marked symbols. FlexDLL does not rely on the visibility of symbols in the PE format and implements its own dynamic linker and export/import tables. In particular, it does not honor the dllexport export (but should happily forward it to the underlying linker). Currently, all public symbols in the DLL will end up in the FlexDLL export table. So as far as I can tell, the change does not "fix" anything and will only export more symbols in the generated images (at the PE level). At least for CAMLprim, the attribute seems useless. For CAMLexport, I don't know. One could argue that if the final image (linked in a DLL) is intended to be used by non-OCaml code, the attribute could be used to explicitly tell the linker to make the symbol accessible from outside the OCaml world. Is that the intended usage of CAMLexport? |
|
If I remember correctly the |
|
Once more, I think there are good ideas in there but they need to be developed and discussed more. Either we do this or we close this PR. |
|
Quoting the last message in 2017:
The discussion has not happened, so closing. @DemiMarie, feel free to actually discuss things if you still want to, we can reopen if relevant. |
Co-authored-by: Cuihtlauac ALVARADO <cuihtmlauac@tarides.com> Co-authored-by: Thibaut Mattio <thibaut.mattio@gmail.com>
CAMLprim and CAMLexport currently expand to nothing, but it can be
made to export the associated declaration even when
-fvisibility=hidden is used.
Also, eliminate the need for CAMLnoreturn_end by moving its
expansion to that of CAMLnoreturn_start.