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

Emscripten: Make the web example work again #127111

Closed
hoodmane opened this issue Nov 21, 2024 · 1 comment · Fixed by #127506
Closed

Emscripten: Make the web example work again #127111

hoodmane opened this issue Nov 21, 2024 · 1 comment · Fixed by #127506
Labels
build The build process and cross-build OS-emscripten

Comments

@hoodmane
Copy link
Contributor

hoodmane commented Nov 21, 2024

My recent changes to the Emscripten build broke the web example. I'll fix it and also move all of the components of the web example into a subfolder under Tools/wasm/emscripten.

Linked PRs

hoodmane added a commit to hoodmane/cpython that referenced this issue Nov 21, 2024
I moved the web example from `Tools/wasm` into `Tools/wasm/emscripten/web_example`.
I also added a new target `build_emscripten` which is `build_wasm` but also
builds the web_example. The web_example needs:
1. python.html, copied
2. python.worker.mjs copied
3. python.mjs and python.wasm output from the main linking of the Python interpreter
4. The webserver that sets COOP and COEP
5. python3.14.zip

This last is created by the `wasm_assets.py` script, which required a pretty
small set of changes to work fine for us.

The last thing that should be done is the `python.worker.mjs` script should be
made independent of the Python version: currently 3.14 is hard coded. I ran
into trouble doing this, so maybe I can leave it to a followup.
@hoodmane hoodmane added OS-emscripten build The build process and cross-build labels Nov 21, 2024
hoodmane added a commit to hoodmane/cpython that referenced this issue Nov 21, 2024
I moved the web example from `Tools/wasm` into `Tools/wasm/emscripten/web_example`.
I also added a new target `build_emscripten` which is `build_wasm` but also
builds the web_example. The web_example needs:
1. python.html, copied
2. python.worker.mjs copied
3. python.mjs and python.wasm output from the main linking of the Python interpreter
4. The webserver that sets COOP and COEP
5. python3.14.zip

This last is created by the `wasm_assets.py` script, which required a pretty
small set of changes to work fine for us.

The last thing that should be done is the `python.worker.mjs` script should be
made independent of the Python version: currently 3.14 is hard coded. I ran
into trouble doing this, so maybe I can leave it to a followup.
hoodmane added a commit to hoodmane/cpython that referenced this issue Nov 22, 2024
I moved the web example from `Tools/wasm` into `Tools/wasm/emscripten/web_example`.
I also added a new target `build_emscripten` which is `build_wasm` but also
builds the web_example. The web_example needs:
1. python.html, copied
2. python.worker.mjs copied
3. python.mjs and python.wasm output from the main linking of the Python interpreter
4. The webserver that sets COOP and COEP
5. python3.14.zip

This last is created by the `wasm_assets.py` script, which required a pretty
small set of changes to work fine for us.

The last thing that should be done is the `python.worker.mjs` script should be
made independent of the Python version: currently 3.14 is hard coded. I ran
into trouble doing this, so maybe I can leave it to a followup.
hoodmane added a commit to hoodmane/cpython that referenced this issue Nov 22, 2024
I moved the web example from `Tools/wasm` into `Tools/wasm/emscripten/web_example`.
I also added a new target `build_emscripten` which is `build_wasm` but also
builds the web_example. The web_example needs:
1. python.html, copied
2. python.worker.mjs copied
3. python.mjs and python.wasm output from the main linking of the Python interpreter
4. The webserver that sets COOP and COEP
5. python3.14.zip

This last is created by the `wasm_assets.py` script, which required a pretty
small set of changes to work fine for us.

The last thing that should be done is the `python.worker.mjs` script should be
made independent of the Python version: currently 3.14 is hard coded. I ran
into trouble doing this, so maybe I can leave it to a followup.
freakboy3742 pushed a commit that referenced this issue Dec 2, 2024
Moves the Emscripten web example into a standalone folder, and updates 
Makefile targets to build the web example. Instructions for usage have
also been added.
@freakboy3742
Copy link
Contributor

This also requires the changes to the CLI script from #127506 before it can be closed.

hoodmane added a commit to hoodmane/cpython that referenced this issue Dec 3, 2024
Fixed one spot where there was invalid html (script tag closed twice). Other
than that, this gives consistent usage of semicolons, quotes, indentation, etc.
Separated out into its own commit for ease of review.
freakboy3742 pushed a commit that referenced this issue Dec 5, 2024
Cleaned up formatting (and a stray closing tag) of the web example HTML and JS.
hoodmane added a commit to hoodmane/cpython that referenced this issue Dec 6, 2024
…RED`

The `-sEXPORTED_FUNCTIONS` setting will break when linking a shared library
because the library doesn't `main` or `Py_Version` symbols. Only that one
_needs_ to be moved, but most of these other flags are ignored when
linking a shared library so it's better not to pass them. The only one that
needs to be passed when linking shared libraries is `-sWASM_BIGINT` which
changes the ABI.
@hoodmane hoodmane reopened this Dec 6, 2024
freakboy3742 pushed a commit that referenced this issue Dec 9, 2024
…ORSHARED` (#127666)

Corrects the usage of linking flags to avoid compilation errors related to the
use of `-sEXPORTED_FUNCTIONS` when linking shared libraries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build OS-emscripten
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants