-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds CI to build libpython3.11 for wasm32-emscripten and running tests against it. We need to patch instant to work around the emscripten_get_now: sebcrozet/instant#47 We also have to patch emscripten to work aroung the "undefined symbol gxx_personality_v0" error: emscripten-core/emscripten#17128 I set up a nox file to download and install emscripten, download and build cpython, set appropriate environment variables then run cargo test. The workflow just installs python, rust, node, and nox and runs the nox session. I xfailed all the test failures. There are problems with datetime. iter_dict_nosegv and test_filenotfounderror should probably be fixable. The tests that involve threads or asyncio probably can't be fixed.
- Loading branch information
Showing
16 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
CURDIR=$(abspath .) | ||
|
||
BUILDROOT ?= $(CURDIR)/builddir | ||
export EMSDKDIR = $(BUILDROOT)/emsdk | ||
|
||
PLATFORM=wasm32_emscripten | ||
SYSCONFIGDATA_NAME=_sysconfigdata__$(PLATFORM) | ||
|
||
# BASH_ENV tells bash to run pyodide_env.sh on startup, which sets various | ||
# environment variables. The next line instructs make to use bash to run each | ||
# command. | ||
export BASH_ENV := $(CURDIR)/env.sh | ||
SHELL := /bin/bash | ||
|
||
EMSCRIPTEN_VERSION=3.1.13 | ||
|
||
PYMAJORMINORMICRO ?= 3.11.0 | ||
PYPRERELEASE ?= b1 | ||
|
||
version_tuple := $(subst ., ,$(PYMAJORMINORMICRO:v%=%)) | ||
export PYMAJOR=$(word 1,$(version_tuple)) | ||
export PYMINOR=$(word 2,$(version_tuple)) | ||
export PYMICRO=$(word 3,$(version_tuple)) | ||
PYVERSION=$(PYMAJORMINORMICRO)$(PYPRERELEASE) | ||
PYMAJORMINOR=$(PYMAJOR).$(PYMINOR) | ||
|
||
|
||
PYTHONURL=https://www.python.org/ftp/python/$(PYMAJORMINORMICRO)/Python-$(PYVERSION).tgz | ||
PYTHONTARBALL=$(BUILDROOT)/downloads/Python-$(PYVERSION).tgz | ||
PYTHONBUILD=$(BUILDROOT)/build/Python-$(PYVERSION) | ||
|
||
export PYTHONLIBDIR=$(BUILDROOT)/install/Python-$(PYVERSION)/lib | ||
|
||
all: $(PYTHONLIBDIR)/libpython$(PYMAJORMINOR).a | ||
|
||
$(BUILDROOT)/.exists: | ||
mkdir -p $(BUILDROOT) | ||
touch $@ | ||
|
||
|
||
$(EMSDKDIR): $(CURDIR)/emscripten_patches/* $(BUILDROOT)/.exists | ||
git clone https://github.com/emscripten-core/emsdk.git --depth 1 --branch $(EMSCRIPTEN_VERSION) $(EMSDKDIR) | ||
$(EMSDKDIR)/emsdk install $(EMSCRIPTEN_VERSION) | ||
cd $(EMSDKDIR)/upstream/emscripten && cat $(CURDIR)/emscripten_patches/* | patch -p1 | ||
$(EMSDKDIR)/emsdk activate $(EMSCRIPTEN_VERSION) | ||
|
||
|
||
$(PYTHONTARBALL): | ||
[ -d $(BUILDROOT)/downloads ] || mkdir -p $(BUILDROOT)/downloads | ||
wget -q -O $@ $(PYTHONURL) | ||
|
||
$(PYTHONBUILD)/.patched: $(PYTHONTARBALL) | ||
[ -d $(PYTHONBUILD) ] || ( \ | ||
mkdir -p $(dir $(PYTHONBUILD));\ | ||
tar -C $(dir $(PYTHONBUILD)) -xf $(PYTHONTARBALL) \ | ||
) | ||
touch $@ | ||
|
||
$(PYTHONBUILD)/Makefile: $(PYTHONBUILD)/.patched $(BUILDROOT)/emsdk | ||
cd $(PYTHONBUILD) && \ | ||
CONFIG_SITE=Tools/wasm/config.site-wasm32-emscripten \ | ||
emconfigure ./configure -C \ | ||
--host=wasm32-unknown-emscripten \ | ||
--build=$(shell $(PYTHONBUILD)/config.guess) \ | ||
--with-emscripten-target=browser \ | ||
--enable-wasm-dynamic-linking \ | ||
--with-build-python=python3.11 | ||
|
||
$(PYTHONLIBDIR)/libpython$(PYMAJORMINOR).a : $(PYTHONBUILD)/Makefile | ||
cd $(PYTHONBUILD) && \ | ||
emmake make -j3 libpython$(PYMAJORMINOR).a | ||
|
||
_PYTHON_SYSCONFIGDATA_NAME=$(SYSCONFIGDATA_NAME) _PYTHON_PROJECT_BASE=$(PYTHONBUILD) python3.11 -m sysconfig --generate-posix-vars | ||
cp `cat pybuilddir.txt`/$(SYSCONFIGDATA_NAME).py $(PYTHONBUILD)/Lib | ||
|
||
mkdir -p $(PYTHONLIBDIR) | ||
find $(PYTHONBUILD) -name '*.a' -exec cp {} $(PYTHONLIBDIR) \; | ||
cp -r $(PYTHONBUILD)/Lib $(PYTHONLIBDIR)/python$(PYMAJORMINOR) | ||
|
||
clean: | ||
rm -rf $(BUILDROOT) |
27 changes: 27 additions & 0 deletions
27
emscripten/emscripten_patches/0001-Add-_gxx_personality_v0-stub-to-library.js.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From 4b56f37c3dc9185a235a8314086c4d7a6239b2f8 Mon Sep 17 00:00:00 2001 | ||
From: Hood Chatham <roberthoodchatham@gmail.com> | ||
Date: Sat, 4 Jun 2022 19:19:47 -0700 | ||
Subject: [PATCH] Add _gxx_personality_v0 stub to library.js | ||
|
||
Mitigation for: | ||
https://github.com/emscripten-core/emscripten/issues/17128 | ||
--- | ||
src/library.js | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/src/library.js b/src/library.js | ||
index e7bb4c38e..7d01744df 100644 | ||
--- a/src/library.js | ||
+++ b/src/library.js | ||
@@ -403,6 +403,8 @@ mergeInto(LibraryManager.library, { | ||
abort('Assertion failed: ' + UTF8ToString(condition) + ', at: ' + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']); | ||
}, | ||
|
||
+ __gxx_personality_v0: function() {}, | ||
+ | ||
// ========================================================================== | ||
// time.h | ||
// ========================================================================== | ||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
|
||
# emsdk_env.sh is fairly noisy, and suppress error message if the file doesn't | ||
# exist yet (i.e. before building emsdk) | ||
# shellcheck source=/dev/null | ||
source "$EMSDKDIR/emsdk_env.sh" 2> /dev/null || true | ||
EMCC_PATH=$(which emcc.py || echo ".") | ||
EM_DIR=$(dirname "$EMCC_PATH") | ||
export EM_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/local/bin/python | ||
import pathlib | ||
import sys | ||
import subprocess | ||
|
||
p = pathlib.Path(sys.argv[1]) | ||
|
||
sys.exit(subprocess.call(["node", p.name], cwd=p.parent)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters