Skip to content

Use patched emsdk 3.1.73 out of emscripten-forge #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 18 additions & 24 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
@@ -21,13 +21,12 @@ jobs:
fail-fast: false
matrix:
include:
- name: osx15-arm-clang-clang-repl-19-emscripten_wasm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather the deployment stuck with the MacOS runner since it is noticeably faster, and works just like the Linux build (this is where I do my testing)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already discussed that we would change the runners to linux as preferred for the build.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring to the discussion we had on Zoom yesterday. I don't remember agreeing to switch the deployment runner from MacOS. Only that we would move to emscripten forges emsdk subject to determining whether it was needed once xeus-cpp was more complicated. @vgvassilev can confirm whether this was agreed to or not in our Zoom meeting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay if not discussed then we can discuss it here. The link to the discord above has all the context regarding the switch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep these builds even if they are not preferred. Once they start failing we will figure out what to do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah yeah not the point of discussion here !

For the deployment, we need to prefer one correct ? For just that we go with all the stable/recommended options. Make sense ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see your point. It was not discussed during our last video call. I'd prefer to change this PR as it was discussed and agreed upon. That means keeping these and moving to the patched version of the sdk.

os: macos-15
compiler: clang
- name: ubu24-x86-gcc12-clang-repl-19-emscripten
os: ubuntu-24.04
compiler: gcc-12
clang-runtime: '19'
cling: Off
micromamba_shell_init: bash
emsdk_ver: "3.1.73"

steps:
- uses: actions/checkout@v4
@@ -70,15 +69,9 @@ jobs:
- name: install mamba
uses: mamba-org/setup-micromamba@main
with:
init-shell: >-
${{ matrix.micromamba_shell_init }}

- name: Setup emsdk
shell: bash -l {0}
run: |
git clone --depth=1 https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${{ matrix.emsdk_ver }}
environment-file: environment-wasm-build.yml
init-shell: bash
environment-name: CppInterOp-wasm-build

- name: Restore Cache LLVM/Clang runtime build directory
uses: actions/cache/restore@v4
@@ -93,11 +86,10 @@ jobs:
if: ${{ runner.os != 'windows' }}
shell: bash -l {0}
run: |
./emsdk/emsdk activate ${{matrix.emsdk_ver}}
source ./emsdk/emsdk_env.sh
micromamba create -f environment-wasm.yml --platform=emscripten-wasm32
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32

export PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm-build
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX

@@ -154,20 +146,16 @@ jobs:
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
echo "BUILD_PREFIX=$BUILD_PREFIX" >> $GITHUB_ENV

- name: Build xeus-cpp
shell: bash -l {0}
run: |
./emsdk/emsdk activate ${{matrix.emsdk_ver}}
source ./emsdk/emsdk_env.sh
export SYSROOT_PATH=$PWD/emsdk/upstream/emscripten/cache/sysroot
micromamba activate CppInterOp-wasm
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
cd ./xeus-cpp
mkdir build
pushd build
export CMAKE_PREFIX_PATH=${{ env.PREFIX }}
export CMAKE_SYSTEM_PREFIX_PATH=${{ env.PREFIX }}
emcmake cmake \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_PREFIX_PATH=${{ env.PREFIX }} \
@@ -186,7 +174,13 @@ jobs:
micromamba create -n xeus-lite-host jupyterlite-core -c conda-forge
micromamba activate xeus-lite-host
python -m pip install jupyterlite-xeus jupyterlite-core jupyterlab notebook libarchive-c
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }} --contents notebooks/xeus-cpp-lite-demo.ipynb --contents notebooks/images/marie.png --contents notebooks/audio/audio.wav --output-dir dist
jupyter lite build \
--XeusAddon.prefix=${{ env.PREFIX }} \
--contents README.md \
--contents notebooks/xeus-cpp-lite-demo.ipynb \
--contents notebooks/images/marie.png \
--contents notebooks/audio/audio.wav \
--output-dir dist

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
@@ -201,7 +195,7 @@ jobs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Deploy to GitHub Pages
id: deployment
76 changes: 22 additions & 54 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
@@ -21,30 +21,20 @@ jobs:
fail-fast: false
matrix:
include:
- name: ubu24-arm-gcc12-clang-repl-19-emscripten
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reverted, and instead work should be done make the emsdk from emscripten forge available for Linux arm.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As part of the evidence as to why we shouldn't be dropping Ubuntu arm from the ci, here is an example of xeus-cpp-lite working on a Ubuntu arm vm. Instead we should make emsdk available on the Ubuntu arm platform as commented above.
image

Copy link
Collaborator Author

@anutosh491 anutosh491 Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay let's add this as a TODO for now and proceed ?

As discussed on the issue, it doesn't matter a lot having a lot of native builds. We aren't generating a lot of value here but if that's something we are interested in we can try supporting it.
emscripten-forge/recipes#1689 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we are interested in that.

Copy link
Collaborator

@mcbarton mcbarton Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not have this labelled as a todo item, just to get the PR in now. We currently are able to have people build on Linux arm (and have it work), while as things stands if itgis PR went in people using Linux arm wouldn't be able to do afterwards. We have agreed to use emscripten forges emsdk (while xeus-cpp-lite is developed more and it is checked the patch you mentioned is needed), but it should be done properly first time. Please do the work to get emsdk available throught emscripten forge on Linux arm first and then revert this ci change.

Copy link
Collaborator Author

@anutosh491 anutosh491 Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay In that case I don't know how to proceed.

As per what we discussed we decided to go ahead with the patched emsdk

  1. And the main point behind using it was not technically to support a lot of platforms rather it was towards introducing a consistent build. I am not sure if it makes sense to use different emsdk's to build llvm and CppInterOp differently and the other platforms differently

  2. That being said, I think what we have is a good start. If we read through the issue that I linked above
    i) emscripten_emscripten-wasm32 package only available on Ubuntu platform emscripten-forge/recipes#1689 (comment)
    ii) emscripten_emscripten-wasm32 package only available on Ubuntu platform emscripten-forge/recipes#1689 (comment)

Answers by Johan and Thortsen state as to why it shouldn't matter even if we have 1 single good build through the CI.

  1. Now obviously there's this point where what do users do in that case ? But think about it ....
    We end up having to make a choice here

Having an inconsistent build on all platforms vs Supporting more platforms !

  1. Btw here's are some answers by pyodide maintainers on why we need the patch. I had opened a discussion so that I can get some detailed replies on this
    i) Discussing patches on emsdk in Pyodide pyodide/pyodide#5420 (reply in thread)
    ii) Discussing patches on emsdk in Pyodide pyodide/pyodide#5420 (comment)

So yeah my point here is that ....
Allowing users to access the patched emsdk to build xeus-cpp-lite actually should end up holding more value than having it through the CI !
We know from a CI standpoint that having 1 good build should do the job in a wasm context
So CI shouldn't be our focus but rather how would a user make use of it. And for that I can open up an issue on emscripten-forge asking it to be supported. I probably won't be able to work on it right away as it doesn't fall under my assigned list of tasks. We can ask our users to make use of the emsdk from github till then and add a TODO for the same.

Also a big point is when it comes to the deployment, shouldn't we work towards the best build possible ? Isn't that what our users would use ?

So even if we don't want to use the patched emsdk untill Ubuntu Arm is supported, we should use it for our deployment build as that is our go-to build. We need to have a consistent build there

@vgvassilev how should we move here ?

My suggestion being if we want to be so demanding out of emscripten-forge cause obviously there's work going on there too and not sure if we would have this right away :/
We just have that one perfect build through our deployment where we use the patched emsdk and not have it through the CI untill Ubuntu Arm is supported ?

Copy link
Collaborator

@mcbarton mcbarton Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is stopping us from cloning emscripten forges recipe repo, so we can activate their emsdk manually on all platforms until its available as a package though emscripten forges channels? Having this way of building for now will xeus-cpp-lite to maintain the ability to be built from any available platforms, and we also get whatever patches are currently being applied within emscripten forge.

Thanks for the opening the discussions on Pyodide about the patches. I will look into what is said in the dicusssion (probably Monday)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is stopping us from cloning emscripten forges recipe repo, so we can activate their emsdk manually on all platforms until its available as a package though emscripten forges channels?

I think that's a brilliant suggestion. Let's do that ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is stopping us from cloning emscripten forges recipe repo, so we can activate their emsdk manually on all platforms until its available as a package though emscripten forges channels?

I think that's a brilliant suggestion. Let's do that ?

Ping me once you've made that suggested change to the ci, and build instructions and I will take another look at the PR (probably Monday as I am busy this weekend)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I am making no commits today. Only on Monday or Teusday

os: ubuntu-24.04-arm
compiler: gcc-12
clang-runtime: '19'
cling: Off
llvm_enable_projects: "clang;lld"
llvm_targets_to_build: "WebAssembly"
emsdk_ver: "3.1.73"
- name: osx15-arm-clang-clang-repl-19-emscripten
os: macos-15
compiler: clang
clang-runtime: '19'
cling: Off
llvm_enable_projects: "clang;lld"
llvm_targets_to_build: "WebAssembly"
emsdk_ver: "3.1.73"
llvm_targets_to_build: "WebAssembly"
- name: ubu24-x86-gcc12-clang-repl-19-emscripten
os: ubuntu-24.04
compiler: gcc-12
clang-runtime: '19'
cling: Off
llvm_enable_projects: "clang;lld"
llvm_targets_to_build: "WebAssembly"
emsdk_ver: "3.1.73"

steps:
- uses: actions/checkout@v4
@@ -115,13 +105,6 @@ jobs:
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-emscripten
lookup-only: true

- name: Setup emsdk
if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }}
run: |
git clone --depth=1 https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${{ matrix.emsdk_ver }}

- name: Setup default Build Type on *nux
if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }}
run: |
@@ -262,11 +245,17 @@ jobs:
sudo apt-get autoremove
sudo apt-get clean

- name: install mamba
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: mamba-org/setup-micromamba@main
with:
environment-file: environment-wasm-build.yml
init-shell: bash
environment-name: CppInterOp-wasm-build

- name: Build LLVM/Cling on Unix systems if the cache is invalid (emscripten)
if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }}
run: |
./emsdk/emsdk activate ${{matrix.emsdk_ver}}
source ./emsdk/emsdk_env.sh
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
git clone https://github.com/root-project/cling.git
@@ -465,21 +454,12 @@ jobs:
clang-runtime: '19'
cling: Off
micromamba_shell_init: bash
emsdk_ver: "3.1.73"
- name: osx15-arm-clang-clang-repl-19-emscripten_wasm
os: macos-15
compiler: clang
clang-runtime: '19'
cling: Off
micromamba_shell_init: bash
emsdk_ver: "3.1.73"
- name: ubu24-arm-gcc12-clang-repl-19-emscripten_wasm
os: ubuntu-24.04-arm
compiler: gcc-12
clang-runtime: '19'
cling: Off
micromamba_shell_init: bash
emsdk_ver: "3.1.73"

steps:
- uses: actions/checkout@v4
@@ -524,19 +504,6 @@ jobs:
echo "ncpus=$(nproc --all)" >> $GITHUB_ENV
fi

- name: install mamba
uses: mamba-org/setup-micromamba@main
with:
init-shell: >-
${{ matrix.micromamba_shell_init }}

- name: Setup emsdk
shell: bash -l {0}
run: |
git clone --depth=1 https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${{ matrix.emsdk_ver }}

- name: Restore Cache LLVM/Clang runtime build directory
uses: actions/cache/restore@v4
id: cache
@@ -545,16 +512,22 @@ jobs:
llvm-project
${{ matrix.cling=='On' && 'cling' || '' }}
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-emscripten

- name: install mamba
uses: mamba-org/setup-micromamba@main
with:
environment-file: environment-wasm-build.yml
init-shell: bash
environment-name: CppInterOp-wasm-build

- name: Emscripten build of CppInterOp on Unix systems
if: ${{ runner.os != 'windows' }}
shell: bash -l {0}
run: |
./emsdk/emsdk activate ${{matrix.emsdk_ver}}
source ./emsdk/emsdk_env.sh
micromamba create -f environment-wasm.yml --platform=emscripten-wasm32
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32

export PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm
export PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm-host
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm-build
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX

@@ -597,7 +570,6 @@ jobs:
-DBUILD_SHARED_LIBS=ON \
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DLLVM_ENABLE_WERROR=On \
../
fi
@@ -612,26 +584,22 @@ jobs:
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
echo "BUILD_PREFIX=$BUILD_PREFIX" >> $GITHUB_ENV

- name: Build xeus-cpp
shell: bash -l {0}
run: |
./emsdk/emsdk activate ${{matrix.emsdk_ver}}
source ./emsdk/emsdk_env.sh
export SYSROOT_PATH=$PWD/emsdk/upstream/emscripten/cache/sysroot
micromamba activate CppInterOp-wasm
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
cd ./xeus-cpp
mkdir build
pushd build
export CMAKE_PREFIX_PATH=${{ env.PREFIX }}
export CMAKE_SYSTEM_PREFIX_PATH=${{ env.PREFIX }}
emcmake cmake \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_PREFIX_PATH=${{ env.PREFIX }} \
-DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} \
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DCppInterOp_DIR="${{ env.CPPINTEROP_BUILD_DIR }}/lib/cmake/CppInterOp" \
-DSYSROOT_PATH=$SYSROOT_PATH \
..
30 changes: 11 additions & 19 deletions Emscripten-build-instructions.md
Original file line number Diff line number Diff line change
@@ -18,23 +18,15 @@ Now move into this directory using the following command
cd ./CppInterOp-wasm
```

To create a wasm build of CppInterOp we make use of the emsdk toolchain. This can be installed by executing (we only currently
support version 3.1.73)
You shall now want to make sure you are using the same emsdk (3.1.73) as the rest of our dependencies. This can be achieved by executing
the following
```bash
git clone https://github.com/emscripten-core/emsdk.git
./emsdk/emsdk install 3.1.73
micromamba create -f environment-wasm-build.yml -y
micromamba activate CppInterOp-wasm-build
```

and activate the emsdk environment

```bash
./emsdk/emsdk activate 3.1.73
source ./emsdk/emsdk_env.sh
```

Now clone the 19.x release of the LLVM project repository and CppInterOp (the building of the emscripten version of llvm can be
avoided by executing micromamba install llvm -c <https://repo.mamba.pm/emscripten-forge> and setting the LLVM_BUILD_DIR appropriately)

Now clone the 19.x release of the LLVM project repository and CppInterOp. The building of the emscripten version of llvm can be
avoided by executing micromamba install llvm=19 -c <https://repo.prefix.dev/emscripten-forge-dev> and setting the LLVM_BUILD_DIR appropriately.

```bash
git clone --depth=1 --branch release/19.x https://github.com/llvm/llvm-project.git
@@ -85,14 +77,14 @@ by executing (assumes you have micromamba installed and that your shell is initi

```bash
cd ../../CppInterOp/
micromamba create -f environment-wasm.yml --platform=emscripten-wasm32
micromamba activate CppInterOp-wasm
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
```

You will also want to set a few environment variables

```bash
export PREFIX=$CONDA_PREFIX
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm-build
export PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm-host
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
```
@@ -103,11 +95,11 @@ Now to build CppInterOp execute the following
mkdir build
cd ./build/
emcmake cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
-DLLD_DIR=$LLVM_BUILD_DIR/lib/cmake/lld \
-DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
../
emmake make -j $(nproc --all) install
@@ -126,7 +118,7 @@ the CppInterOp build folder, you can build the wasm version of xeus-cpp by execu

```bash
cd ../..
export SYSROOT_PATH=$PWD/emsdk/upstream/emscripten/cache/sysroot
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
cd ./xeus-cpp
mkdir build
Loading
Loading