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

RangeError: Maximum call stack size exceeded with custom compile #14

Open
leongrdic opened this issue Jun 17, 2022 · 0 comments
Open

RangeError: Maximum call stack size exceeded with custom compile #14

leongrdic opened this issue Jun 17, 2022 · 0 comments

Comments

@leongrdic
Copy link

leongrdic commented Jun 17, 2022

hello, first of all, I'm sorry because this may not be an actual issue and it's kinda offtopic.

I've been trying to compile PHP 8.1 for WASM for a few weeks now and haven't had much luck. I recently came across this repo and noticed you managed to do it.

I've cloned your repo locally and tried to do the compile myself, and when I try to run code in the demo app it works but fails for more complex code snippets (like including the phan phar or its autoload.php, or a deeply recursive function) - those same code snippets work when I just download your compiled php.wasm, php.data and php.js from https://phan.github.io/demo/ and load them locally or even in the online demo app.
The error I'm getting when trying to run the complex code (sometimes in the output section in page and sometimes in console):

Unexpected error reloading php: RangeError: Maximum call stack size exceeded

I then proceeded to modify the build.sh - get rid of most extensions and change the compile flags in attempts to get it to work but with no success and I've done over a hundred different compiles at this point.

If anyone's interested to help me out, here are the important parts of my build.sh:

export CFLAGS='-O1 -DZEND_MM_ERROR=0'
./buildconf --force
emconfigure ./configure \
  --with-layout=GNU \
  --enable-embed=static \
  --disable-all \
  --disable-cgi \
  --disable-cli \
  --disable-rpath \
  --disable-phpdbg \
  --without-pear \
  --without-pcre-jit \
  --without-valgrind \
  --with-valgrind=no \
  --disable-fiber-asm \
  --enable-phar

emmake make clean
emmake make -j5
emcc $CFLAGS -I . -I Zend -I main -I TSRM/ ../pib_eval.c -c -o pib_eval.o
emcc $CFLAGS \
  --llvm-lto 2 \
  -s ENVIRONMENT=web \
  -s EXPORTED_FUNCTIONS='["_pib_eval", "_php_embed_init", "_zend_eval_string", "_php_embed_shutdown"]' \
  -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall"]' \
  -s MODULARIZE=1 \
  -s EXPORT_NAME="'PHP'" \
  -s TOTAL_MEMORY=134217728 \
  -s INVOKE_RUN=0 \
  -s ERROR_ON_UNDEFINED_SYMBOLS=0 \
  -s ASSERTIONS=1 \
  -s TOTAL_STACK=10485760 \
  --preload-file some.phar \
  libs/libphp.a pib_eval.o -o out/php.js

I'm running Emscripten SDK version 1.39.18 with the following command:

docker run --rm -v $(pwd):/src trzeci/emscripten /bin/bash -c "apt-get update ; apt-get install -y autoconf ; ./build.sh"

thanks very much in advance to anyone who's willing to help regarding this.

@leongrdic leongrdic changed the title PHP execution issue with custom compile RangeError: Maximum call stack size exceeded with custom compile Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant