@@ -63,9 +63,8 @@ On Windows execute the following
63
63
``` powershell
64
64
cd .\llvm-project\
65
65
cp -r ..\patches\llvm\emscripten-clang20*
66
- cp -r ..\patches\llvm\Windows-emscripten-clang20*
67
- git apply -v Windows-emscripten-clang20-1-CrossCompile.patch
68
66
git apply -v emscripten-clang20-2-shift-temporary-files-to-tmp-dir.patch
67
+ git apply -v emscripten-clang20-3-enable_exception_handling.patch
69
68
```
70
69
71
70
We are now in a position to build an emscripten build of llvm by executing the following on Linux
@@ -81,7 +80,6 @@ mkdir build
81
80
cd build
82
81
emcmake cmake -DCMAKE_BUILD_TYPE=Release \
83
82
-DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten \
84
- -DLLVM_ENABLE_ASSERTIONS=ON \
85
83
-DLLVM_TARGETS_TO_BUILD=" WebAssembly" \
86
84
-DLLVM_ENABLE_LIBEDIT=OFF \
87
85
-DLLVM_ENABLE_PROJECTS=" clang;lld" \
@@ -99,6 +97,9 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
99
97
-DLLVM_ENABLE_LIBPFM=OFF \
100
98
-DCLANG_BUILD_TOOLS=OFF \
101
99
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_DIR \
100
+ -DCMAKE_C_FLAGS_RELEASE=" -Oz -g0 -DNDEBUG" \
101
+ -DCMAKE_CXX_FLAGS_RELEASE=" -Oz -g0 -DNDEBUG" \
102
+ -DLLVM_ENABLE_LTO=Full \
102
103
../llvm
103
104
emmake make libclang -j $( nproc --all)
104
105
emmake make clangInterpreter clangStaticAnalyzerCore -j $( nproc --all)
@@ -108,11 +109,17 @@ emmake make lldWasm -j $(nproc --all)
108
109
or executing
109
110
110
111
``` powershell
112
+ mkdir native_build
113
+ cd native_build
114
+ cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release -G Ninja ../llvm/
115
+ cmake --build . --target llvm-tblgen clang-tblgen --parallel $(nproc --all)
116
+ $env:PWD_DIR= $PWD.Path
117
+ $env:NATIVE_DIR="$env:PWD_DIR/bin/"
118
+ cd ..
111
119
mkdir build
112
120
cd build
113
121
emcmake cmake -DCMAKE_BUILD_TYPE=Release `
114
122
-DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten `
115
- -DLLVM_ENABLE_ASSERTIONS=ON `
116
123
-DLLVM_TARGETS_TO_BUILD="WebAssembly" `
117
124
-DLLVM_ENABLE_LIBEDIT=OFF `
118
125
-DLLVM_ENABLE_PROJECTS="clang;lld" `
@@ -129,7 +136,11 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
129
136
-DLLVM_BUILD_TOOLS=OFF `
130
137
-DLLVM_ENABLE_LIBPFM=OFF `
131
138
-DCLANG_BUILD_TOOLS=OFF `
139
+ -DLLVM_NATIVE_TOOL_DIR="$env:NATIVE_DIR" `
132
140
-G Ninja `
141
+ -DCMAKE_C_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
142
+ -DCMAKE_CXX_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
143
+ -DLLVM_ENABLE_LTO=Full `
133
144
..\llvm
134
145
emmake ninja libclang clangInterpreter clangStaticAnalyzerCore lldWasm
135
146
```
@@ -208,14 +219,14 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
208
219
emmake make -j $(nproc --all) check-cppinterop
209
220
```
210
221
211
- It is possible to run the Emscripten tests in a headless browser on Linux and osx (in future we plan to include instructions on how to run the tests in a browser on Windows too) . To do this we will first move to the tests directory
222
+ It is possible to run the Emscripten tests in a headless browser. To do this we will first move to the tests directory
212
223
213
224
214
225
``` bash
215
226
cd ./unittests/CppInterOp/
216
227
```
217
228
218
- We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this on MacOS execute the following
229
+ We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this for Chrome and Firefox on MacOS execute the following
219
230
220
231
``` bash
221
232
wget " https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
@@ -242,6 +253,19 @@ echo "Running DynamicLibraryManagerTests in Google Chrome"
242
253
emrun --browser=" Google Chrome" --kill_exit --timeout 60 --browser-args=" --headless --no-sandbox" DynamicLibraryManagerTests.html
243
254
```
244
255
256
+ To run tests in Safari you can make use of safaridriver. How to enable this will depend on
257
+ your MacOS operating system, and is best to consult [ safaridriver] ( https://developer.apple.com/documentation/webkit/testing-with-webdriver-in-safari ) . You will also need to install the Selenium
258
+ python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
259
+
260
+ ``` bash
261
+ echo " Running CppInterOpTests in Safari"
262
+ emrun --no_browser --kill_exit --timeout 60 --browser-args=" --headless --no-sandbox" CppInterOpTests.html &
263
+ python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
264
+ echo " Running DynamicLibraryManagerTests in Safari"
265
+ emrun --no_browser --kill_exit --timeout 60 --browser-args=" --headless --no-sandbox" DynamicLibraryManagerTests.html &
266
+ python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
267
+ ```
268
+
245
269
To do this on Ubuntu x86 execute the following
246
270
247
271
``` bash
@@ -283,6 +307,26 @@ echo "Running DynamicLibraryManagerTests in Firefox"
283
307
emrun --browser=" firefox" --kill_exit --timeout 60 --browser-args=" --headless" DynamicLibraryManagerTests.html
284
308
```
285
309
310
+ To do this on Windows x86 execute the following
311
+
312
+ ``` powershell
313
+ Invoke-WebRequest -Uri "https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/1411573/chrome-win.zip" -OutFile "$PWD\chrome-win.zip" -Verbose
314
+ Expand-Archive -Path "$PWD\chrome-win.zip" -DestinationPath "$PWD" -Force -Verbose
315
+ Invoke-WebRequest -Uri "https://download.mozilla.org/?product=firefox-latest-ssl&os=win64&lang=en-US" -OutFile "firefox-setup.exe" -Verbose
316
+ & "C:\Program Files\7-Zip\7z.exe" x "firefox-setup.exe"
317
+ $env:PATH="$PWD\core;$PWD\chrome-win;$env:PATH"
318
+ echo "PATH=$env:PATH"
319
+ echo "PATH=$env:PATH" >> $env:GITHUB_ENV
320
+ echo "Running CppInterOpTests in Firefox"
321
+ emrun.bat --browser="firefox.exe" --kill_exit --timeout 60 --browser-args="--headless" CppInterOpTests.html
322
+ echo "Running DynamicLibraryManagerTests in Firefox"
323
+ emrun.bat --browser="firefox.exe" --kill_exit --timeout 60 --browser-args="--headless" DynamicLibraryManagerTests.html
324
+ echo "Running CppInterOpTests in Chromium"
325
+ emrun.bat --browser="chrome.exe" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
326
+ echo "Running DynamicLibraryManagerTests in Chromium"
327
+ emrun.bat --browser="chrome.exe" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
328
+ ```
329
+
286
330
Assuming it passes all test you can install by executing the following
287
331
288
332
``` bash
@@ -293,12 +337,13 @@ emmake make -j $(nproc --all) install
293
337
## Xeus-cpp-lite Wasm Build Instructions
294
338
295
339
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
296
- the CppInterOp build folder, you can build the wasm version of xeus-cpp by executing (replace $ LLVM_VERSION with the version
340
+ the CppInterOp build folder, you can build the wasm version of xeus-cpp by executing (replace LLVM_VERSION with the version
297
341
of llvm you are building against)
298
342
299
343
``` bash
300
344
cd ../..
301
345
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
346
+ export LLVM_VERSION=20
302
347
cd ./xeus-cpp
303
348
mkdir build
304
349
cd build
@@ -308,29 +353,23 @@ emcmake cmake \
308
353
-DCMAKE_INSTALL_PREFIX=$PREFIX \
309
354
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
310
355
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
311
- -DXEUS_CPP_RESOURCE_DIR=$LLVM_BUILD_DIR /lib/clang/$LLVM_VERSION \
356
+ -DXEUS_CPP_RESOURCE_DIR=" $LLVM_BUILD_DIR /lib/clang/$LLVM_VERSION " \
312
357
-DSYSROOT_PATH=$SYSROOT_PATH \
313
358
..
314
359
emmake make -j $( nproc --all) install
315
360
```
316
361
317
- To build Jupyter Lite website with this kernel locally that you can use for testing execute the following
362
+ To build and test Jupyter Lite with this kernel locally you can execute the following
318
363
319
364
``` bash
320
365
cd ../..
321
366
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyterlite-xeus jupyter_server jupyterlab notebook python-libarchive-c -c conda-forge
322
367
micromamba activate xeus-lite-host
323
- jupyter lite build --XeusAddon.prefix=$PREFIX \
368
+ jupyter lite serve --XeusAddon.prefix=$PREFIX \
324
369
--contents xeus-cpp/notebooks/xeus-cpp-lite-demo.ipynb \
325
370
--contents xeus-cpp/notebooks/smallpt.ipynb \
326
371
--contents xeus-cpp/notebooks/images/marie.png \
327
372
--contents xeus-cpp/notebooks/audio/audio.wav \
328
373
--XeusAddon.mounts=" $PREFIX /share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
329
374
--XeusAddon.mounts=" $PREFIX /etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d"
330
375
```
331
-
332
- Once the Jupyter Lite site has built you can test the website locally by executing
333
-
334
- ``` bash
335
- jupyter lite serve --XeusAddon.prefix=$PREFIX
336
- ```
0 commit comments