-
Notifications
You must be signed in to change notification settings - Fork 15
Build with wasm exception handling #81
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
30cbe32
Build with wasm exception handling
hoodmane a02dda7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3186d20
Fix
hoodmane 8256e72
Fix again
hoodmane 5e46696
Only download rust toolchain once
hoodmane adda8a5
Fix
hoodmane b33d1c9
Always run rustup toolchain link
hoodmane f2d72e7
Add wasm-sjlj suffix to wasm-eh libs
hoodmane 3c3dc79
Update Emscripten toolchain version
hoodmane 30517bd
Merge branch 'main' into rust-wasm-eh
hoodmane 0c88c0f
Merge branch 'main' into rust-wasm-eh
hoodmane 663e78e
Remove duplication of toolchain name
hoodmane 529a583
Pass recipe ldflags through library rewriting logic as well
hoodmane a63c7b9
Add ignore for too many branches lint
hoodmane b50d1c1
Only install Emscripten target from url
hoodmane 3b1734b
Fix syntax error
hoodmane c93aab1
Move target url to config variable
hoodmane 036626d
Set default rust_toolchain to nightly-2025-01-15
hoodmane 7bbdde2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 114e477
Only change pywasmcross behavior for new abi
hoodmane 330e762
Merge branch 'main' into rust-wasm-eh
hoodmane 6a49a51
Merge branch 'main' into rust-wasm-eh
hoodmane 194c463
Don't append None to new_args
hoodmane 6fa5b9b
Merge branch 'main' into rust-wasm-eh
hoodmane 4cb167e
Merge branch 'main' into rust-wasm-eh
hoodmane dc1c6a2
Merge branch 'main' into rust-wasm-eh
hoodmane ba33a1c
Don't adjust flags from recipes
hoodmane 6fe5882
Add comments
hoodmane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,9 @@ class CrossCompileArgs(NamedTuple): | |
target_install_dir: str = "" # The path to the target Python installation | ||
pythoninclude: str = "" # path to the cross-compiled Python include directory | ||
exports: Literal["whole_archive", "requested", "pyinit"] | list[str] = "pyinit" | ||
# Pyodide abi, e.g., 2025_0 | ||
# Sometimes we have to inject compile flags only for certain abis. | ||
abi: str = "" | ||
|
||
|
||
def is_link_cmd(line: list[str]) -> bool: | ||
|
@@ -93,7 +96,7 @@ def is_link_cmd(line: list[str]) -> bool: | |
return False | ||
|
||
|
||
def replay_genargs_handle_dashl(arg: str, used_libs: set[str]) -> str | None: | ||
def replay_genargs_handle_dashl(arg: str, used_libs: set[str], abi: str) -> str | None: | ||
""" | ||
Figure out how to replace a `-lsomelib` argument. | ||
|
||
|
@@ -118,6 +121,13 @@ def replay_genargs_handle_dashl(arg: str, used_libs: set[str]) -> str | None: | |
if arg == "-lgfortran": | ||
return None | ||
|
||
# Some Emscripten libraries that use setjmp/longjmp. | ||
# The Emscripten linker should automatically know to use these variants so | ||
# this shouldn't be necessary. | ||
# This suffix will need to change soon to `-legacysjlj`. | ||
if abi > "2025" and arg in ["-lfreetype", "-lpng"]: | ||
arg += "-wasm-sjlj" | ||
Comment on lines
+128
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a comment about the context of this if condition.
hoodmane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# WASM link doesn't like libraries being included twice | ||
# skip second one | ||
if arg in used_libs: | ||
|
@@ -555,7 +565,7 @@ def handle_command_generate_args( # noqa: C901 | |
continue | ||
|
||
if arg.startswith("-l"): | ||
result = replay_genargs_handle_dashl(arg, used_libs) | ||
result = replay_genargs_handle_dashl(arg, used_libs, build_args.abi) | ||
elif arg.startswith("-I"): | ||
result = replay_genargs_handle_dashI(arg, build_args.target_install_dir) | ||
elif arg.startswith("-Wl"): | ||
|
@@ -638,6 +648,7 @@ def compiler_main(): | |
target_install_dir=PYWASMCROSS_ARGS["target_install_dir"], | ||
pythoninclude=PYWASMCROSS_ARGS["pythoninclude"], | ||
exports=PYWASMCROSS_ARGS["exports"], | ||
abi=PYWASMCROSS_ARGS["abi"], | ||
) | ||
basename = Path(sys.argv[0]).name | ||
args = list(sys.argv) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.