From ec87ea4ce045b3ad0de3273bd9098d67fee33d31 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Mon, 26 Oct 2026 17:30:47 -0700 Subject: [PATCH] GH-160135: Make sure the target triple makes it through `configure` --- Lib/test/test_io/test_fileio.py | 11 ++++++++--- Platforms/WASI/_build.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_io/test_fileio.py b/Lib/test/test_io/test_fileio.py index 21a160904a7f1e..b89a381439bade 100644 --- a/Lib/test/test_io/test_fileio.py +++ b/Lib/test/test_io/test_fileio.py @@ -565,10 +565,15 @@ def testAbles(self): self.assertEqual(f.writable(), True) if sys.platform != "darwin" and \ 'bsd' not in sys.platform and \ - not sys.platform.startswith(('sunos', 'aix')): - # Somehow /dev/tty appears seekable on some BSDs + not sys.platform.startswith(('sunos', 'aix')) and \ + not is_wasi: + # Somehow /dev/tty appears seekable on some BSDs and + # WASI. self.assertEqual(f.seekable(), False) - self.assertEqual(f.isatty(), True) + if not is_wasi: + # wasi-libc special-cases stdin to be a TTY, but + # nothing else is supported. + self.assertEqual(f.isatty(), True) f.close() finally: os.unlink(TESTFN) diff --git a/Platforms/WASI/_build.py b/Platforms/WASI/_build.py index 87b42ea6283951..9ea92a58ef5bb3 100644 --- a/Platforms/WASI/_build.py +++ b/Platforms/WASI/_build.py @@ -181,8 +181,9 @@ def wasi_sdk_env(context): for env_var, binary_name in list(env.items()): env[env_var] = os.fsdecode(wasi_sdk_path / "bin" / binary_name) - if not wasi_sdk_path.name.startswith("wasi-sdk"): - for compiler in ["CC", "CPP", "CXX"]: + for compiler in ["CC", "CPP", "CXX"]: + env[compiler] += f" --target={context.host_triple}" + if not wasi_sdk_path.name.startswith("wasi-sdk"): env[compiler] += f" --sysroot={sysroot}" env["PKG_CONFIG_PATH"] = "" @@ -229,7 +230,11 @@ def configure_wasi_python(context, working_dir): "https://github.com/bytecodealliance/wasmtime" ) host_runner = context.host_runner.format_map(args) - env_additions = {"CONFIG_SITE": config_site, "HOSTRUNNER": host_runner} + env_additions = { + "CONFIG_SITE": config_site, + "HOSTRUNNER": host_runner, + "CFLAGS": f"{os.environ.get('CFLAGS', '')} -DPY_CALL_TRAMPOLINE".strip(), + } build_python = os.fsdecode(context.build_python_interpreter) # The path to `configure` MUST be relative, else `python.wasm` is unable # to find the stdlib due to Python not recognizing that it's being @@ -239,7 +244,6 @@ def configure_wasi_python(context, working_dir): f"--host={context.host_triple}", f"--build={context.build_python_path.name}", f"--with-build-python={build_python}", - "CFLAGS=-DPY_CALL_TRAMPOLINE", ] if context.is_debug: configure.append("--with-pydebug")