Update to emscripten 2.0.15 (#1312)

This commit is contained in:
Dexter Chua 2021-03-10 16:13:53 +08:00 committed by GitHub
parent 1fb2df4e13
commit 958724101a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 53 deletions

View File

@ -1,5 +1,5 @@
export PYODIDE_EMSCRIPTEN_VERSION ?= 2.0.14
export PYODIDE_BINARYEN_VERSION ?= ed20954 # version_99. The git tag tags the wrong commit
export PYODIDE_EMSCRIPTEN_VERSION ?= 2.0.15
export PYODIDE_BINARYEN_VERSION ?= version_100
# BASH_ENV tells bash to run pyodide_env.sh on startup, whcih sets various
# environment variables. The next line instructs make to use bash to run each

View File

@ -2,7 +2,7 @@ diff --git a/emsdk/binary/src/passes/FuncCastEmulation.cpp b/src/passes/FuncCast
index 9d232c9..60d3990 100644
--- a/emsdk/binaryen/src/passes/FuncCastEmulation.cpp
+++ b/emsdk/binaryen/src/passes/FuncCastEmulation.cpp
@@ -170,20 +170,86 @@ struct FuncCastEmulation : public Pass {
@@ -170,23 +170,86 @@ struct FuncCastEmulation : public Pass {
std::stoul(runner->options.getArgumentOrDefault("max-func-params", "16"));
// we just need the one ABI function type for all indirect calls
Signature ABIType(Type(std::vector<Type>(numParams, Type::i64)), Type::i64);
@ -38,61 +38,61 @@ index 9d232c9..60d3990 100644
+ }
+ int exportCount=0;
+ // Add a thunk for each function in the table, and do the call through it.
for (auto& segment : module->table.segments) {
for (auto& name : segment.data) {
- auto iter = funcThunks.find(name);
- if (iter == funcThunks.end()) {
- auto thunk = makeThunk(name, module, numParams);
- funcThunks[name] = thunk;
- name = thunk;
- } else {
- name = iter->second;
+ // don't create FPCAST emulation for javascript legalizer stubs
+ // (used when javascript doesn't have 64 bit support, so
+ // can't use fpcast emulation calls which need 64 bit support)
+ if(strncmp(name.str,"legalstub$",10)!=0)
+ {
for (auto& table : module->tables) {
for (auto& segment : table->segments) {
for (auto& name : segment.data) {
- auto iter = funcThunks.find(name);
- if (iter == funcThunks.end()) {
- auto thunk = makeThunk(name, module, numParams);
- funcThunks[name] = thunk;
- name = thunk;
- } else {
- name = iter->second;
+ // don't create FPCAST emulation for javascript legalizer stubs
+ // (used when javascript doesn't have 64 bit support, so
+ // can't use fpcast emulation calls which need 64 bit support)
+ if(strncmp(name.str,"legalstub$",10)!=0) {
+ auto iter = funcThunks.find(name);
+ if (iter == funcThunks.end()) {
+ // we've already made thunks for exported funcionts so
+ // this is a static function - make the thunk and make an anon export
+ // to it so that it can be called by pyodide
+ Name orig_name(name);
+ auto thunk = makeThunk(name, module, numParams);
+ funcThunks[name] = thunk;
+ exportCount+=1;
+ char buffer[256];
+ snprintf(buffer,256,"byn$fpcast-emu$__static_%d",exportCount);
+ // first make the fpcast version of the function
+ auto* export_ = new Export;
+ export_->name = buffer;
+ export_->value = thunk;
+ export_->kind = ExternalKind::Function;
+ module->addExport(export_);
+ // now make the non-fpcast version
+ snprintf(buffer,256,"__static_%d",exportCount);
+ auto* export2_ = new Export;
+ export2_->name = buffer;
+ export2_->value = orig_name;
+ export2_->kind = ExternalKind::Function;
+ module->addExport(export2_);
+ name = thunk;
+ Name orig_name(name);
+ auto thunk = makeThunk(name, module, numParams);
+ funcThunks[name] = thunk;
+ exportCount+=1;
+ char buffer[256];
+ snprintf(buffer,256,"byn$fpcast-emu$__static_%d",exportCount);
+ // first make the fpcast version of the function
+ auto* export_ = new Export;
+ export_->name = buffer;
+ export_->value = thunk;
+ export_->kind = ExternalKind::Function;
+ module->addExport(export_);
+ // now make the non-fpcast version
+ snprintf(buffer,256,"__static_%d",exportCount);
+ auto* export2_ = new Export;
+ export2_->name = buffer;
+ export2_->value = orig_name;
+ export2_->kind = ExternalKind::Function;
+ module->addExport(export2_);
+ name = thunk;
+ } else {
+ name = iter->second;
+ }
}
}
}
}
+ // make exports for all export thunks
+ for(auto& thunk: exportThunks)
+ {
+ auto* export_ = new Export;
+ export_->name = thunk.first;
+ for(auto& thunk: exportThunks) {
+ auto* export_ = new Export;
+ export_->name = thunk.first;
+ export_->value = thunk.second;
+ export_->kind = ExternalKind::Function;
+ module->addExport(export_);
+ }
+
+
// update call_indirects
ParallelFuncCastEmulation(ABIType, numParams).run(runner, module);

View File

@ -1,11 +0,0 @@
--- a/emsdk/upstream/emscripten/src/library_syscall.js
+++ b/emsdk/upstream/emscripten/src/library_syscall.js
@@ -755,7 +755,7 @@ var SyscallsLibrary = {
},
__sys_wait4__proxy: false,
__sys_wait4: function(pid, wstart, options, rusage) {
- abort('cannot wait on child processes');
+ return -({{{ cDefine('ENOSYS') }}});
},
__sys_setdomainname__nothrow: true,
__sys_setdomainname__proxy: false,