@@ -63,9 +63,8 @@ On Windows execute the following
6363``` powershell
6464cd .\llvm-project\
6565cp -r ..\patches\llvm\emscripten-clang20*
66- cp -r ..\patches\llvm\Windows-emscripten-clang20*
67- git apply -v Windows-emscripten-clang20-1-CrossCompile.patch
6866git apply -v emscripten-clang20-2-shift-temporary-files-to-tmp-dir.patch
67+ git apply -v emscripten-clang20-3-enable_exception_handling.patch
6968```
7069
7170We are now in a position to build an emscripten build of llvm by executing the following on Linux
@@ -81,7 +80,6 @@ mkdir build
8180cd build
8281emcmake cmake -DCMAKE_BUILD_TYPE=Release \
8382 -DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten \
84- -DLLVM_ENABLE_ASSERTIONS=ON \
8583 -DLLVM_TARGETS_TO_BUILD=" WebAssembly" \
8684 -DLLVM_ENABLE_LIBEDIT=OFF \
8785 -DLLVM_ENABLE_PROJECTS=" clang;lld" \
@@ -99,6 +97,9 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
9997 -DLLVM_ENABLE_LIBPFM=OFF \
10098 -DCLANG_BUILD_TOOLS=OFF \
10199 -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 \
102103 ../llvm
103104emmake make libclang -j $( nproc --all)
104105emmake make clangInterpreter clangStaticAnalyzerCore -j $( nproc --all)
@@ -108,11 +109,17 @@ emmake make lldWasm -j $(nproc --all)
108109or executing
109110
110111``` 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 ..
111119mkdir build
112120cd build
113121emcmake cmake -DCMAKE_BUILD_TYPE=Release `
114122 -DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten `
115- -DLLVM_ENABLE_ASSERTIONS=ON `
116123 -DLLVM_TARGETS_TO_BUILD="WebAssembly" `
117124 -DLLVM_ENABLE_LIBEDIT=OFF `
118125 -DLLVM_ENABLE_PROJECTS="clang;lld" `
@@ -129,7 +136,11 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
129136 -DLLVM_BUILD_TOOLS=OFF `
130137 -DLLVM_ENABLE_LIBPFM=OFF `
131138 -DCLANG_BUILD_TOOLS=OFF `
139+ -DLLVM_NATIVE_TOOL_DIR="$env:NATIVE_DIR" `
132140 -G Ninja `
141+ -DCMAKE_C_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
142+ -DCMAKE_CXX_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
143+ -DLLVM_ENABLE_LTO=Full `
133144 ..\llvm
134145emmake ninja libclang clangInterpreter clangStaticAnalyzerCore lldWasm
135146```
@@ -208,14 +219,14 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
208219 emmake make -j $(nproc --all) check-cppinterop
209220```
210221
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
212223
213224
214225``` bash
215226 cd ./unittests/CppInterOp/
216227```
217228
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
219230
220231``` bash
221232wget " 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"
242253emrun --browser=" Google Chrome" --kill_exit --timeout 60 --browser-args=" --headless --no-sandbox" DynamicLibraryManagerTests.html
243254```
244255
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+
245269To do this on Ubuntu x86 execute the following
246270
247271``` bash
@@ -283,6 +307,26 @@ echo "Running DynamicLibraryManagerTests in Firefox"
283307emrun --browser=" firefox" --kill_exit --timeout 60 --browser-args=" --headless" DynamicLibraryManagerTests.html
284308```
285309
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+
286330Assuming it passes all test you can install by executing the following
287331
288332``` bash
@@ -293,12 +337,13 @@ emmake make -j $(nproc --all) install
293337## Xeus-cpp-lite Wasm Build Instructions
294338
295339A 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
297341of llvm you are building against)
298342
299343``` bash
300344cd ../..
301345git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
346+ export LLVM_VERSION=20
302347cd ./xeus-cpp
303348mkdir build
304349cd build
@@ -308,29 +353,23 @@ emcmake cmake \
308353 -DCMAKE_INSTALL_PREFIX=$PREFIX \
309354 -DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
310355 -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 " \
312357 -DSYSROOT_PATH=$SYSROOT_PATH \
313358 ..
314359 emmake make -j $( nproc --all) install
315360```
316361
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
318363
319364``` bash
320365cd ../..
321366micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyterlite-xeus jupyter_server jupyterlab notebook python-libarchive-c -c conda-forge
322367micromamba activate xeus-lite-host
323- jupyter lite build --XeusAddon.prefix=$PREFIX \
368+ jupyter lite serve --XeusAddon.prefix=$PREFIX \
324369 --contents xeus-cpp/notebooks/xeus-cpp-lite-demo.ipynb \
325370 --contents xeus-cpp/notebooks/smallpt.ipynb \
326371 --contents xeus-cpp/notebooks/images/marie.png \
327372 --contents xeus-cpp/notebooks/audio/audio.wav \
328373 --XeusAddon.mounts=" $PREFIX /share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
329374 --XeusAddon.mounts=" $PREFIX /etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d"
330375```
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