rodd has asked for the wisdom of the Perl Monks concerning the following question:
I'm working on binding some JS and Perl code using Bun FFI (https://bun.sh/docs/api/ffi) and perlembed. Things work good, except for XS dynamic loading. Probably due to the way the Bun FFI links to the boot_DynaLoader in my libperl.so, and the general lack of tools and knowledge on my part to circumvent, emulate or recode some of those parts.
So, my question: where or how in core is the libperl boot_DynaLoader C function defined? I just can't find it! I've been to the Perl core code and docs on XS, boot_DynaLoader and ExtUtils::Embed, but to my surprise I can't figure how it works or where its code resides in core (my core is 5.22.1).
Any leads, links or pointers to help me acquire the knowledge of the inner workings of dynamic loading would be of great help.
PD: I didn't want to bore you with my code, but here it is, for context:
const xsInit = new JSCallback( (pTHX) => { Perl.Perl_newXS( perl, pstr('DynaLoader::boot_DynaLoader'), Perl.boot_DynaLoader.ptr, pstr(import.meta.file) ); }, { args: ['ptr'] } ); const rc = Perl.perl_parse(perl, xsInit.ptr, argc, argv, envp);
The above does not dynamic loads XS modules as intended due to the way the FFI library exports symbols, which are meant primarily to be used within the JS realm, not to be sent back to libperl as a callback or (void *)() pointers. I've tried some other workarounds and practices, ie using my own compiled xs_init() function from C and FFI linking to that, but loading is still not working. I probably will be able to solve it at some point, but still, I'd like to understand the inner workings of the core in that regard. I got it working on darwin x86 by accident, but the same workaround fails in linux.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: boot_DynaLoader: what, where, how
by choroba (Cardinal) on Mar 23, 2024 at 16:07 UTC | |
|
Re: boot_DynaLoader: what, where, how
by hv (Prior) on Mar 23, 2024 at 16:48 UTC | |
by cavac (Prior) on Mar 25, 2024 at 12:08 UTC | |
by etj (Priest) on Nov 07, 2024 at 15:31 UTC |