mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-95853: Add script to automate WASM build (GH-95828)
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``. Co-authored-by: Brett Cannon <brett@python.org>
This commit is contained in:
parent
0b329f4f03
commit
32ac98e899
9 changed files with 828 additions and 22 deletions
166
configure
generated
vendored
166
configure
generated
vendored
|
|
@ -906,6 +906,7 @@ AR
|
|||
LINK_PYTHON_OBJS
|
||||
LINK_PYTHON_DEPS
|
||||
LIBRARY_DEPS
|
||||
NODE
|
||||
HOSTRUNNER
|
||||
STATIC_LIBPYTHON
|
||||
GNULD
|
||||
|
|
@ -4079,6 +4080,16 @@ if test -z "$CFLAGS"; then
|
|||
CFLAGS=
|
||||
fi
|
||||
|
||||
case $host in #(
|
||||
wasm64-*-emscripten) :
|
||||
|
||||
as_fn_append CFLAGS " -sMEMORY64=1"
|
||||
as_fn_append LDFLAGS " -sMEMORY64=1"
|
||||
;; #(
|
||||
*) :
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "$ac_sys_system" = "Darwin"
|
||||
then
|
||||
# Extract the first word of "xcrun", so it can be a program name with args.
|
||||
|
|
@ -6220,7 +6231,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
|
||||
|
|
@ -6840,19 +6851,162 @@ if test "$cross_compiling" = yes; then
|
|||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking HOSTRUNNER" >&5
|
||||
$as_echo_n "checking HOSTRUNNER... " >&6; }
|
||||
if test -z "$HOSTRUNNER"
|
||||
then
|
||||
case $ac_sys_system/$ac_sys_emscripten_target in #(
|
||||
Emscripten/node*) :
|
||||
|
||||
if test -n "$ac_tool_prefix"; then
|
||||
# Extract the first word of "${ac_tool_prefix}node", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}node; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_path_NODE+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $NODE in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_NODE="$NODE" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_path_NODE="$as_dir/$ac_word$ac_exec_ext"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
NODE=$ac_cv_path_NODE
|
||||
if test -n "$NODE"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $NODE" >&5
|
||||
$as_echo "$NODE" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
if test -z "$ac_cv_path_NODE"; then
|
||||
ac_pt_NODE=$NODE
|
||||
# Extract the first word of "node", so it can be a program name with args.
|
||||
set dummy node; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_path_ac_pt_NODE+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $ac_pt_NODE in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_ac_pt_NODE="$ac_pt_NODE" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_path_ac_pt_NODE="$as_dir/$ac_word$ac_exec_ext"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
ac_pt_NODE=$ac_cv_path_ac_pt_NODE
|
||||
if test -n "$ac_pt_NODE"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_NODE" >&5
|
||||
$as_echo "$ac_pt_NODE" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
if test "x$ac_pt_NODE" = x; then
|
||||
NODE="node"
|
||||
else
|
||||
case $cross_compiling:$ac_tool_warned in
|
||||
yes:)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
|
||||
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
|
||||
ac_tool_warned=yes ;;
|
||||
esac
|
||||
NODE=$ac_pt_NODE
|
||||
fi
|
||||
else
|
||||
NODE="$ac_cv_path_NODE"
|
||||
fi
|
||||
|
||||
HOSTRUNNER="$NODE"
|
||||
# bigint for ctypes c_longlong, c_longdouble
|
||||
HOSTRUNNER="node --experimental-wasm-bigint"
|
||||
# no longer available in Node 16
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for node --experimental-wasm-bigint" >&5
|
||||
$as_echo_n "checking for node --experimental-wasm-bigint... " >&6; }
|
||||
if ${ac_cv_tool_node_wasm_bigint+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
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
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_tool_node_wasm_bigint" >&5
|
||||
$as_echo "$ac_cv_tool_node_wasm_bigint" >&6; }
|
||||
if test "x$ac_cv_tool_node_wasm_bigint" = xyes; then :
|
||||
|
||||
as_fn_append HOSTRUNNER " --experimental-wasm-bigint"
|
||||
|
||||
fi
|
||||
|
||||
if test "x$enable_wasm_pthreads" = xyes; then :
|
||||
|
||||
HOSTRUNNER="$HOSTRUNNER --experimental-wasm-threads --experimental-wasm-bulk-memory"
|
||||
as_fn_append HOSTRUNNER " --experimental-wasm-threads"
|
||||
# no longer available in Node 16
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for node --experimental-wasm-bulk-memory" >&5
|
||||
$as_echo_n "checking for node --experimental-wasm-bulk-memory... " >&6; }
|
||||
if ${ac_cv_tool_node_wasm_bulk_memory+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
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
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_tool_node_wasm_bulk_memory" >&5
|
||||
$as_echo "$ac_cv_tool_node_wasm_bulk_memory" >&6; }
|
||||
if test "x$ac_cv_tool_node_wasm_bulk_memory" = xyes; then :
|
||||
|
||||
as_fn_append HOSTRUNNER " --experimental-wasm-bulk-memory"
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if test "x$host_cpu" = xwasm64; then :
|
||||
as_fn_append HOSTRUNNER " --experimental-wasm-memory64"
|
||||
fi
|
||||
;; #(
|
||||
WASI/*) :
|
||||
|
|
@ -6863,6 +7017,8 @@ fi
|
|||
esac
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking HOSTRUNNER" >&5
|
||||
$as_echo_n "checking HOSTRUNNER... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOSTRUNNER" >&5
|
||||
$as_echo "$HOSTRUNNER" >&6; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue