Skip to content

Commit c8319f7

Browse files
authored
bpo-40280: Build WASM stdlib bundle and more modules for node (GH-30597)
1 parent 7c770d3 commit c8319f7

File tree

3 files changed

+55
-24
lines changed

3 files changed

+55
-24
lines changed

Makefile.pre.in

+1
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,7 @@ clean-retain-profile: pycremoval
23992399
-rm -f Lib/lib2to3/*Grammar*.pickle
24002400
-rm -f _bootstrap_python
24012401
-rm -f python.html python*.js python.data
2402+
-rm -rf $(WASM_STDLIB)
24022403
-rm -f Programs/_testembed Programs/_freeze_module
24032404
-rm -f Python/deepfreeze/*.[co]
24042405
-rm -f Python/frozen_modules/*.h

configure

+22-12
Original file line numberDiff line numberDiff line change
@@ -6577,7 +6577,13 @@ fi
65776577
$as_echo "$LDLIBRARY" >&6; }
65786578

65796579
# LIBRARY_DEPS, LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variable
6580-
LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)'
6580+
case $ac_sys_system/$ac_sys_emscripten_target in #(
6581+
Emscripten/browser) :
6582+
LIBRARY_DEPS='$(PY3LIBRARY) $(WASM_STDLIB)' ;; #(
6583+
*) :
6584+
LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)'
6585+
;;
6586+
esac
65816587
LINK_PYTHON_DEPS='$(LIBRARY_DEPS)'
65826588
if test "$PY_ENABLE_SHARED" = 1 || test "$enable_framework" ; then
65836589
LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS"
@@ -7669,14 +7675,14 @@ fi
76697675
case $ac_sys_system/$ac_sys_emscripten_target in #(
76707676
Emscripten/browser) :
76717677

7672-
LDFLAGS_NODIST="$(LDFLAGS_NODIST) -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file \$(WASM_ASSETS_DIR)"
7678+
LDFLAGS_NODIST="$LDFLAGS_NODIST -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file \$(WASM_ASSETS_DIR)"
76737679
WASM_ASSETS_DIR=".\$(prefix)"
76747680
WASM_STDLIB="\$(WASM_ASSETS_DIR)/local/lib/python\$(VERSION)/os.py"
76757681
;; #(
76767682
Emscripten/node) :
76777683

7678-
LDFLAGS_NODIST="$(LDFLAGS_NODIST) -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s USE_PTHREADS -s PROXY_TO_PTHREAD"
7679-
CFLAGS_NODIST="$(CFLAGS_NODIST) -pthread"
7684+
LDFLAGS_NODIST="$LDFLAGS_NODIST -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s USE_PTHREADS -s PROXY_TO_PTHREAD"
7685+
CFLAGS_NODIST="$CFLAGS_NODIST -pthread"
76807686
;; #(
76817687
WASI) :
76827688

@@ -21294,22 +21300,26 @@ $as_echo "yes" >&6; }
2129421300
fi
2129521301

2129621302

21297-
case $ac_sys_system in #(
21298-
AIX) :
21303+
case $ac_sys_system/$ac_sys_emscripten_target in #(
21304+
AIX/*) :
2129921305
py_stdlib_not_available="_scproxy spwd" ;; #(
21300-
VxWorks*) :
21306+
VxWorks*/*) :
2130121307
py_stdlib_not_available="_scproxy _crypt termios grp" ;; #(
21302-
Darwin) :
21308+
Darwin/*) :
2130321309
py_stdlib_not_available="ossaudiodev spwd" ;; #(
21304-
CYGWIN*) :
21310+
CYGWIN*/*) :
2130521311
py_stdlib_not_available="_scproxy nis" ;; #(
21306-
QNX*) :
21312+
QNX*/*) :
2130721313
py_stdlib_not_available="_scproxy nis" ;; #(
21308-
FreeBSD*) :
21314+
FreeBSD*/*) :
2130921315
py_stdlib_not_available="_scproxy spwd" ;; #(
21310-
Emscripten) :
21316+
Emscripten/browser) :
2131121317

2131221318
py_stdlib_not_available="_ctypes _curses _curses_panel _dbm _gdbm _multiprocessing _posixshmem _posixsubprocess _scproxy _tkinter _xxsubinterpreters fcntl grp nis ossaudiodev resource readline spwd syslog termios"
21319+
;; #(
21320+
Emscripten/node) :
21321+
21322+
py_stdlib_not_available="_ctypes _curses _curses_panel _dbm _gdbm _scproxy _tkinter nis ossaudiodev spwd syslog"
2131321323
;; #(
2131421324
*) :
2131521325
py_stdlib_not_available="_scproxy"

configure.ac

+32-12
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,10 @@ fi
13541354
AC_MSG_RESULT($LDLIBRARY)
13551355

13561356
# LIBRARY_DEPS, LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variable
1357-
LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)'
1357+
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
1358+
[Emscripten/browser], [LIBRARY_DEPS='$(PY3LIBRARY) $(WASM_STDLIB)'],
1359+
[LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)']
1360+
)
13581361
LINK_PYTHON_DEPS='$(LIBRARY_DEPS)'
13591362
if test "$PY_ENABLE_SHARED" = 1 || test "$enable_framework" ; then
13601363
LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS"
@@ -1839,13 +1842,13 @@ fi
18391842
# WASM flags
18401843
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
18411844
[Emscripten/browser], [
1842-
LDFLAGS_NODIST="$(LDFLAGS_NODIST) -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file \$(WASM_ASSETS_DIR)"
1845+
LDFLAGS_NODIST="$LDFLAGS_NODIST -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file \$(WASM_ASSETS_DIR)"
18431846
WASM_ASSETS_DIR=".\$(prefix)"
18441847
WASM_STDLIB="\$(WASM_ASSETS_DIR)/local/lib/python\$(VERSION)/os.py"
18451848
],
18461849
[Emscripten/node], [
1847-
LDFLAGS_NODIST="$(LDFLAGS_NODIST) -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s USE_PTHREADS -s PROXY_TO_PTHREAD"
1848-
CFLAGS_NODIST="$(CFLAGS_NODIST) -pthread"
1850+
LDFLAGS_NODIST="$LDFLAGS_NODIST -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s USE_PTHREADS -s PROXY_TO_PTHREAD"
1851+
CFLAGS_NODIST="$CFLAGS_NODIST -pthread"
18491852
],
18501853
[WASI], [
18511854
AC_DEFINE([_WASI_EMULATED_SIGNAL], [1], [Define to 1 if you want to emulate signals on WASI])
@@ -6336,14 +6339,14 @@ AC_SUBST(TEST_MODULES)
63366339
dnl Modules that are not available on some platforms
63376340
dnl AIX has shadow passwords, but access is not via getspent()
63386341
dnl VxWorks does not provide crypt() function
6339-
AS_CASE([$ac_sys_system],
6340-
[AIX], [py_stdlib_not_available="_scproxy spwd"],
6341-
[VxWorks*], [py_stdlib_not_available="_scproxy _crypt termios grp"],
6342-
[Darwin], [py_stdlib_not_available="ossaudiodev spwd"],
6343-
[CYGWIN*], [py_stdlib_not_available="_scproxy nis"],
6344-
[QNX*], [py_stdlib_not_available="_scproxy nis"],
6345-
[FreeBSD*], [py_stdlib_not_available="_scproxy spwd"],
6346-
[Emscripten], [
6342+
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
6343+
[AIX/*], [py_stdlib_not_available="_scproxy spwd"],
6344+
[VxWorks*/*], [py_stdlib_not_available="_scproxy _crypt termios grp"],
6345+
[Darwin/*], [py_stdlib_not_available="ossaudiodev spwd"],
6346+
[CYGWIN*/*], [py_stdlib_not_available="_scproxy nis"],
6347+
[QNX*/*], [py_stdlib_not_available="_scproxy nis"],
6348+
[FreeBSD*/*], [py_stdlib_not_available="_scproxy spwd"],
6349+
[Emscripten/browser], [
63476350
py_stdlib_not_available="m4_normalize([
63486351
_ctypes
63496352
_curses
@@ -6367,6 +6370,23 @@ AS_CASE([$ac_sys_system],
63676370
termios
63686371
])"
63696372
],
6373+
dnl Some modules like _posixsubprocess do not work. We build them anyway
6374+
dnl so imports in tests do not fail.
6375+
[Emscripten/node], [
6376+
py_stdlib_not_available="m4_normalize([
6377+
_ctypes
6378+
_curses
6379+
_curses_panel
6380+
_dbm
6381+
_gdbm
6382+
_scproxy
6383+
_tkinter
6384+
nis
6385+
ossaudiodev
6386+
spwd
6387+
syslog
6388+
])"
6389+
],
63706390
[py_stdlib_not_available="_scproxy"]
63716391
)
63726392

0 commit comments

Comments
 (0)