Skip to content

Commit d9f6630

Browse files
committed
Use EMCC_CFLAGS="-Oz" during Emscripten llvm build to reduce CppInterOp shared library size to 48Mb
1 parent 2585d0d commit d9f6630

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

.github/workflows/emscripten.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ jobs:
195195
-DCLANG_BUILD_TOOLS=OFF \
196196
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_DIR \
197197
../llvm
198-
emmake ninja clang cling lld gtest_main
198+
EMCC_CFLAGS="-Oz" emmake ninja clang cling lld gtest_main
199199
else
200200
# Apply patches
201201
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
@@ -226,7 +226,7 @@ jobs:
226226
-G Ninja \
227227
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_DIR \
228228
../llvm
229-
emmake ninja libclang clangInterpreter clangStaticAnalyzerCore lldWasm
229+
EMCC_CFLAGS="-Oz" emmake ninja libclang clangInterpreter clangStaticAnalyzerCore lldWasm
230230
fi
231231
cd ../
232232
rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".")
@@ -296,6 +296,7 @@ jobs:
296296
-DLLVM_ENABLE_LIBPFM=OFF `
297297
-DCLANG_BUILD_TOOLS=OFF `
298298
..\llvm
299+
$env:EMCC_CFLAGS="-Oz"
299300
emmake make clang cling lld gtest_main
300301
}
301302
else
@@ -337,6 +338,7 @@ jobs:
337338
-DCLANG_BUILD_TOOLS=OFF `
338339
-G Ninja `
339340
..\llvm
341+
$env:EMCC_CFLAGS="-Oz"
340342
emmake ninja libclang clangInterpreter clangStaticAnalyzerCore lldWasm
341343
}
342344
cd ..\

Emscripten-build-instructions.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
100100
-DCLANG_BUILD_TOOLS=OFF \
101101
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_DIR \
102102
../llvm
103-
emmake make libclang -j $(nproc --all)
104-
emmake make clangInterpreter clangStaticAnalyzerCore -j $(nproc --all)
105-
emmake make lldWasm -j $(nproc --all)
103+
EMCC_CFLAGS="-Oz" emmake make libclang -j $(nproc --all)
104+
EMCC_CFLAGS="-Oz" emmake make clangInterpreter clangStaticAnalyzerCore -j $(nproc --all)
105+
EMCC_CFLAGS="-Oz" emmake make lldWasm -j $(nproc --all)
106106
```
107107

108108
or executing
@@ -131,7 +131,9 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
131131
-DCLANG_BUILD_TOOLS=OFF `
132132
-G Ninja `
133133
..\llvm
134+
$env:EMCC_CFLAGS="-Oz"
134135
emmake ninja libclang clangInterpreter clangStaticAnalyzerCore lldWasm
136+
$env:EMCC_CFLAGS=""
135137
```
136138

137139
on Windows. Once this finishes building we need to take note of where we built our llvm build. This can be done by executing the following on Linux and osx

docs/Emscripten-build-instructions.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ and osx
120120
-DCLANG_BUILD_TOOLS=OFF \
121121
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_DIR \
122122
../llvm
123-
emmake make libclang -j $(nproc --all)
124-
emmake make clangInterpreter clangStaticAnalyzerCore -j $(nproc --all)
125-
emmake make lldWasm -j $(nproc --all)
123+
EMCC_CFLAGS="-Oz" emmake make libclang -j $(nproc --all)
124+
EMCC_CFLAGS="-Oz" emmake make clangInterpreter clangStaticAnalyzerCore -j $(nproc --all)
125+
EMCC_CFLAGS="-Oz" emmake make lldWasm -j $(nproc --all)
126126
127127
or executing
128128

@@ -151,7 +151,9 @@ or executing
151151
-DCLANG_BUILD_TOOLS=OFF `
152152
-G Ninja `
153153
..\llvm
154+
$env:EMCC_CFLAGS="-Oz"
154155
emmake ninja libclang clangInterpreter clangStaticAnalyzerCore lldWasm
156+
$env:EMCC_CFLAGS=""
155157
156158
on Windows. Once this finishes building we need to take note of where we built our llvm build.
157159
This can be done by executing the following on Linux and osx

0 commit comments

Comments
 (0)