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

it should be possible to load native extensions from an object file at runtime #206

Open
mikedanese opened this issue Jun 9, 2016 · 5 comments

Comments

@mikedanese
Copy link
Contributor

Similart to --jpath, we need an --npath that is search for symbols that match a convention, then dlopen and register them as native extensions. Lua supports a similar feature.

https://www.lua.org/pil/8.2.html

@mikedanese
Copy link
Contributor Author

Use casese:

  • I want to maintain a yaml import function out of tree
  • I want to maintain a regexp library out of tree

@sparkprime
Copy link
Contributor

So you're suggesting that the commandline executable would do this so you don't have to write a frontend yourself (in the style of jsonnet_test_snippet)?

@sparkprime
Copy link
Contributor

Is there any way to do this portably? What if the user had to give the dynamic library using a commandline param and then it was assumed to implement a particular ABI?

@mikedanese
Copy link
Contributor Author

mikedanese commented Jun 24, 2016

Is there any way to do this portably?

There are various degrees of support. We should be able to rig something up on linux and mac. Here's where luajit does it for unixy systems:

https://github.com/LuaJIT/LuaJIT/blob/db1b399af134e715b8ba9a0e4ad9cbafbe06ecb1/src/lib_package.c#L58-L66

That function is only defined three times in that file :)

So you're suggesting that the commandline executable would do this so you don't have to write a frontend yourself (in the style of jsonnet_test_snippet)?

Yes, this would be a feature of the jsonnet cli tool that would allow for some basic not-compiled-in extensions. It would server the "import" functionality for native functions.

@sparkprime
Copy link
Contributor

dlopen and dlsym are standard but they don't let you search for files or search through files. However if the user gave the filename and we assumed a particular function name (that set up all the callbacks) then it could work.

sbarzowski pushed a commit to sbarzowski/jsonnet that referenced this issue Jun 10, 2024
* Make some filenames Windows-friendly

* Update references to renamed files

* Fix escaped filenames to run on non-Windows platforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants