Skip to content

Commit 72d562a

Browse files
authored
Add a WASI pydebug builder (#456)
1 parent 7ee34b6 commit 72d562a

File tree

3 files changed

+126
-77
lines changed

3 files changed

+126
-77
lines changed

master/custom/builders.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@
4141
MacOSArmWithBrewNoGilRefleakBuild,
4242
WindowsARM64Build,
4343
WindowsARM64ReleaseBuild,
44-
Wasm32EmscriptenNodePThreadsBuild,
45-
Wasm32EmscriptenNodeDLBuild,
46-
Wasm32EmscriptenBrowserBuild,
47-
Wasm32WASIBuild,
44+
Wasm32WasiCrossBuild,
45+
Wasm32WasiDebugBuild,
4846
)
4947

5048
# A builder can be marked as stable when at least the 10 latest builds are
@@ -175,8 +173,9 @@
175173
("ARM64 Windows", "linaro-win-arm64", WindowsARM64Build),
176174
("ARM64 Windows Non-Debug", "linaro-win-arm64", WindowsARM64ReleaseBuild),
177175

178-
# WebAssembly
179-
("wasm32-wasi", "bcannon-wasi", Wasm32WASIBuild),
176+
# WASI
177+
("wasm32-wasi Non-Debug", "bcannon-wasi", Wasm32WasiCrossBuild),
178+
("wasm32-wasi", "bcannon-wasi", Wasm32WasiDebugBuild),
180179
]
181180

182181

@@ -285,7 +284,7 @@
285284
("AMD64 FreeBSD15", "opsec-fbsd15", UnixBuild),
286285

287286
# WebAssembly
288-
("wasm32 WASI 8Core", "kushaldas-wasi", Wasm32WASIBuild),
287+
("wasm32 WASI 8Core", "kushaldas-wasi", Wasm32WasiCrossBuild),
289288
]
290289

291290

@@ -359,7 +358,7 @@ def get_builders(settings):
359358
]
360359

361360
# Match builder name (excluding the branch name) of builders that should only
362-
# run on the master and "custom" branches.
361+
# run on the main and "custom" branches.
363362
ONLY_MAIN_BRANCH = (
364363
"Alpine Linux",
365364
# Cygwin is not supported on 2.7, 3.6, 3.7

master/custom/factories.py

Lines changed: 113 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ class WindowsARM64ReleaseBuild(WindowsARM64Build):
671671
factory_tags = ["win-arm64", "nondebug"]
672672

673673
##############################################################################
674-
############################## WASM BUILDS #################################
674+
############################## WASI BUILDS #################################
675675
##############################################################################
676676

677677

@@ -821,81 +821,28 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
821821
)
822822

823823

824-
class Wasm32EmscriptenBuild(UnixCrossBuild):
825-
"""wasm32-emscripten builder
826-
827-
* Emscripten SDK >= 3.1.12 must be installed
828-
* ccache must be installed
829-
* Emscripten PATHs must be pre-pended to PATH
830-
* ``which node`` must be equal $EMSDK_NODE
831-
"""
832-
factory_tags = ["wasm", "emscripten"]
833-
compile_environ = {
834-
"CONFIG_SITE": "../../Tools/wasm/config.site-wasm32-emscripten",
835-
"EM_COMPILER_WRAPPER": "ccache",
836-
}
837-
838-
host = "wasm32-unknown-emscripten"
839-
host_configure_cmd = ["emconfigure", "../../configure"]
840-
host_make_cmd = ["emmake", "make"]
841-
842-
843-
class Wasm32EmscriptenNodePThreadsBuild(Wasm32EmscriptenBuild):
844-
"""Emscripten with pthreads, testing with NodeJS
845-
"""
846-
buildersuffix = ".emscripten-node-pthreads"
847-
extra_configure_flags = [
848-
# don't run with --with-pydebug, Emscripten has limited stack
849-
"--without-pydebug",
850-
"--with-emscripten-target=node",
851-
"--disable-wasm-dynamic-linking",
852-
"--enable-wasm-pthreads",
853-
]
854-
855-
856-
class Wasm32EmscriptenNodeDLBuild(Wasm32EmscriptenBuild):
857-
"""Emscripten with dynamic linking, testing with NodeJS
858-
"""
859-
buildersuffix = ".emscripten-node-dl"
860-
extra_configure_flags = [
861-
# don't run with --with-pydebug, Emscripten has limited stack
862-
"--without-pydebug",
863-
"--with-emscripten-target=node",
864-
"--enable-wasm-dynamic-linking",
865-
"--disable-wasm-pthreads",
866-
]
867-
868-
869-
class Wasm32EmscriptenBrowserBuild(Wasm32EmscriptenBuild):
870-
"""Emscripten browser builds (no tests)
871-
"""
872-
buildersuffix = ".emscripten-browser"
873-
extra_configure_flags = [
874-
# don't run with --with-pydebug, Emscripten has limited stack
875-
"--without-pydebug",
876-
"--with-emscripten-target=browser",
877-
"--enable-wasm-dynamic-linking",
878-
"--disable-wasm-pthreads",
879-
]
880-
# browser builds do not accept argv from CLI
881-
can_execute_python = False
882-
883-
884-
class Wasm32WASIBuild(UnixCrossBuild):
824+
# Deprecated since Python 3.13; can be dropped once `wasi.py` is in all versions.
825+
class Wasm32WasiCrossBuild(UnixCrossBuild):
885826
"""wasm32-wasi builder
886827
887828
* WASI SDK >= 16 must be installed to default path /opt/wasi-sdk
888829
* wasmtime must be installed and on PATH
889-
* Tools/wasm/wasi-env detects presence of WASIX and ccache
890830
"""
891-
buildersuffix = ".wasi"
892-
factory_tags = ["wasm", "wasi"]
831+
832+
buildersuffix = ".wasi.nondebug"
833+
factory_tags = ["wasm", "wasi", "nondebug"]
893834
extra_configure_flags = [
894835
# debug builds exhaust the limited call stack on WASI
895836
"--without-pydebug",
896837
]
897838
compile_environ = {
898839
"CONFIG_SITE": "../../Tools/wasm/config.site-wasm32-wasi",
840+
# Silence warnings about using the old CLI as raised by wasmtime 14+.
841+
"WASMTIME_NEW_CLI": "0",
842+
}
843+
test_environ = {
844+
# Silence warnings about using the old CLI as raised by wasmtime 14+.
845+
"WASMTIME_NEW_CLI": "0",
899846
}
900847
host = "wasm32-unknown-wasi"
901848
host_configure_cmd = ["../../Tools/wasm/wasi-env", "../../configure"]
@@ -909,6 +856,105 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
909856
haltOnFailure=True,
910857
)
911858
)
912-
super().setup(
913-
parallel, branch, test_with_PTY=test_with_PTY, **kwargs
859+
super().setup(parallel, branch, test_with_PTY=test_with_PTY, **kwargs)
860+
861+
862+
class _Wasm32WasiBuild(UnixBuild):
863+
"""Build Python for wasm32-wasi using Tools/wasm/wasi.py."""
864+
buildersuffix = ".wasi"
865+
factory_tags = ["wasm", "wasi"]
866+
# pydebug and append_suffix defined in subclasses.
867+
868+
def __init__(self, source, *, extra_tags=[], **kwargs):
869+
if not self.pydebug:
870+
extra_tags.append("nondebug")
871+
self.buildersuffix += self.append_suffix
872+
super().__init__(source, extra_tags=extra_tags, **kwargs)
873+
874+
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
875+
wasi_py = "Tools/wasm/wasi.py"
876+
host_path = "build/wasm32-wasi"
877+
878+
# Build Python
879+
build_configure = ["python3", wasi_py, "configure-build-python"]
880+
if self.pydebug:
881+
build_configure.extend(["--", "--with-pydebug"])
882+
self.addStep(
883+
Configure(
884+
name="Configure build Python",
885+
command=build_configure,
886+
)
887+
)
888+
self.addStep(
889+
Compile(
890+
name="Compile build Python",
891+
command=["python3", wasi_py, "make-build-python"],
892+
)
914893
)
894+
895+
# Host/WASI Python
896+
self.addStep(
897+
# Pydebug build automatically inferred from build Python.
898+
Configure(
899+
name="Configure host Python",
900+
command=["python3", wasi_py, "configure-host"],
901+
)
902+
)
903+
self.addStep(
904+
Compile(
905+
name="Compile host Python",
906+
command=["python3", wasi_py, "make-host"],
907+
)
908+
)
909+
910+
self.addStep(
911+
ShellCommand(
912+
name="pythoninfo",
913+
description="pythoninfo",
914+
command=["make", "pythoninfo"],
915+
warnOnFailure=True,
916+
workdir=host_path,
917+
)
918+
)
919+
920+
# Copied from UnixBuild.
921+
testopts = list(self.testFlags)
922+
if not has_option("-R", self.testFlags):
923+
testopts.extend(("--junit-xml", JUNIT_FILENAME))
924+
if parallel:
925+
testopts.append(parallel)
926+
if not has_option("-j", testopts):
927+
testopts.append("-j2")
928+
test = [
929+
"make",
930+
"buildbottest",
931+
"TESTOPTS=" + " ".join(testopts) + " ${BUILDBOT_TESTOPTS}",
932+
f"TESTPYTHONOPTS={self.interpreterFlags}",
933+
f"TESTTIMEOUT={self.test_timeout}",
934+
]
935+
self.addStep(
936+
Test(
937+
command=test,
938+
timeout=step_timeout(self.test_timeout),
939+
usePTY=test_with_PTY,
940+
env=self.test_environ,
941+
workdir=host_path,
942+
)
943+
)
944+
if branch not in ("3",) and not has_option("-R", self.testFlags):
945+
filename = os.path.join(host_path, JUNIT_FILENAME)
946+
self.addStep(UploadTestResults(branch, filename=filename))
947+
948+
self.addStep(
949+
Clean(
950+
name="Clean the builds",
951+
command=["python3", wasi_py, "clean"],
952+
)
953+
)
954+
955+
956+
# Preventing this from running on versions older than 3.13 is managed in
957+
# master.cfg.
958+
class Wasm32WasiDebugBuild(_Wasm32WasiBuild):
959+
append_suffix = ".debug"
960+
pydebug = True

master/master.cfg

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,12 @@ for branch_num, (git_url, branchname, git_branch) in enumerate(git_branches):
238238
tags.append(tier)
239239

240240
# Only 3.11+ for WebAssembly builds
241-
if "wasm" in tags and branchname in {"3.9", "3.10"}:
242-
continue
241+
if "wasm" in tags:
242+
if branchname in {"3.9", "3.10"}:
243+
continue
244+
# Pydebug support is 3.13+
245+
elif "nondebug" not in tags and branchname in {"3.11", "3.12"}:
246+
continue
243247

244248
if name in DAILYBUILDERS:
245249
dailybuildernames.append(buildername)

0 commit comments

Comments
 (0)