Skip to content

Commit 125daf8

Browse files
committed
Fix Emscripten shared library size llvm 21
1 parent 3d3dc5e commit 125daf8

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

.github/workflows/emscripten.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ jobs:
329329
{
330330
git apply -v emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch
331331
git apply -v emscripten-clang21-2-enable_exception_handling.patch
332+
git apply -v emscripten-clang21-3-llvm-abi-annotation-remote.patch
332333
}
333334
cd build
334335
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
@@ -539,14 +540,14 @@ jobs:
539540
540541
emmake make -j ${{ env.ncpus }} check-cppinterop
541542
os="${{ matrix.os }}"
542-
#if [[ "${os}" != macos* ]] ; then
543-
# actual_size=$(stat -c%s "./lib/libclangCppInterOp.so")
544-
# max_size=$((40 * 1024 * 1024))
545-
# if [[ "$actual_size" -gt "$max_size" ]]; then
546-
# echo "Error: libclangCppInterOp.so is larger than 40 MB."
547-
# exit 1
548-
# fi
549-
#fi
543+
if [[ "${os}" != macos* ]] ; then
544+
actual_size=$(stat -c%s "./lib/libclangCppInterOp.so")
545+
max_size=$((40 * 1024 * 1024))
546+
if [[ "$actual_size" -gt "$max_size" ]]; then
547+
echo "Error: libclangCppInterOp.so is larger than 40 MB."
548+
exit 1
549+
fi
550+
fi
550551
cd ./unittests/CppInterOp/
551552
# Fresh install browsers, and run Emscripten tests in them
552553
# This is to match the Emscripten build instructions, where

Emscripten-build-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ cd .\llvm-project\
6565
cp -r ..\patches\llvm\emscripten-clang21*
6666
git apply -v emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch
6767
git apply -v emscripten-clang21-2-enable_exception_handling.patch
68+
git apply -v emscripten-clang21-3-llvm-abi-annotation-remote.patch
6869
```
6970

7071
We are now in a position to build an emscripten build of llvm by executing the following on Linux

docs/Emscripten-build-instructions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ On Windows execute the following
8484
cp -r ..\patches\llvm\emscripten-clang21*
8585
git apply -v emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch
8686
git apply -v emscripten-clang21-2-enable_exception_handling.patch
87+
git apply -v emscripten-clang21-3-llvm-abi-annotation-remote.patch
8788
8889
We are now in a position to build an emscripten build of llvm by executing the following on Linux
8990
and osx
@@ -429,4 +430,4 @@ and on Windows execute
429430
--contents xeus-cpp/notebooks/images/marie.png `
430431
--contents xeus-cpp/notebooks/audio/audio.wav `
431432
--XeusAddon.mounts="$env:PREFIX/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" `
432-
--XeusAddon.mounts="$env:PREFIX/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d"
433+
--XeusAddon.mounts="$env:PREFIX/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
2+
index 297d3e9b0..6aaa5d4e3 100644
3+
--- a/llvm/include/llvm/Support/Compiler.h
4+
+++ b/llvm/include/llvm/Support/Compiler.h
5+
@@ -202,10 +202,10 @@
6+
#define LLVM_EXPORT_TEMPLATE
7+
#define LLVM_ABI_EXPORT LLVM_ABI
8+
#elif defined(__MACH__) || defined(__WASM__) || defined(__EMSCRIPTEN__)
9+
-#define LLVM_ABI __attribute__((visibility("default")))
10+
+#define LLVM_ABI
11+
#define LLVM_TEMPLATE_ABI
12+
#define LLVM_EXPORT_TEMPLATE
13+
-#define LLVM_ABI_EXPORT LLVM_ABI
14+
+#define LLVM_ABI_EXPORT
15+
#endif
16+
#endif
17+
#endif

0 commit comments

Comments
 (0)