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

Build with wasm exception handling #81

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
30cbe32
Build with wasm exception handling
hoodmane Jan 13, 2025
a02dda7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 13, 2025
3186d20
Fix
hoodmane Jan 13, 2025
8256e72
Fix again
hoodmane Jan 13, 2025
5e46696
Only download rust toolchain once
hoodmane Jan 13, 2025
adda8a5
Fix
hoodmane Jan 13, 2025
b33d1c9
Always run rustup toolchain link
hoodmane Jan 14, 2025
f2d72e7
Add wasm-sjlj suffix to wasm-eh libs
hoodmane Jan 14, 2025
3c3dc79
Update Emscripten toolchain version
hoodmane Jan 14, 2025
30517bd
Merge branch 'main' into rust-wasm-eh
hoodmane Jan 15, 2025
0c88c0f
Merge branch 'main' into rust-wasm-eh
hoodmane Jan 15, 2025
663e78e
Remove duplication of toolchain name
hoodmane Jan 15, 2025
529a583
Pass recipe ldflags through library rewriting logic as well
hoodmane Jan 15, 2025
a63c7b9
Add ignore for too many branches lint
hoodmane Jan 15, 2025
b50d1c1
Only install Emscripten target from url
hoodmane Jan 15, 2025
3b1734b
Fix syntax error
hoodmane Jan 15, 2025
c93aab1
Move target url to config variable
hoodmane Jan 15, 2025
036626d
Set default rust_toolchain to nightly-2025-01-15
hoodmane Jan 15, 2025
7bbdde2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 15, 2025
114e477
Only change pywasmcross behavior for new abi
hoodmane Jan 15, 2025
330e762
Merge branch 'main' into rust-wasm-eh
hoodmane Jan 27, 2025
6a49a51
Merge branch 'main' into rust-wasm-eh
hoodmane Jan 30, 2025
194c463
Don't append None to new_args
hoodmane Jan 31, 2025
6fa5b9b
Merge branch 'main' into rust-wasm-eh
hoodmane Feb 23, 2025
4cb167e
Merge branch 'main' into rust-wasm-eh
hoodmane Feb 24, 2025
dc1c6a2
Merge branch 'main' into rust-wasm-eh
hoodmane Feb 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions pyodide_build/buildall.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
from rich.table import Table

from pyodide_build import build_env, recipe
from pyodide_build.build_env import BuildArgs
from pyodide_build.build_env import BuildArgs, get_pyodide_root
from pyodide_build.buildpkg import needs_rebuild
from pyodide_build.common import (
download_and_unpack_archive,
exit_with_stdio,
extract_wheel_metadata_file,
find_matching_wheels,
Expand Down Expand Up @@ -649,22 +650,18 @@ def run(self, n_jobs: int, already_built: set[str]) -> None:


def _ensure_rust_toolchain():
rust_toolchain = build_env.get_build_flag("RUST_TOOLCHAIN")
toolchain_version = build_env.get_build_flag("RUST_TOOLCHAIN")
pyodide_root = get_pyodide_root()
toolchain_path = pyodide_root / ".rust-toolchain" / toolchain_version
if not toolchain_path.exists():
download_and_unpack_archive(
f"http://pyodide-cache.s3-website-us-east-1.amazonaws.com/rustc/{toolchain_version}.tar.bz2",
toolchain_path.parent,
"rust toolchain",
)
result = subprocess.run(
["rustup", "toolchain", "install", rust_toolchain], check=False
["rustup", "toolchain", "link", toolchain_version, toolchain_path], check=False
)
if result.returncode == 0:
result = subprocess.run(
[
"rustup",
"target",
"add",
"wasm32-unknown-emscripten",
"--toolchain",
rust_toolchain,
],
check=False,
)
if result.returncode != 0:
logger.error("ERROR: rustup toolchain install failed")
exit_with_stdio(result)
Expand Down
2 changes: 1 addition & 1 deletion pyodide_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def to_env(self) -> dict[str, str]:
"rustflags": "-C link-arg=-sSIDE_MODULE=2 -C link-arg=-sWASM_BIGINT -Z link-native-libraries=no",
"cargo_build_target": "wasm32-unknown-emscripten",
"cargo_target_wasm32_unknown_emscripten_linker": "emcc",
"rust_toolchain": "nightly-2024-01-29",
"rust_toolchain": "emscripten_2025-01-13_724fd8dedf1",
# Other configuration
"pyodide_jobs": "1",
"skip_emscripten_version_check": "0",
Expand Down
8 changes: 7 additions & 1 deletion pyodide_build/pywasmcross.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def replay_genargs_handle_dashl(arg: str, used_libs: set[str]) -> str | None:
if arg == "-lgfortran":
return None

if arg in ["-lfreetype", "-lpng"]:
arg += "-wasm-sjlj"

# WASM link doesn't like libraries being included twice
# skip second one
if arg in used_libs:
Expand Down Expand Up @@ -578,7 +581,10 @@ def handle_command_generate_args( # noqa: C901
# Better to fail at compile or link time.
if is_link_cmd(line):
new_args.append("-Wl,--fatal-warnings")
new_args.extend(build_args.ldflags.split())
for arg in build_args.ldflags.split():
if arg.startswith("-l"):
arg = replay_genargs_handle_dashl(arg, used_libs)
new_args.append(arg)
new_args.extend(get_export_flags(line, build_args.exports))

if "-c" in line:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ lint.select = [

lint.logger-objects = ["pyodide_build.logger.logger"]

lint.ignore = ["E402", "E501", "E731", "E741", "PERF401", "PLW2901", "UP038"]
lint.ignore = ["E402", "E501", "E731", "E741", "PERF401", "PLW2901", "UP038", "PLR0912"]
# line-length = 219 # E501: Recommended goal is 88 to match black
target-version = "py312"

Expand Down
Loading