1
1
# Wasm Build Instructions
2
2
3
- It should be noted that the wasm build of CppInterOp is still experimental and subject to change to change .
3
+ It should be noted that the wasm build of CppInterOp is still experimental and subject to change.
4
4
5
5
## CppInterOp Wasm Build Instructions
6
6
@@ -22,14 +22,7 @@ To create a wasm build of CppInterOp we make use of the emsdk toolchain. This ca
22
22
support version 3.1.45)
23
23
``` bash
24
24
git clone https://github.com/emscripten-core/emsdk.git
25
- cd emsdk
26
- ./emsdk install 3.1.45
27
- ```
28
-
29
- Go back upto the top level build directory using
30
-
31
- ``` bash
32
- cd ../..
25
+ ./emsdk/emsdk install 3.1.45
33
26
```
34
27
35
28
and activate the emsdk environment
@@ -48,11 +41,11 @@ git clone --depth=1 --branch release/19.x https://github.com/llvm/llvm-project.g
48
41
git clone --depth=1 https://github.com/compiler-research/CppInterOp.git
49
42
```
50
43
51
- Now move into the cloned llvm-project folder and apply a required patch
44
+ Now move into the cloned llvm-project folder and apply the required patches
52
45
53
46
``` bash
54
47
cd ./llvm-project/
55
- git apply -v ../CppInterOp/patches/llvm/emscripten-clang ${{ matrix.clang-runtime } } -* .patch
48
+ git apply -v ../CppInterOp/patches/llvm/emscripten-clang19 -* .patch
56
49
```
57
50
58
51
We are now in a position to build an emscripten build of llvm by executing the following
@@ -71,8 +64,13 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
71
64
-DCLANG_ENABLE_ARCMT=OFF \
72
65
-DCLANG_ENABLE_BOOTSTRAP=OFF \
73
66
-DCMAKE_CXX_FLAGS=" -Dwait4=__syscall_wait4" \
67
+ -DLLVM_INCLUDE_BENCHMARKS=OFF \
68
+ -DLLVM_INCLUDE_EXAMPLES=OFF \
69
+ -DLLVM_INCLUDE_TESTS=OFF \
70
+ -DLLVM_ENABLE_THREADS=OFF \
74
71
../llvm
75
72
emmake make clang -j $( nproc --all)
73
+ emmake make clang-repl -j $( nproc --all)
76
74
emmake make lld -j $( nproc --all)
77
75
```
78
76
@@ -82,10 +80,26 @@ Once this finishes building we need to take note of where we built our llvm buil
82
80
export LLVM_BUILD_DIR=$PWD
83
81
```
84
82
85
- We can move onto building the wasm version of CppInterOp. To do this execute the following
83
+ We can move onto building the wasm version of CppInterOp. We will do this within a Conda environment. We can achieve this
84
+ by executing (assumes you have micromamba installed and that your shell is initialised for the micromamba install)
86
85
87
86
``` bash
88
87
cd ../../CppInterOp/
88
+ micromamba create -f environment-wasm.yml --platform=emscripten-wasm32
89
+ micromamba activate CppInterOp-wasm
90
+ ```
91
+
92
+ You will also want to set a few environment variables
93
+
94
+ ``` bash
95
+ export PREFIX=$CONDA_PREFIX
96
+ export CMAKE_PREFIX_PATH=$PREFIX
97
+ export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
98
+ ```
99
+
100
+ Now to build CppInterOp execute the following
101
+
102
+ ``` bash
89
103
mkdir build
90
104
cd ./build/
91
105
emcmake cmake -DCMAKE_BUILD_TYPE=Release \
@@ -96,7 +110,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
96
110
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
97
111
-DCMAKE_INSTALL_PREFIX=$PREFIX \
98
112
../
99
- emmake make -j $( nproc --all)
113
+ emmake make -j $( nproc --all) install
100
114
```
101
115
102
116
Once this finishes building we need to take note of where we built CppInterOp. This can be done by executing the following
@@ -107,27 +121,16 @@ export CPPINTEROP_BUILD_DIR=$PWD
107
121
108
122
## Xeus-cpp-lite Wasm Build Instructions
109
123
110
- A project which makes use of the wasm build of CppInterOp is xeus-cpp. xeus-cpp is a C++ Jupyter kernel. To build xeus-cpp we first need to
111
- install several other dependencies. To create an Conda environment with this dependencies installed execute the following from the
112
- CppInterOp build folder (these instructions will assume you have already installed micromamba)
113
-
114
- ``` bash
115
- cd ..
116
- micromamba create -f environment-wasm.yml --platform=emscripten-wasm32
117
- micromamba activate CppInterOp-wasm
118
- export PREFIX=$MAMBA_ROOT_PREFIX /envs/CppInterOp-wasm
119
- ```
120
- Now we can build an wasm build of xeus-cpp by executing the following
124
+ A project which makes use of the wasm build of CppInterOp is xeus-cpp. xeus-cpp is a C++ Jupyter kernel. Assuming you are in
125
+ the CppInterOp build folder, you can build the wasm version of xeus-cpp by executing
121
126
122
127
``` bash
123
- cd ..
128
+ cd ../..
129
+ export SYSROOT_PATH=$PWD /emsdk/upstream/emscripten/cache/sysroot
124
130
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
125
131
cd ./xeus-cpp
126
132
mkdir build
127
133
cd build
128
- export CMAKE_PREFIX_PATH=$PREFIX
129
- export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
130
- export SYSROOT_PATH=$HOME /emsdk/upstream/emscripten/cache/sysroot
131
134
emcmake cmake \
132
135
-DCMAKE_BUILD_TYPE=Release \
133
136
-DCMAKE_PREFIX_PATH=$PREFIX \
@@ -140,11 +143,11 @@ emcmake cmake \
140
143
emmake make -j $( nproc --all) install
141
144
```
142
145
143
- To build Jupyter Lite with this kernel without creating a website you can execute the following
146
+ To build Jupyter Lite website with this kernel locally that you can use for testing execute the following
144
147
145
148
``` bash
146
149
cd ../..
147
- micromamba create -n xeus-lite-host jupyterlite-core
150
+ micromamba create -n xeus-lite-host jupyterlite-core -c conda-forge
148
151
micromamba activate xeus-lite-host
149
152
python -m pip install jupyterlite-xeus
150
153
jupyter lite build --XeusAddon.prefix=$PREFIX
@@ -159,7 +162,7 @@ cp $PREFIX/bin/xcpp.data _output/extensions/@jupyterlite/xeus/static
159
162
cp $PREFIX /lib/libclangCppInterOp.so _output/extensions/@jupyterlite/xeus/static
160
163
```
161
164
162
- Once the Jupyter Lite site has built you can test the website locally by executing
165
+ Once the Jupyter Lite site has built you can test the website locally by executing
163
166
164
167
``` bash
165
168
jupyter lite serve --XeusAddon.prefix=$PREFIX
0 commit comments