Skip to content

[3.14] GH-137243: Have Tools/wasm/wasi detect WASI SDK installs in /opt when the release tarball is extracted (GH-137244) #137250

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

Open
wants to merge 1 commit into
base: 3.14
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Have Tools/wasm/wasi detect a WASI SDK install in /opt when it was directly
extracted from a release tarball.
36 changes: 26 additions & 10 deletions Tools/wasm/wasi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/wasi.py\n".encode("utf-8")

WASI_SDK_VERSION = 24

WASMTIME_VAR_NAME = "WASMTIME"
WASMTIME_HOST_RUNNER_VAR = f"{{{WASMTIME_VAR_NAME}}}"

Expand Down Expand Up @@ -169,10 +171,22 @@ def make_build_python(context, working_dir):


def find_wasi_sdk():
"""Find the path to wasi-sdk."""
"""Find the path to the WASI SDK."""
if wasi_sdk_path := os.environ.get("WASI_SDK_PATH"):
return pathlib.Path(wasi_sdk_path)
elif (default_path := pathlib.Path("/opt/wasi-sdk")).exists():

opt_path = pathlib.Path("/opt")
# WASI SDK versions have a ``.0`` suffix, but it's a constant; the WASI SDK team
# has said they don't plan to ever do a point release and all of their Git tags
# lack the ``.0`` suffix.
# Starting with WASI SDK 23, the tarballs went from containing a directory named
# ``wasi-sdk-{WASI_SDK_VERSION}.0`` to e.g.
# ``wasi-sdk-{WASI_SDK_VERSION}.0-x86_64-linux``.
potential_sdks = [path for path in opt_path.glob(f"wasi-sdk-{WASI_SDK_VERSION}.0*")
if path.is_dir()]
if len(potential_sdks) == 1:
return potential_sdks[0]
elif (default_path := opt_path / "wasi-sdk").is_dir():
return default_path


Expand Down Expand Up @@ -303,6 +317,8 @@ def clean_contents(context):


def main():
default_host_triple = "wasm32-wasip1"
default_wasi_sdk = find_wasi_sdk()
default_host_runner = (f"{WASMTIME_HOST_RUNNER_VAR} run "
# Make sure the stack size will work for a pydebug
# build.
Expand Down Expand Up @@ -346,17 +362,17 @@ def main():
for subcommand in build, configure_host:
subcommand.add_argument("--wasi-sdk", type=pathlib.Path,
dest="wasi_sdk_path",
default=find_wasi_sdk(),
help="Path to wasi-sdk; defaults to "
"$WASI_SDK_PATH or /opt/wasi-sdk")
default=default_wasi_sdk,
help=f"Path to the WASI SDK; defaults to {default_wasi_sdk}")
subcommand.add_argument("--host-runner", action="store",
default=default_host_runner, dest="host_runner",
help="Command template for running the WASI host "
"(default designed for wasmtime 14 or newer: "
f"`{default_host_runner}`)")
help="Command template for running the WASI host; defaults to "
f"`{default_host_runner}`")
for subcommand in build, configure_host, make_host:
subcommand.add_argument("--host-triple", action="store", default="wasm32-wasip1",
help="The target triple for the WASI host build")
subcommand.add_argument("--host-triple", action="store",
default=default_host_triple,
help="The target triple for the WASI host build; "
f"defaults to {default_host_triple}")

context = parser.parse_args()
context.init_dir = pathlib.Path().absolute()
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy