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

Insert -Zbuild-std when building rust packages #40

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions pyodide_build/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
RUST_BUILD_PRELUDE = """
rustup toolchain install ${RUST_TOOLCHAIN} && rustup default ${RUST_TOOLCHAIN}
rustup target add wasm32-unknown-emscripten --toolchain ${RUST_TOOLCHAIN}
rustup component add rust-src --toolchain ${RUST_TOOLCHAIN}
"""


Expand Down
3 changes: 3 additions & 0 deletions pyodide_build/pywasmcross.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ def handle_command_generate_args( # noqa: C901
elif cmd == "strip":
line[0] = "emstrip"
return line
elif cmd == "cargo":
line.insert(1, "-Zbuild-std")
return line
Comment on lines +528 to +530
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test for this (test_pywasmcross.py)

else:
return line

Expand Down
8 changes: 8 additions & 0 deletions pyodide_build/tests/test_pywasmcross.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,11 @@ def test_is_link_cmd():
assert is_link_cmd(["test.so"])
assert is_link_cmd(["test.so.1.2.3"])
assert not is_link_cmd(["test", "test.a", "test.o", "test.c", "test.cpp", "test.h"])


def test_handle_command_cargo(build_args):
assert handle_command_generate_args(["cargo", "build"], build_args) == [
"cargo",
"-Zbuild-std",
"build",
]
Loading