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,11 @@ 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
+ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
68
+ -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true \
74
69
../llvm
75
70
emmake make clang -j $( nproc --all)
71
+ emmake make clang-repl -j $( nproc --all)
76
72
emmake make lld -j $( nproc --all)
77
73
```
78
74
@@ -82,10 +78,27 @@ Once this finishes building we need to take note of where we built our llvm buil
82
78
export LLVM_BUILD_DIR=$PWD
83
79
```
84
80
85
- We can move onto building the wasm version of CppInterOp. To do this execute the following
81
+ We can move onto building the wasm version of CppInterOp. We will do this within a Conda environment. We can achieve this
82
+ by execut (assumes you have micromamba installed and that your shell is initialised for the micromamba install)
86
83
87
84
``` bash
88
85
cd ../../CppInterOp/
86
+ micromamba create -f environment-wasm.yml --platform=emscripten-wasm32
87
+ micromamba activate CppInterOp-wasm
88
+ ```
89
+
90
+ You will also want to set a few environment variables
91
+
92
+ ``` bash
93
+ export PREFIX=$CONDA_PREFIX /envs/CppInterOp-wasm
94
+ export CMAKE_PREFIX_PATH=$PREFIX
95
+ export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
96
+ export LDFLAGS=" -s MODULARIZE=1 -s LINKABLE=1 -s EXPORT_ALL=1 -s WASM=1 -std=c++14 -s SIDE_MODULE=1 -sWASM_BIGINT"
97
+ ```
98
+
99
+ Now to build CppInterOp execute the following
100
+
101
+ ``` bash
89
102
mkdir build
90
103
cd ./build/
91
104
emcmake cmake -DCMAKE_BUILD_TYPE=Release \
@@ -96,7 +109,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
96
109
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
97
110
-DCMAKE_INSTALL_PREFIX=$PREFIX \
98
111
../
99
- emmake make -j $( nproc --all)
112
+ emmake make -j $( nproc --all) install
100
113
```
101
114
102
115
Once this finishes building we need to take note of where we built CppInterOp. This can be done by executing the following
@@ -107,27 +120,17 @@ export CPPINTEROP_BUILD_DIR=$PWD
107
120
108
121
## Xeus-cpp-lite Wasm Build Instructions
109
122
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
123
+ 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
124
+ the CppInterOp build folder, you can build the wasm version of xeus-cpp by executing
121
125
122
126
``` bash
123
- cd ..
127
+ cd ../..
128
+ export LDFLAGS=" -s MODULARIZE=1 -s LINKABLE=1 -s EXPORT_ALL=1 -s WASM=1 -std=c++14 -sWASM_BIGINT"
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