gh-84461: Drop -sWASM, fix building tests for browser (GH-91530)

- drop unnecessary ``=1`` suffix from Emscripten flags
- drop unnecessary ``-sWASM`` flag for side modules
- rename ``build_platform`` to ``build_wasm``. I introduced the target
  for WASM builds a couple of months ago.
- fix ``--enable-test-modules`` for browser builds
This commit is contained in:
Christian Heimes 2022-04-14 17:27:41 +03:00 committed by GitHub
parent 1b035d9699
commit 7acedd71de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 57 deletions

View File

@ -580,7 +580,7 @@ LIBEXPAT_HEADERS= \
all: @DEF_MAKE_ALL_RULE@
build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
Programs/_testembed python-config
build_platform: check-clean-src $(BUILDPYTHON) platform
build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config
# Check that the source is clean when building out of source.
check-clean-src:
@ -2475,7 +2475,7 @@ update-config:
Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
# Declare targets that aren't real files
.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest
.PHONY: all build_all build_wasm sharedmods check-clean-src oldsharedmods test quicktest
.PHONY: install altinstall oldsharedinstall bininstall altbininstall
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure

49
configure generated vendored
View File

@ -7226,8 +7226,8 @@ fi
;;
esac
elif test "$ac_sys_system" = "Emscripten"; then
DEF_MAKE_ALL_RULE="build_platform"
elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then
DEF_MAKE_ALL_RULE="build_wasm"
REQUIRE_PGO="no"
DEF_MAKE_RULE="all"
else
@ -7791,17 +7791,17 @@ fi
case $ac_sys_system/$ac_sys_emscripten_target in #(
Emscripten/browser*) :
LDFLAGS_NODIST="$LDFLAGS_NODIST -sALLOW_MEMORY_GROWTH=1"
LDFLAGS_NODIST="$LDFLAGS_NODIST -sALLOW_MEMORY_GROWTH"
LINKFORSHARED="--preload-file=\$(WASM_ASSETS_DIR)"
if test "x$enable_wasm_dynamic_linking" = xyes; then :
as_fn_append LINKFORSHARED " -sMAIN_MODULE=1"
as_fn_append LINKFORSHARED " -sMAIN_MODULE"
fi
WASM_ASSETS_DIR=".\$(prefix)"
WASM_STDLIB="\$(WASM_ASSETS_DIR)/local/lib/python\$(VERSION)/os.py"
if test "$Py_DEBUG" = 'true' -o "$ac_sys_emscripten_target" = "browser-debug"; then
LDFLAGS_NODIST="$LDFLAGS_NODIST -sASSERTIONS=1"
LDFLAGS_NODIST="$LDFLAGS_NODIST -sASSERTIONS"
LINKFORSHARED="$LINKFORSHARED -gsource-map --emit-symbol-map"
else
LINKFORSHARED="$LINKFORSHARED -O2 -g0"
@ -7809,16 +7809,16 @@ fi
;; #(
Emscripten/node*) :
LDFLAGS_NODIST="$LDFLAGS_NODIST -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sUSE_PTHREADS=1"
LINKFORSHARED="-sPROXY_TO_PTHREAD=1 -sEXIT_RUNTIME=1"
LDFLAGS_NODIST="$LDFLAGS_NODIST -sALLOW_MEMORY_GROWTH -sNODERAWFS -sUSE_PTHREADS"
LINKFORSHARED="-sPROXY_TO_PTHREAD -sEXIT_RUNTIME"
if test "x$enable_wasm_dynamic_linking" = xyes; then :
as_fn_append LINKFORSHARED " -sMAIN_MODULE=1"
as_fn_append LINKFORSHARED " -sMAIN_MODULE"
fi
CFLAGS_NODIST="$CFLAGS_NODIST -pthread"
if test "$Py_DEBUG" = 'true' -o "$ac_sys_emscripten_target" = "node-debug"; then
LDFLAGS_NODIST="$LDFLAGS_NODIST -sASSERTIONS=1"
LDFLAGS_NODIST="$LDFLAGS_NODIST -sASSERTIONS"
LINKFORSHARED="$LINKFORSHARED -gseparate-dwarf --emit-symbol-map"
else
LINKFORSHARED="$LINKFORSHARED -O2 -g0"
@ -10567,7 +10567,7 @@ fi;;
fi
if test "$enable_wasm_dynamic_linking" = "yes" -a "$ac_sys_system" = "Emscripten"; then
BLDSHARED='$(CC) -shared -sSIDE_MODULE=1 -sWASM=1'
BLDSHARED='$(CC) -shared -sSIDE_MODULE=1'
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDSHARED" >&5
@ -16030,8 +16030,8 @@ $as_echo "yes" >&6; }
fi
if test "$have_zlib" = "yes" -a "$ac_sys_system" = "Emscripten" -a "$ZLIB_LIBS" = "-lz"; then
ZLIB_CFLAGS="-sUSE_ZLIB=1"
ZLIB_LIBS="-sUSE_ZLIB=1"
ZLIB_CFLAGS="-sUSE_ZLIB"
ZLIB_LIBS="-sUSE_ZLIB"
fi
if test "x$have_zlib" = xyes; then :
@ -16264,8 +16264,8 @@ $as_echo "yes" >&6; }
fi
if test "$have_bzip2" = "yes" -a "$ac_sys_system" = "Emscripten" -a "$BZIP2_LIBS" = "-lbz2"; then
BZIP2_CFLAGS="-sUSE_BZIP2=1"
BZIP2_LIBS="-sUSE_BZIP2=1"
BZIP2_CFLAGS="-sUSE_BZIP2"
BZIP2_LIBS="-sUSE_BZIP2"
fi
@ -22341,28 +22341,27 @@ $as_echo_n "checking for --disable-test-modules... " >&6; }
# Check whether --enable-test-modules was given.
if test "${enable_test_modules+set}" = set; then :
enableval=$enable_test_modules;
if test "x$enable_test_modules" = xyes; then :
TEST_MODULES=yes
else
TEST_MODULES=no
fi
if test "$enable_test_modules" = no; then
TEST_MODULES=no
else
case $ac_sys_system/$ac_sys_emscripten_target in #(
case $ac_sys_system/$ac_sys_emscripten_target in #(
Emscripten/browser*) :
TEST_MODULES=no ;; #(
*) :
TEST_MODULES=yes
;;
;;
esac
fi
if test "x$TEST_MODULES" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $TEST_MODULES" >&5
$as_echo "$TEST_MODULES" >&6; }

View File

@ -1574,10 +1574,10 @@ if test "$Py_OPT" = 'true' ; then
])
;;
esac
elif test "$ac_sys_system" = "Emscripten"; then
elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then
dnl Emscripten does not support shared extensions yet. Build
dnl "python.[js,html,wasm]", "pybuilddir.txt", and "platform" files.
DEF_MAKE_ALL_RULE="build_platform"
dnl "python.[js,wasm]", "pybuilddir.txt", and "platform" files.
DEF_MAKE_ALL_RULE="build_wasm"
REQUIRE_PGO="no"
DEF_MAKE_RULE="all"
else
@ -1911,30 +1911,30 @@ fi
# WASM flags
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
[Emscripten/browser*], [
LDFLAGS_NODIST="$LDFLAGS_NODIST -sALLOW_MEMORY_GROWTH=1"
LDFLAGS_NODIST="$LDFLAGS_NODIST -sALLOW_MEMORY_GROWTH"
LINKFORSHARED="--preload-file=\$(WASM_ASSETS_DIR)"
AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
AS_VAR_APPEND([LINKFORSHARED], [" -sMAIN_MODULE=1"])
AS_VAR_APPEND([LINKFORSHARED], [" -sMAIN_MODULE"])
])
WASM_ASSETS_DIR=".\$(prefix)"
WASM_STDLIB="\$(WASM_ASSETS_DIR)/local/lib/python\$(VERSION)/os.py"
dnl separate-dwarf does not seem to work in Chrome DevTools Support.
if test "$Py_DEBUG" = 'true' -o "$ac_sys_emscripten_target" = "browser-debug"; then
LDFLAGS_NODIST="$LDFLAGS_NODIST -sASSERTIONS=1"
LDFLAGS_NODIST="$LDFLAGS_NODIST -sASSERTIONS"
LINKFORSHARED="$LINKFORSHARED -gsource-map --emit-symbol-map"
else
LINKFORSHARED="$LINKFORSHARED -O2 -g0"
fi
],
[Emscripten/node*], [
LDFLAGS_NODIST="$LDFLAGS_NODIST -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sUSE_PTHREADS=1"
LINKFORSHARED="-sPROXY_TO_PTHREAD=1 -sEXIT_RUNTIME=1"
LDFLAGS_NODIST="$LDFLAGS_NODIST -sALLOW_MEMORY_GROWTH -sNODERAWFS -sUSE_PTHREADS"
LINKFORSHARED="-sPROXY_TO_PTHREAD -sEXIT_RUNTIME"
AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
AS_VAR_APPEND([LINKFORSHARED], [" -sMAIN_MODULE=1"])
AS_VAR_APPEND([LINKFORSHARED], [" -sMAIN_MODULE"])
])
CFLAGS_NODIST="$CFLAGS_NODIST -pthread"
if test "$Py_DEBUG" = 'true' -o "$ac_sys_emscripten_target" = "node-debug"; then
LDFLAGS_NODIST="$LDFLAGS_NODIST -sASSERTIONS=1"
LDFLAGS_NODIST="$LDFLAGS_NODIST -sASSERTIONS"
LINKFORSHARED="$LINKFORSHARED -gseparate-dwarf --emit-symbol-map"
else
LINKFORSHARED="$LINKFORSHARED -O2 -g0"
@ -3009,7 +3009,7 @@ fi
dnl Emscripten's emconfigure sets LDSHARED. Set BLDSHARED outside the
dnl test -z $LDSHARED block to configure BLDSHARED for side module support.
if test "$enable_wasm_dynamic_linking" = "yes" -a "$ac_sys_system" = "Emscripten"; then
BLDSHARED='$(CC) -shared -sSIDE_MODULE=1 -sWASM=1'
BLDSHARED='$(CC) -shared -sSIDE_MODULE=1'
fi
AC_MSG_RESULT($LDSHARED)
@ -4549,8 +4549,8 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
])
if test "$have_zlib" = "yes" -a "$ac_sys_system" = "Emscripten" -a "$ZLIB_LIBS" = "-lz"; then
ZLIB_CFLAGS="-sUSE_ZLIB=1"
ZLIB_LIBS="-sUSE_ZLIB=1"
ZLIB_CFLAGS="-sUSE_ZLIB"
ZLIB_LIBS="-sUSE_ZLIB"
fi
dnl binascii can use zlib for optimized crc32.
@ -4572,8 +4572,8 @@ PKG_CHECK_MODULES([BZIP2], [bzip2], [have_bzip2=yes], [
])
if test "$have_bzip2" = "yes" -a "$ac_sys_system" = "Emscripten" -a "$BZIP2_LIBS" = "-lbz2"; then
BZIP2_CFLAGS="-sUSE_BZIP2=1"
BZIP2_LIBS="-sUSE_BZIP2=1"
BZIP2_CFLAGS="-sUSE_BZIP2"
BZIP2_LIBS="-sUSE_BZIP2"
fi
@ -6557,21 +6557,18 @@ fi],
# Check whether to disable test modules. Once set, setup.py will not build
# test extension modules and "make install" will not install test suites.
AC_MSG_CHECKING(for --disable-test-modules)
AC_ARG_ENABLE(test-modules,
AS_HELP_STRING([--disable-test-modules], [don't build nor install test modules]))
if test "$enable_test_modules" = no; then
TEST_MODULES=no
else
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
[Emscripten/browser*], [TEST_MODULES=no],
[TEST_MODULES=yes]
)
fi
AS_VAR_IF([TEST_MODULES], [yes],
[AC_MSG_RESULT(no)], [AC_MSG_RESULT(yes)]
)
AC_SUBST(TEST_MODULES)
AC_MSG_CHECKING([for --disable-test-modules])
AC_ARG_ENABLE([test-modules],
[AS_HELP_STRING([--disable-test-modules], [don't build nor install test modules])], [
AS_VAR_IF([enable_test_modules], [yes], [TEST_MODULES=yes], [TEST_MODULES=no])
], [
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
[Emscripten/browser*], [TEST_MODULES=no],
[TEST_MODULES=yes]
)
])
AC_MSG_RESULT([$TEST_MODULES])
AC_SUBST([TEST_MODULES])
AC_DEFUN([PY_STDLIB_MOD_SET_NA], [
m4_foreach([mod], [$@], [