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

[Explore] Compile PHP to WASI so it can run without JS #113

Closed
wants to merge 1 commit into from

Conversation

adamziel
Copy link
Collaborator

This PR explores using the wasmenv toolkit to compile PHP. The configure phase works, but the make fails because setjmp is unsupported yet, see the error message below and the relevant GitHub issue at WebAssembly/WASI#490

There's a chance "make" would work if we tried a dedicated libc build:

https://github.com/WebAssembly/wasi-libc/blob/main/libc-top-half/musl/include/setjmp.h

I'm not sure if the final PHP build would be functional, though.

Either way, building using wasi-sdk which has libc and set_jmp.h baked in would be a sensible next step:

https://github.com/WebAssembly/wasi-sdk/releases

31 69.49 /root/php-src/main/setjmp.h:44:2: warning: setjmp is not yet implemented for WASI [-W#warnings] 31 69.49 #warning setjmp is not yet implemented for WASI 31 69.49  ^
31 69.56 In file included from /root/php-src/ext/bcmath/libbcmath/src/div.c:32: 31 69.56 In file included from /root/php-src/ext/bcmath/libbcmath/src/config.h:7: 31 69.56 In file included from /root/php-src/main/php.h:35: 31 69.56 In file included from /root/php-src/Zend/zend_API.h:25: 31 69.56 In file included from /root/php-src/Zend/zend_modules.h:24: 31 69.56 In file included from /root/php-src/Zend/zend_compile.h:724: 31 69.56 /root/php-src/Zend/zend_globals.h:151:2: error: unknown type name 'jmp_buf'
31 69.56         JMP_BUF *bailout;
31 69.56         ^
31 69.56 /root/php-src/Zend/zend_portability.h:361:18: note: expanded from macro 'JMP_BUF'
31 69.56 # define JMP_BUF jmp_buf

This commit explores using the wasmenv toolkit to compile PHP.
The configure phase works, but the make fails because setjmp is
unsupported yet, see the error message below and the relevant
GitHub issue at WebAssembly/WASI#490

There's a chance "make" would work if we tried a dedicated libc build:

   https://github.com/WebAssembly/wasi-libc/blob/main/libc-top-half/musl/include/setjmp.h

I'm not sure if the final PHP build would be functional, though.

Either way, building using wasi-sdk which has libc and set_jmp.h baked
in would be a sensible next step:

https://github.com/WebAssembly/wasi-sdk/releases

31 69.49 /root/php-src/main/setjmp.h:44:2: warning: setjmp is not yet implemented for WASI [-W#warnings]
31 69.49 #warning setjmp is not yet implemented for WASI
31 69.49  ^
31 69.56 In file included from /root/php-src/ext/bcmath/libbcmath/src/div.c:32:
31 69.56 In file included from /root/php-src/ext/bcmath/libbcmath/src/config.h:7:
31 69.56 In file included from /root/php-src/main/php.h:35:
31 69.56 In file included from /root/php-src/Zend/zend_API.h:25:
31 69.56 In file included from /root/php-src/Zend/zend_modules.h:24:
31 69.56 In file included from /root/php-src/Zend/zend_compile.h:724:
31 69.56 /root/php-src/Zend/zend_globals.h:151:2: error: unknown type name 'jmp_buf'
31 69.56         JMP_BUF *bailout;
31 69.56         ^
31 69.56 /root/php-src/Zend/zend_portability.h:361:18: note: expanded from macro 'JMP_BUF'
31 69.56 # define JMP_BUF jmp_buf
@adamziel adamziel changed the title Explore compiling PHP to WASI for node.js-less CLI compatibility [Explore] Compile PHP to WASI to run without JS Jan 14, 2023
@adamziel adamziel changed the title [Explore] Compile PHP to WASI to run without JS [Explore] Compile PHP to WASI so it can run without JS Jan 14, 2023
@adamziel
Copy link
Collaborator Author

adamziel commented May 4, 2023

Closing this one. Let's look into collaborating with https://github.com/vmware-labs/webassembly-language-runtimes (see php-8.1.11) once WASI supports longjmp.

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

Successfully merging this pull request may close these issues.

1 participant