summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-09-13 10:06:39 (GMT)
committerGitHub <noreply@github.com>2022-09-13 10:06:39 (GMT)
commit4958820032d547cf7a1ebd619460d778ec143f9c (patch)
treec815e5ef7fc33c15f794534ced51d72616cf6844 /configure.ac
parent390123b412346eb4438665f068bb73226ac84e7c (diff)
downloadcpython-4958820032d547cf7a1ebd619460d778ec143f9c.zip
cpython-4958820032d547cf7a1ebd619460d778ec143f9c.tar.gz
cpython-4958820032d547cf7a1ebd619460d778ec143f9c.tar.bz2
[3.11] gh-95853: Add script to automate WASM build (GH-95828, GH-95985, GH-96045, GH-96389, GH-96744) (GH-96749)
Automate WASM build with a new Python script. The script provides several build profiles with configure flags for Emscripten flavors and WASI. The script can detect and use Emscripten SDK and WASI SDK from default locations or env vars. ``configure`` now detects Node arguments and creates HOSTRUNNER arguments for Node 16. It also sets correct arguments for ``wasm64-emscripten``.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac46
1 files changed, 41 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index ab5e1de..1d7e1be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -753,6 +753,16 @@ if test -z "$CFLAGS"; then
CFLAGS=
fi
+dnl Emscripten SDK and WASI SDK default to wasm32.
+dnl On Emscripten use MEMORY64 setting to build target wasm64-emscripten.
+dnl for wasm64.
+AS_CASE([$host],
+ [wasm64-*-emscripten], [
+ AS_VAR_APPEND([CFLAGS], [" -sMEMORY64=1"])
+ AS_VAR_APPEND([LDFLAGS], [" -sMEMORY64=1"])
+ ],
+)
+
if test "$ac_sys_system" = "Darwin"
then
# Compiler selection on MacOSX is more complicated than
@@ -1056,7 +1066,7 @@ cat > conftest.c <<EOF
# error unknown wasm32 platform
# endif
#elif defined(__wasm64__)
-# if defined(__EMSCRIPTEN)
+# if defined(__EMSCRIPTEN__)
wasm64-emscripten
# elif defined(__wasi__)
wasm64-wasi
@@ -1523,16 +1533,41 @@ if test "$cross_compiling" = yes; then
fi
AC_ARG_VAR([HOSTRUNNER], [Program to run CPython for the host platform])
-AC_MSG_CHECKING([HOSTRUNNER])
if test -z "$HOSTRUNNER"
then
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
[Emscripten/node*], [
+ AC_PATH_TOOL([NODE], [node], [node])
+ HOSTRUNNER="$NODE"
# bigint for ctypes c_longlong, c_longdouble
- HOSTRUNNER="node --experimental-wasm-bigint"
+ # no longer available in Node 16
+ AC_CACHE_CHECK([for node --experimental-wasm-bigint], [ac_cv_tool_node_wasm_bigint], [
+ if $NODE -v --experimental-wasm-bigint > /dev/null 2>&1; then
+ ac_cv_tool_node_wasm_bigint=yes
+ else
+ ac_cv_tool_node_wasm_bigint=no
+ fi
+ ])
+ AS_VAR_IF([ac_cv_tool_node_wasm_bigint], [yes], [
+ AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-bigint"])
+ ])
+
AS_VAR_IF([enable_wasm_pthreads], [yes], [
- HOSTRUNNER="$HOSTRUNNER --experimental-wasm-threads --experimental-wasm-bulk-memory"
+ AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-threads"])
+ # no longer available in Node 16
+ AC_CACHE_CHECK([for node --experimental-wasm-bulk-memory], [ac_cv_tool_node_wasm_bulk_memory], [
+ if $NODE -v --experimental-wasm-bulk-memory > /dev/null 2>&1; then
+ ac_cv_tool_node_wasm_bulk_memory=yes
+ else
+ ac_cv_tool_node_wasm_bulk_memory=no
+ fi
+ ])
+ AS_VAR_IF([ac_cv_tool_node_wasm_bulk_memory], [yes], [
+ AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-bulk-memory"])
+ ])
])
+
+ AS_VAR_IF([host_cpu], [wasm64], [AS_VAR_APPEND([HOSTRUNNER], [" --experimental-wasm-memory64"])])
],
dnl TODO: support other WASI runtimes
dnl wasmtime starts the proces with "/" as CWD. For OOT builds add the
@@ -1542,6 +1577,7 @@ then
)
fi
AC_SUBST([HOSTRUNNER])
+AC_MSG_CHECKING([HOSTRUNNER])
AC_MSG_RESULT([$HOSTRUNNER])
if test -n "$HOSTRUNNER"; then
@@ -1553,7 +1589,7 @@ AC_MSG_RESULT($LDLIBRARY)
# LIBRARY_DEPS, LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variable
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
- [Emscripten/browser*], [LIBRARY_DEPS='$(PY3LIBRARY) $(WASM_STDLIB)'],
+ [Emscripten/browser*], [LIBRARY_DEPS='$(PY3LIBRARY) $(WASM_STDLIB) python.html python.worker.js'],
[LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)']
)
LINK_PYTHON_DEPS='$(LIBRARY_DEPS)'