From 4ad4aa29fdd9e23ff4caec8f027e92024f39d8d5 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Tue, 13 Aug 2024 19:10:56 -0700 Subject: [PATCH 1/3] Allow specifying the host'r target triple --- Tools/wasm/wasi.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Tools/wasm/wasi.py b/Tools/wasm/wasi.py index a14f58bdac0cb2..050e3723feb247 100644 --- a/Tools/wasm/wasi.py +++ b/Tools/wasm/wasi.py @@ -20,8 +20,6 @@ CROSS_BUILD_DIR = CHECKOUT / "cross-build" BUILD_DIR = CROSS_BUILD_DIR / "build" -HOST_TRIPLE = "wasm32-wasi" -HOST_DIR = CROSS_BUILD_DIR / HOST_TRIPLE LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local" LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/wasi.py\n".encode("utf-8") @@ -63,12 +61,17 @@ def subdir(working_dir, *, clean_ok=False): def decorator(func): @functools.wraps(func) def wrapper(context): + nonlocal working_dir + + if callable(working_dir): + working_dir = working_dir(context) try: tput_output = subprocess.check_output(["tput", "cols"], encoding="utf-8") - terminal_width = int(tput_output.strip()) except subprocess.CalledProcessError: terminal_width = 80 + else: + terminal_width = int(tput_output.strip()) print("⎯" * terminal_width) print("📁", working_dir) if (clean_ok and getattr(context, "clean", False) and @@ -193,7 +196,7 @@ def wasi_sdk_env(context): return env -@subdir(HOST_DIR, clean_ok=True) +@subdir(lambda context: CROSS_BUILD_DIR / context.host_triple, clean_ok=True) def configure_wasi_python(context, working_dir): """Configure the WASI/host build.""" if not context.wasi_sdk_path or not context.wasi_sdk_path.exists(): @@ -238,7 +241,7 @@ def configure_wasi_python(context, working_dir): # to find the stdlib due to Python not recognizing that it's being # executed from within a checkout. configure = [os.path.relpath(CHECKOUT / 'configure', working_dir), - f"--host={HOST_TRIPLE}", + f"--host={context.host_triple}", f"--build={build_platform()}", f"--with-build-python={build_python}"] if pydebug: @@ -258,7 +261,7 @@ def configure_wasi_python(context, working_dir): sys.stdout.flush() -@subdir(HOST_DIR) +@subdir(lambda context: CROSS_BUILD_DIR / context.host_triple) def make_wasi_python(context, working_dir): """Run `make` for the WASI/host build.""" call(["make", "--jobs", str(cpu_count()), "all"], @@ -342,6 +345,9 @@ def main(): help="Command template for running the WASI host " "(default designed for wasmtime 14 or newer: " f"`{default_host_runner}`)") + for subcommand in build, configure_host, make_host: + subcommand.add_argument("--host-triple", action="store", default="wasm32-wasi", + help="The target triple for the WASI host build") context = parser.parse_args() From 2959f15d94d44e48a1efa3bd616c26ad5683a1ee Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Tue, 13 Aug 2024 19:11:13 -0700 Subject: [PATCH 2/3] Allow for `wasm32-wasip2` --- configure | 4 +++- configure.ac | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/configure b/configure index a0fbebcb0442b9..585ad3f2edda72 100755 --- a/configure +++ b/configure @@ -4064,7 +4064,7 @@ then *-*-emscripten) ac_sys_system=Emscripten ;; - *-*-wasi) + *-*-wasi*) ac_sys_system=WASI ;; *) @@ -7064,6 +7064,8 @@ case $host/$ac_cv_cc_name in #( PY_SUPPORT_TIER=2 ;; #( wasm32-unknown-wasi/clang) : PY_SUPPORT_TIER=2 ;; #( + wasm32-unknown-wasip2/clang) : + PY_SUPPORT_TIER=2 ;; #( x86_64-*-linux-gnu/clang) : PY_SUPPORT_TIER=2 ;; #( diff --git a/configure.ac b/configure.ac index 9a17fc279e5a69..b702fb8bc7acfa 100644 --- a/configure.ac +++ b/configure.ac @@ -336,7 +336,7 @@ then *-*-emscripten) ac_sys_system=Emscripten ;; - *-*-wasi) + *-*-wasi*) ac_sys_system=WASI ;; *) @@ -1181,7 +1181,8 @@ AS_CASE([$host/$ac_cv_cc_name], [aarch64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=2], dnl Linux ARM64, glibc, gcc+clang [aarch64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2], [powerpc64le-*-linux-gnu/gcc], [PY_SUPPORT_TIER=2], dnl Linux on PPC64 little endian, glibc, gcc - [wasm32-unknown-wasi/clang], [PY_SUPPORT_TIER=2], dnl WebAssembly System Interface, clang + [wasm32-unknown-wasi/clang], [PY_SUPPORT_TIER=2], dnl WebAssembly System Interface preview1, clang + [wasm32-unknown-wasip2/clang], [PY_SUPPORT_TIER=2], dnl WebAssembly System Interface 0.2, clang [x86_64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2], dnl Linux on AMD64, any vendor, glibc, clang [aarch64-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=3], dnl Windows ARM64, MSVC From 55521f18690ff9b2c39081e3c3049055c41ce09e Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 14 Aug 2024 15:02:59 -0700 Subject: [PATCH 3/3] Add a news entry --- .../next/Build/2024-08-14-15-02-49.gh-issue-121634.VEsP4L.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2024-08-14-15-02-49.gh-issue-121634.VEsP4L.rst diff --git a/Misc/NEWS.d/next/Build/2024-08-14-15-02-49.gh-issue-121634.VEsP4L.rst b/Misc/NEWS.d/next/Build/2024-08-14-15-02-49.gh-issue-121634.VEsP4L.rst new file mode 100644 index 00000000000000..baa4df9741b64b --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-08-14-15-02-49.gh-issue-121634.VEsP4L.rst @@ -0,0 +1 @@ +Add support for wasm32-wasip2 .