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

creating shared objects with purescript-native-cpp #47

Open
freylax opened this issue Dec 23, 2019 · 1 comment
Open

creating shared objects with purescript-native-cpp #47

freylax opened this issue Dec 23, 2019 · 1 comment
Labels
C++ Applies to the C++11 target enhancement

Comments

@freylax
Copy link

freylax commented Dec 23, 2019

I propose to use extern "C" functions for all exposed functions.This makes it possible to use them in shared libraries and shared object files. This solves two issues which could not be addressed with the current c++ functions:

  • get rid of the dictionary lookup for ffi calls
    if you try to use an ffi function which is not implemented yet you will get an
    error at library or shared object load time, not at runtime of the missing function
  • allow for using plugins in an running application
    this is not quite a repl but it allows live coding in a runnig application. You can edit
    the plugin module, recompile and reload it in the runnig application as shared object.
    Discuss: C++-specific REPL support #27

A runnig example can be found here:
hello world
which is implemented by changed the pscpp
pscpp
and ported the ffi functions for the standard library to the C function interface
ffi
I just used Linux, so no effort was made to make it work on other platforms.
I apreciate your comments and wish you a mery christmas.

@freylax
Copy link
Author

freylax commented Jan 10, 2020

Using zephirs dead code elimination I was able to link in only the modules and ffi's which are truely needed. This allowes for a gradual completion of the ffi's for the shared library and having the gurantee that the neede ffi's which are used by the executable are actually all in there.
https://github.com/freylax/purescript-native-build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ Applies to the C++11 target enhancement
Projects
None yet
Development

No branches or pull requests

2 participants