Skip to content

Commit ec87ea4

Browse files
committed
GH-160135: Make sure the target triple makes it through configure
1 parent 0e35313 commit ec87ea4

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

‎Lib/test/test_io/test_fileio.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,15 @@ def testAbles(self):
565565
self.assertEqual(f.writable(), True)
566566
if sys.platform != "darwin" and \
567567
'bsd' not in sys.platform and \
568-
not sys.platform.startswith(('sunos', 'aix')):
569-
# Somehow /dev/tty appears seekable on some BSDs
568+
not sys.platform.startswith(('sunos', 'aix')) and \
569+
not is_wasi:
570+
# Somehow /dev/tty appears seekable on some BSDs and
571+
# WASI.
570572
self.assertEqual(f.seekable(), False)
571-
self.assertEqual(f.isatty(), True)
573+
if not is_wasi:
574+
# wasi-libc special-cases stdin to be a TTY, but
575+
# nothing else is supported.
576+
self.assertEqual(f.isatty(), True)
572577
f.close()
573578
finally:
574579
os.unlink(TESTFN)

‎Platforms/WASI/_build.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ def wasi_sdk_env(context):
181181
for env_var, binary_name in list(env.items()):
182182
env[env_var] = os.fsdecode(wasi_sdk_path / "bin" / binary_name)
183183

184-
if not wasi_sdk_path.name.startswith("wasi-sdk"):
185-
for compiler in ["CC", "CPP", "CXX"]:
184+
for compiler in ["CC", "CPP", "CXX"]:
185+
env[compiler] += f" --target={context.host_triple}"
186+
if not wasi_sdk_path.name.startswith("wasi-sdk"):
186187
env[compiler] += f" --sysroot={sysroot}"
187188

188189
env["PKG_CONFIG_PATH"] = ""
@@ -229,7 +230,11 @@ def configure_wasi_python(context, working_dir):
229230
"https://github.com/bytecodealliance/wasmtime"
230231
)
231232
host_runner = context.host_runner.format_map(args)
232-
env_additions = {"CONFIG_SITE": config_site, "HOSTRUNNER": host_runner}
233+
env_additions = {
234+
"CONFIG_SITE": config_site,
235+
"HOSTRUNNER": host_runner,
236+
"CFLAGS": f"{os.environ.get('CFLAGS', '')} -DPY_CALL_TRAMPOLINE".strip(),
237+
}
233238
build_python = os.fsdecode(context.build_python_interpreter)
234239
# The path to `configure` MUST be relative, else `python.wasm` is unable
235240
# to find the stdlib due to Python not recognizing that it's being
@@ -239,7 +244,6 @@ def configure_wasi_python(context, working_dir):
239244
f"--host={context.host_triple}",
240245
f"--build={context.build_python_path.name}",
241246
f"--with-build-python={build_python}",
242-
"CFLAGS=-DPY_CALL_TRAMPOLINE",
243247
]
244248
if context.is_debug:
245249
configure.append("--with-pydebug")

0 commit comments

Comments
 (0)