diff --git a/Misc/NEWS.d/next/Tools-Demos/2025-07-30-10-28-35.gh-issue-137243.NkdUqH.rst b/Misc/NEWS.d/next/Tools-Demos/2025-07-30-10-28-35.gh-issue-137243.NkdUqH.rst new file mode 100644 index 00000000000000..c9c6c2ca287efd --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2025-07-30-10-28-35.gh-issue-137243.NkdUqH.rst @@ -0,0 +1,2 @@ +Have Tools/wasm/wasi detect a WASI SDK install in /opt when it was directly +extracted from a release tarball. diff --git a/Tools/wasm/wasi/__main__.py b/Tools/wasm/wasi/__main__.py index 54ccc95157d57d..dd3f7fa82272c7 100644 --- a/Tools/wasm/wasi/__main__.py +++ b/Tools/wasm/wasi/__main__.py @@ -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}}}" @@ -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 @@ -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. @@ -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() 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