Skip to content

Commit

Permalink
pythongh-84461: Drop -sWASM, fix building tests for browser (pythonGH…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
tiran authored Apr 14, 2022
1 parent 1b035d9 commit 7acedd7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
49 changes: 24 additions & 25 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 27 additions & 30 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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


Expand Down Expand Up @@ -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], [$@], [
Expand Down

0 comments on commit 7acedd7

Please sign in to comment.