Open kaineer opened 5 years ago
Sorry, I don't have much time to investigate loading a extension dynamically from network or filesystem. Currently the only tested way to use php extension is to static link it into the binary.
Static linking would be ok. But is it possible for php extensions? Where can I read about it?
A simple extension demo is add: https://github.com/oraoto/pib/commit/a5f47e70c5a950d6c5a3823d22cc9bf81403d8a8
Explanation:
Symbolic link (or copy) the extension source into php's ext folder
ln -rsfv ext-example $PHP_PATH/ext
Run buildconf --force
to re-generate configs
# Install
apt-get update
apt-get install -y autoconf
./buildconf --force
Enable the extension in configure
emconfigure ./configure --
--disable-all \
--disable-cgi \
--disable-cli \
--disable-rpath \
--disable-phpdbg \
--with-valgrind=no \
--without-pear \
--without-pcre-jit \
--with-layout=GNU \
--enable-embed=static \
--enable-bcmath \
--enable-json \
--enable-ctype \
--enable-mbstring \
--disable-mbregex \
--enable-tokenizer \
--enable-example
Build it as usual. For the latest emscripten, this step fails.
Great :) Thank you. I'll try this.
Updated emscripten to 1.38.31 and got bunch of errors like:
error: asm2wasm seeing an invalid argument type at index 1 (this will not validate) in call from $__php_s
tream_fopen_from_fd to $_lseek (this is likely due to undefined behavior in C, like defining a function $
ne way and calling it in another, which is important to fix)
Did you use 1.38.31 version, or some more later one?
After switching to php-7.3.0, both functions from example
extension became available, yay :)
Thanks again :)
I build the example using docker image trzeci/emscripten:sdk-incoming-64bit
.
Oh, now I see. Fortunately, emacsen 1.38.31 was enough for me.
Good. First part of my problem is solved :)
But, there's second one :-/ I need to call Javascript function from my extension.
Samples that I've found use something like extern functionName();
notation and then just call that function. It seems like in php-extension I should use something else.
Didn't find anything useful in google, though. Perhaps, I don't know what to search for.
You can call javascript functions using emacripten's emscripten_run_script.
@kaineer I did it when I created vrzno. If you're still interested let me know.
Usual way to use extension with php is to copy compiled extension into
extension_dir
and then addingextension=ext-name.o
tophp.ini
.Is there any way to include some custom extension into pib bundle?
I'm just started to learn something about emacsen, so I yet can't figure solution by myself.