Skip to content

Commit

Permalink
added emsdk patched installer
Browse files Browse the repository at this point in the history
  • Loading branch information
DerThorsten committed Feb 5, 2024
1 parent 6e15a5c commit de54a07
Show file tree
Hide file tree
Showing 6 changed files with 523 additions and 10 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ jobs:
run: |
playwright install
- name: Setup emsdk
shell: bash -el {0}
run: |
micromamba activate pyjs-wasm
emsdk install ${{matrix.emsdk_ver}}
./emsdk/setup_emsdk.sh ${{ matrix.emsdk_ver }} $(pwd)/emsdk_install
- name: create wasm build environment
run: |
Expand All @@ -61,9 +62,8 @@ jobs:
- name: Build pyjs
run: |
emsdk activate ${{matrix.emsdk_ver}}
source $CONDA_EMSDK_DIR/emsdk_env.sh
source $(pwd)/emsdk_install/emsdk_env.sh
mkdir build
pushd build
Expand All @@ -88,8 +88,7 @@ jobs:
- name: Build xeus-python
run: |
emsdk activate ${{matrix.emsdk_ver}}
source $CONDA_EMSDK_DIR/emsdk_env.sh
source $(pwd)/emsdk_install/emsdk_env.sh
git clone [email protected]:jupyter-xeus/xeus-python.git
pushd xeus-python
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ jobs:
playwright install
- name: Setup emsdk
shell: bash -el {0}
run: |
micromamba activate pyjs-wasm
emsdk install ${{matrix.emsdk_ver}}
./emsdk/setup_emsdk.sh ${{ matrix.emsdk_ver }} $(pwd)/emsdk_install
- name: Build pyjs
run: |
micromamba activate pyjs-wasm
emsdk activate ${{matrix.emsdk_ver}}
source $CONDA_EMSDK_DIR/emsdk_env.sh
source $(pwd)/emsdk_install/emsdk_env.sh
micromamba create -n pyjs-build-wasm \
--platform=emscripten-32 \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 0170462a78e86de9ee95017bfa7e4a3dd620a375 Mon Sep 17 00:00:00 2001
From: Hood Chatham <[email protected]>
Date: Fri, 2 Jun 2023 11:59:32 -0700
Subject: [PATCH] Add back fs.findObject and fs.readFile in loadLibData

See upstream PR:
https://github.com/emscripten-core/emscripten/pull/19513
---
src/library_dylink.js | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/library_dylink.js b/src/library_dylink.js
index d7676cdc2..f616d230d 100644
--- a/src/library_dylink.js
+++ b/src/library_dylink.js
@@ -993,14 +993,23 @@ var LibraryDylink = {
#endif

// for wasm, we can use fetch for async, but for fs mode we can only imitate it
+ var libData;
if (handle) {
var data = {{{ makeGetValue('handle', C_STRUCTS.dso.file_data, '*') }}};
var dataSize = {{{ makeGetValue('handle', C_STRUCTS.dso.file_data_size, '*') }}};
if (data && dataSize) {
- var libData = HEAP8.slice(data, data + dataSize);
- return flags.loadAsync ? Promise.resolve(libData) : libData;
+ libData = HEAP8.slice(data, data + dataSize);
}
}
+ if (!libData && flags.fs && flags.fs.findObject(libName)) {
+ libData = flags.fs.readFile(libName, {encoding: 'binary'});
+ if (!(libData instanceof Uint8Array)) {
+ libData = new Uint8Array(libData);
+ }
+ }
+ if (libData) {
+ return flags.loadAsync ? Promise.resolve(libData) : libData;
+ }

var libFile = locateFile(libName);
if (flags.loadAsync) {
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From a8bdb50a29062ee70c8667e4fd94dde47917f8fa Mon Sep 17 00:00:00 2001
From: Hood Chatham <[email protected]>
Date: Fri, 19 May 2023 12:19:00 -0700
Subject: [PATCH] Add useful error when symbol resolution fails

Currently if symbol resolution fails, we get:
```js
TypeError: Cannot read properties of undefined (reading 'apply')
```
It is very hard for newcomers to Emscripten to recognize this as a
symbol resolution error. Even for people experienced with this message,
it has the annoyance that it doesn't give any hint as to which symbol
went missing.

This adds a descriptive error message with the name of the missing
symbol.
---
src/library_dylink.js | 3 +++
1 file changed, 3 insertions(+)

diff --git a/src/library_dylink.js b/src/library_dylink.js
index d96e6b425..7f63b5c5e 100644
--- a/src/library_dylink.js
+++ b/src/library_dylink.js
@@ -727,6 +727,9 @@ var LibraryDylink = {
var resolved;
stubs[prop] = function() {
if (!resolved) resolved = resolveSymbol(prop);
+ if (!resolved) {
+ throw new Error(`Dynamic linking error: cannot resolve symbol ${prop}`);
+ }
return resolved.apply(null, arguments);
};
}
--
2.25.1

Loading

0 comments on commit de54a07

Please sign in to comment.