Commit 65ebb994 authored by Michael Droettboom's avatar Michael Droettboom Committed by GitHub

Merge pull request #293 from mdboom/upgrade-emscripten-1.38.22

Upgrade emscripten to 1.38.22
parents 00a2bf9b 5c3bf202
......@@ -18,7 +18,7 @@ jobs:
- restore_cache:
keys:
- v1-emsdk-{{ checksum "emsdk/Makefile" }}-v12-
- v1-emsdk-{{ checksum "emsdk/Makefile" }}-v13-
- run:
name: build
......@@ -36,7 +36,7 @@ jobs:
paths:
- ./emsdk/emsdk
- ~/.ccache
key: v1-emsdk-{{ checksum "emsdk/Makefile" }}-v12-{{ .BuildNum }}
key: v1-emsdk-{{ checksum "emsdk/Makefile" }}-v13-{{ .BuildNum }}
- persist_to_workspace:
root: .
......
......@@ -16,22 +16,20 @@ CFLAGS=$(OPTFLAGS) -g -I$(PYTHONINCLUDE) -Wno-warn-absolute-paths
CXXFLAGS=$(CFLAGS) -std=c++14
# __ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv is in
# EXPORTED_FUNCTIONS to keep the C++ standard library in the core, even though
# there isn't any C++ there, for the sake of loading dynamic modules written in
# C++, such as those in matplotlib.
LDFLAGS=\
-O3 \
-s MODULARIZE=1 \
$(CPYTHONROOT)/installs/python-$(PYVERSION)/lib/libpython$(PYMINOR).a \
lz4/lz4-1.8.3/lib/liblz4.a \
$(LZ4LIB) \
-s "BINARYEN_METHOD='native-wasm'" \
-s TOTAL_MEMORY=1073741824 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MAIN_MODULE=1 \
-s EMULATED_FUNCTION_POINTERS=1 \
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
-s EXPORTED_FUNCTIONS='["_main", "__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv", "__ZNSt11logic_errorC2EPKc"]' \
-s LINKABLE=1 \
-s EXPORT_ALL=1 \
-s EXPORTED_FUNCTIONS='["___cxa_guard_acquire"]' \
-s WASM=1 \
-s SWAPPABLE_ASM_MODULE=1 \
-s USE_FREETYPE=1 \
......@@ -68,8 +66,6 @@ build/pyodide.asm.js: src/main.bc src/jsimport.bc src/jsproxy.bc src/js2python.b
[ -d build ] || mkdir build
$(CXX) -s EXPORT_NAME="'pyodide'" -o build/pyodide.asm.html $(filter %.bc,$^) \
$(LDFLAGS) -s FORCE_FILESYSTEM=1
rm build/pyodide.asm.asm.js
rm build/pyodide.asm.wasm.pre
rm build/pyodide.asm.html
......@@ -149,7 +145,7 @@ build/test.data: $(CPYTHONLIB)
)
( \
cd build; \
python $(FILEPACKAGER) test.data --lz4 --preload ../$(CPYTHONLIB)/test@/lib/python3.7/test --js-output=test.js --export-name=pyodide._module --exclude \*.wasm.pre --exclude __pycache__ \
python $(FILEPACKAGER) test.data --lz4 --preload ../$(CPYTHONLIB)/test@/lib/python3.7/test --js-output=test.js --export-name=pyodide._module --exclude __pycache__ \
)
uglifyjs build/test.js -o build/test.js
......@@ -174,7 +170,6 @@ root/.built: \
cd root/lib/python$(PYMINOR); \
rm -fr `cat ../../../remove_modules.txt`; \
rm -fr test; \
find . -name "*.wasm.pre" -type f -delete ; \
find -type d -name __pycache__ -prune -exec rm -rf {} \; \
)
touch root/.built
......@@ -185,7 +180,7 @@ ccache/emcc:
if hash ccache &>/dev/null; then \
ln -s `which ccache` $(PYODIDE_ROOT)/ccache/emcc ; \
else \
ln -s emsdk/emsdk/emscripten/tag-1.38.12/emcc $(PYODIDE_ROOT)/ccache/emcc; \
ln -s emsdk/emsdk/emscripten/tag-$(EMSCRIPTEN_VERSION)/emcc $(PYODIDE_ROOT)/ccache/emcc; \
fi
......@@ -194,7 +189,7 @@ ccache/em++:
if hash ccache &>/dev/null; then \
ln -s `which ccache` $(PYODIDE_ROOT)/ccache/em++ ; \
else \
ln -s emsdk/emsdk/emscripten/tag-1.38.12/em++ $(PYODIDE_ROOT)/ccache/em++; \
ln -s emsdk/emsdk/emscripten/tag-$(EMSCRIPTEN_VERSION)/em++ $(PYODIDE_ROOT)/ccache/em++; \
fi
......
export PATH := $(PYODIDE_ROOT)/ccache:$(PYODIDE_ROOT)/emsdk/emsdk:$(PYODIDE_ROOT)/emsdk/emsdk/clang/tag-e1.38.12/build_tag-e1.38.12_64/bin:$(PYODIDE_ROOT)/emsdk/emsdk/node/8.9.1_64bit/bin:$(PYODIDE_ROOT)/emsdk/emsdk/emscripten/tag-1.38.12:$(PYODIDE_ROOT)/emsdk/emsdk/binaryen/tag-1.38.12_64bit_binaryen/bin:$(PATH)
export EMSCRIPTEN_VERSION = 1.38.22
export PATH := $(PYODIDE_ROOT)/ccache:$(PYODIDE_ROOT)/emsdk/emsdk:$(PYODIDE_ROOT)/emsdk/emsdk/clang/tag-e$(EMSCRIPTEN_VERSION)/build_tag-e$(EMSCRIPTEN_VERSION)_64/bin:$(PYODIDE_ROOT)/emsdk/emsdk/node/8.9.1_64bit/bin:$(PYODIDE_ROOT)/emsdk/emsdk/emscripten/tag-$(EMSCRIPTEN_VERSION):$(PYODIDE_ROOT)/emsdk/emsdk/binaryen/tag-$(EMSCRIPTEN_VERSION)_64bit_binaryen/bin:$(PATH)
export EMSDK = $(PYODIDE_ROOT)/emsdk/emsdk
export EM_CONFIG = $(PYODIDE_ROOT)/emsdk/emsdk/.emscripten
export EM_CACHE = $(PYODIDE_ROOT)/emsdk/emsdk/.emscripten_cache
export EMSCRIPTEN = $(PYODIDE_ROOT)/emsdk/emsdk/emscripten/tag-1.38.12
export BINARYEN_ROOT = $(PYODIDE_ROOT)/emsdk/emsdk/binaryen/tag-1.38.12_64bit_binaryen
export EMSCRIPTEN = $(PYODIDE_ROOT)/emsdk/emsdk/emscripten/tag-$(EMSCRIPTEN_VERSION)
export BINARYEN_ROOT = $(PYODIDE_ROOT)/emsdk/emsdk/binaryen/tag-$(EMSCRIPTEN_VERSION)_64bit_binaryen
export PYVERSION=3.7.0
export PYMINOR=$(basename $(PYVERSION))
......@@ -22,4 +24,6 @@ export SIDE_LDFLAGS=\
-s SIDE_MODULE=1 \
-s WASM=1 \
-s "BINARYEN_TRAP_MODE='clamp'" \
--memory-init-file 0
--memory-init-file 0 \
-s LINKABLE=1 \
-s EXPORT_ALL=1
PYODIDE_ROOT=$(abspath ..)
include ../Makefile.envs
all: emsdk/.complete
# We hack the CPU_CORES, because if you use all of the cores on Circle-CI, you
......@@ -8,14 +11,15 @@ emsdk/.complete:
git clone https://github.com/juj/emsdk.git
sed -i -e "s#CPU_CORES = max(multiprocessing.cpu_count()-1, 1)#CPU_CORES = 3#g" emsdk/emsdk
( \
cd emsdk ; \
./emsdk install --build=Release sdk-tag-1.38.12-64bit binaryen-tag-1.38.12-64bit ; \
cd .. ; \
cd emsdk && \
./emsdk install --build=Release sdk-tag-$(EMSCRIPTEN_VERSION)-64bit binaryen-tag-$(EMSCRIPTEN_VERSION)-64bit && \
cd .. && \
(cat patches/*.patch | patch -p1) ; \
cd emsdk/binaryen/tag-1.38.12_64bit_binaryen/ ; \
make ; \
cd ../.. ; \
./emsdk activate --embedded --build=Release sdk-tag-1.38.12-64bit binaryen-tag-1.38.12-64bit ; \
cd emsdk/binaryen/tag-$(EMSCRIPTEN_VERSION)_64bit_binaryen/ && \
make && \
cd ../.. && \
cp binaryen/tag-$(EMSCRIPTEN_VERSION)/bin/wasm.js binaryen/tag-$(EMSCRIPTEN_VERSION)_64bit_binaryen/bin && \
./emsdk activate --embedded --build=Release sdk-tag-$(EMSCRIPTEN_VERSION)-64bit binaryen-tag-$(EMSCRIPTEN_VERSION)-64bit && \
touch .complete \
)
......
diff --git a/emsdk/emscripten/tag-1.38.12/src/library.js b/emsdk/emscripten/tag-1.38.12/src/library.js
index 82537bb3e..8e2e43128 100644
--- a/emsdk/emscripten/tag-1.38.12/src/library.js
+++ b/emsdk/emscripten/tag-1.38.12/src/library.js
@@ -1781,6 +1781,12 @@ LibraryManager.library = {
diff --git a/emsdk/emscripten/tag-1.38.22/src/support.js b//emsdk/emscripten/tag-1.38.22/src/support.js
index 8e1df8e82..4d07d6bef 100644
--- a/emsdk/emscripten/tag-1.38.22/src/support.js
+++ b/emsdk/emscripten/tag-1.38.22/src/support.js
@@ -437,7 +437,18 @@ function loadWebAssemblyModule(binary, flags) {
// present in the dynamic library but not in the main JS,
// and the dynamic library cannot provide JS for it. Use
// the generic "X" invoke for it.
- return env[prop] = invoke_X;
+ var dynCallName = 'dynCall_' + prop.slice(7);
+ return env[prop] = function() {
+ var sp = stackSave();
+ try {
+ var args = Array.prototype.slice.call(arguments);
+ return Module[dynCallName].apply(null, args);
+ } catch(e) {
+ stackRestore(sp);
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ Module["setThrew"](1, 0);
+ }
+ }
}
}
+ for (var sym in lib_module) {
+ if (sym.startsWith('dynCall_') && !Module.hasOwnProperty(sym)) {
+ Module[sym] = lib_module[sym];
+ }
+ }
+
// Not all browsers support Object.keys().
var handle = 1;
for (var key in DLFCN.loadedLibs) {
diff --git a/emsdk/emscripten/tag-1.38.12/src/support.js b/emsdk/emscripten/tag-1.38.12/src/support.js
index cff68fbe2..3a4e51dca 100644
--- a/emsdk/emscripten/tag-1.38.12/src/support.js
+++ b/emsdk/emscripten/tag-1.38.12/src/support.js
@@ -211,9 +211,21 @@ function loadWebAssemblyModule(binary, loadAsync) {
if (prop.startsWith('invoke_')) {
// A missing invoke, i.e., an invoke for a function type
// present in the dynamic library but not in the main JS,
- // and the dynamic library cannot provide JS for it. Use
- // the generic "X" invoke for it.
- return env[prop] = invoke_X;
+ // and the dynamic library cannot provide JS for it. Generate
+ // a closure for it.
+ var dynCallName = 'dynCall_' + prop.slice(7);
+ env[prop] = function() {
+ var sp = stackSave();
+ try {
+ var args = Array.prototype.slice.call(arguments);
+ return Module[dynCallName].apply(null, args);
+ } catch(e) {
+ stackRestore(sp);
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ Module["setThrew"](1, 0);
// if not a global, then a function - call it indirectly
return env[prop] = function() {
@@ -502,6 +513,11 @@ function loadWebAssemblyModule(binary, flags) {
}
#endif
}
+ if (e.startsWith("dynCall_")) {
+ if (!Module.hasOwnProperty(e)) {
+ Module[e] = value;
+ }
+ }
+ return env[prop];
exports[e] = value;
}
// if not a global, then a function - call it indirectly
return env[prop] = function() {
// initialize the module
diff --git a/emsdk/emscripten/tag-1.38.12/src/library_lz4.js b/emsdk/emscripten/tag-1.38.12/src/library_lz4.js
diff --git a/emsdk/emscripten/tag-1.38.22/src/library_lz4.js b/emsdk/emscripten/tag-1.38.22/src/library_lz4.js
index 4c3f583b7..5291002a4 100644
--- a/emsdk/emscripten/tag-1.38.12/src/library_lz4.js
+++ b/emsdk/emscripten/tag-1.38.12/src/library_lz4.js
--- a/emsdk/emscripten/tag-1.38.22/src/library_lz4.js
+++ b/emsdk/emscripten/tag-1.38.22/src/library_lz4.js
@@ -5,26 +5,14 @@ mergeInto(LibraryManager.library, {
DIR_MODE: {{{ cDefine('S_IFDIR') }}} | 511 /* 0777 */,
FILE_MODE: {{{ cDefine('S_IFREG') }}} | 511 /* 0777 */,
......
diff --git a/emsdk/binaryen/master/src/passes/FuncCastEmulation.cpp b/emsdk/binaryen/master/src/passes/FuncCastEmulation.cpp
index 013e9403..d95fc282 100644
--- a/emsdk/binaryen/tag-1.38.12/src/passes/FuncCastEmulation.cpp
+++ b/emsdk/binaryen/tag-1.38.12/src/passes/FuncCastEmulation.cpp
--- a/emsdk/binaryen/tag-1.38.22/src/passes/FuncCastEmulation.cpp
+++ b/emsdk/binaryen/tag-1.38.22/src/passes/FuncCastEmulation.cpp
@@ -39,7 +39,7 @@ namespace wasm {
// This should be enough for everybody. (As described above, we need this
// to match when dynamically linking, and also dynamic linking is why we
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment