Skip to content

Commit d89d71e

Browse files
authored
Partially fix Emscripten ci on main (fixes osx job which fixes deployment, but Windows still broken) (#919)
Fix Emscripten ci on main
1 parent fb745ea commit d89d71e

5 files changed

Lines changed: 57 additions & 17 deletions

File tree

.github/actions/Build_and_Test_CppInterOp/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ runs:
185185
cmake -DCMAKE_BUILD_TYPE=Release \
186186
-DLLVM_DIR=$NATIVE_LLVM_BUILD_DIR/lib/cmake/llvm \
187187
-DCPPINTEROP_ENABLE_TESTING=OFF \
188+
-DCMAKE_CXX_STANDARD=17 \
189+
-DLLVM_ENABLE_WERROR=On \
188190
-DCPPINTEROP_BUILD_TABLEGEN_ONLY=ON \
189191
../
190192
cmake --build . --target cppinterop-tblgen -j ${{ env.ncpus }}
@@ -488,6 +490,7 @@ runs:
488490
cmake -DCMAKE_BUILD_TYPE=Release `
489491
-DLLVM_DIR="$env:NATIVE_LLVM_BUILD_DIR\lib\cmake\llvm" `
490492
-DCPPINTEROP_ENABLE_TESTING=OFF `
493+
-DCMAKE_CXX_STANDARD=17 -DLLVM_ENABLE_WERROR=On `
491494
-DCPPINTEROP_BUILD_TABLEGEN_ONLY=ON `
492495
..\
493496
cmake --build . --target cppinterop-tblgen -j ${{ env.ncpus }}

.github/workflows/emscripten.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ jobs:
210210
EMCC_CFLAGS="-fwasm-exceptions" emmake ninja libclang clangInterpreter clangStaticAnalyzerCore
211211
fi
212212
cd ../
213-
rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".")
213+
rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name "." ! -name "native_build")
214214
if [[ "${cling_on}" == "ON" ]]; then
215215
cd ./llvm/
216216
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
@@ -343,7 +343,7 @@ jobs:
343343
$env:EMCC_CFLAGS=""
344344
}
345345
cd ..\
346-
rm -r -force $(find.exe . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".")
346+
rm -r -force $(find.exe . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name "." ! -name "native_build")
347347
if ( "${{ matrix.cling }}" -imatch "On" )
348348
{
349349
cd .\llvm\

Emscripten-build-instructions.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ mkdir native_build
7575
cd native_build
7676
cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release ../llvm/
7777
cmake --build . --target llvm-tblgen clang-tblgen --parallel $(nproc --all)
78-
export NATIVE_DIR=$PWD/bin/
78+
export NATIVE_LLVM_BUILD_DIR=$PWD
79+
export NATIVE_LLVM_BIN_DIR=$PWD/bin/
7980
cd ..
8081
mkdir build
8182
cd build
@@ -97,7 +98,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
9798
-DLLVM_BUILD_TOOLS=OFF \
9899
-DLLVM_ENABLE_LIBPFM=OFF \
99100
-DCLANG_BUILD_TOOLS=OFF \
100-
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_DIR \
101+
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_LLVM_BIN_DIR \
101102
-DCMAKE_C_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" \
102103
-DCMAKE_CXX_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" \
103104
-DLLVM_ENABLE_LTO=Full \
@@ -113,7 +114,8 @@ cd native_build
113114
cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release -G Ninja ../llvm/
114115
cmake --build . --target llvm-tblgen clang-tblgen --parallel $(nproc --all)
115116
$env:PWD_DIR= $PWD.Path
116-
$env:NATIVE_DIR="$env:PWD_DIR/bin/"
117+
$env:NATIVE_LLVM_BUILD_DIR="$env:PWD_DIR"
118+
$env:NATIVE_LLVM_BIN_DIR="$env:PWD_DIR/bin/"
117119
cd ..
118120
mkdir build
119121
cd build
@@ -135,7 +137,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
135137
-DLLVM_BUILD_TOOLS=OFF `
136138
-DLLVM_ENABLE_LIBPFM=OFF `
137139
-DCLANG_BUILD_TOOLS=OFF `
138-
-DLLVM_NATIVE_TOOL_DIR="$env:NATIVE_DIR" `
140+
-DLLVM_NATIVE_TOOL_DIR="$env:NATIVE_LLVM_BIN_DIR" `
139141
-G Ninja `
140142
-DCMAKE_C_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
141143
-DCMAKE_CXX_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
@@ -184,7 +186,42 @@ $env:CMAKE_PREFIX_PATH=$env:PREFIX
184186
$env:CMAKE_SYSTEM_PREFIX_PATH=$env:PREFIX
185187
```
186188

187-
on Windows. Now to build and test your Emscripten build of CppInterOp using node on Linux and osx execute the following
189+
on Windows. efore building the Emscripten version of CppInterOp, we need
190+
to build ``cppinterop-tblgen`` natively. This tool generates ``.inc`` files
191+
from ``.td`` definitions and must run on the host (not under Emscripten).
192+
We use the native LLVM build from the earlier step since it has the required
193+
``libLLVMTableGen`` library.
194+
195+
On Linux and osx:
196+
197+
```bash
198+
mkdir -p native_cppinterop_build && cd native_cppinterop_build
199+
cmake -DCMAKE_BUILD_TYPE=Release \
200+
-DLLVM_DIR=$NATIVE_LLVM_BUILD_DIR/lib/cmake/llvm \
201+
-DCMAKE_CXX_STANDARD=17 \
202+
-DCPPINTEROP_BUILD_TABLEGEN_ONLY=ON \
203+
../
204+
cmake --build . --target cppinterop-tblgen -j $(nproc --all)
205+
export CPPINTEROP_TBLGEN_EXE=$(find $PWD -name cppinterop-tblgen -type f | head -1)
206+
cd ..
207+
```
208+
209+
On Windows:
210+
211+
```powershell
212+
mkdir native_cppinterop_build
213+
cd native_cppinterop_build
214+
cmake -DCMAKE_BUILD_TYPE=Release `
215+
-DLLVM_DIR="$env:NATIVE_LLVM_BUILD_DIR\lib\cmake\llvm" `
216+
-DCMAKE_CXX_STANDARD=17 `
217+
-DCPPINTEROP_BUILD_TABLEGEN_ONLY=ON `
218+
..\
219+
cmake --build . --target cppinterop-tblgen -j $(nproc --all)
220+
$env:CPPINTEROP_TBLGEN_EXE = (Get-ChildItem -Recurse -Filter "cppinterop-tblgen.exe" | Select-Object -First 1).FullName
221+
cd ..
222+
```
223+
224+
Now to build and test your Emscripten build of CppInterOp using node on Linux and osx execute the following
188225
(BUILD_SHARED_LIBS=ON is only needed if building xeus-cpp, as CppInterOp can be built as an Emscripten static library)
189226

190227
```bash
@@ -198,6 +235,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
198235
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
199236
-DCMAKE_INSTALL_PREFIX=$PREFIX \
200237
-DSYSROOT_PATH=$SYSROOT_PATH \
238+
-DCPPINTEROP_TABLEGEN_EXE=$CPPINTEROP_TBLGEN_EXE \
201239
../
202240
emmake make -j $(nproc --all) check-cppinterop
203241
```
@@ -216,6 +254,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
216254
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON `
217255
-DLLVM_ENABLE_WERROR=On `
218256
-DSYSROOT_PATH="$env:SYSROOT_PATH" `
257+
-DCPPINTEROP_TABLEGEN_EXE="$env:CPPINTEROP_TBLGEN_EXE" `
219258
..\
220259
emmake make -j $(nproc --all) check-cppinterop
221260
```

docs/Emscripten-build-instructions.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ and osx
9595
cd native_build
9696
cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release ../llvm/
9797
cmake --build . --target llvm-tblgen clang-tblgen --parallel $(nproc --all)
98-
export NATIVE_DIR=$PWD/bin/
98+
export NATIVE_LLVM_BUILD_DIR==$PWD
99+
export NATIVE_LLVM_BIN_DIR=$PWD/bin/
99100
cd ..
100101
mkdir build
101102
cd build
@@ -117,7 +118,7 @@ and osx
117118
-DLLVM_BUILD_TOOLS=OFF \
118119
-DLLVM_ENABLE_LIBPFM=OFF \
119120
-DCLANG_BUILD_TOOLS=OFF \
120-
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_DIR \
121+
-DLLVM_NATIVE_TOOL_DIR=$NATIVE_LLVM_BIN_DIR \
121122
-DCMAKE_C_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" \
122123
-DCMAKE_CXX_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" \
123124
-DLLVM_ENABLE_LTO=Full \
@@ -133,7 +134,8 @@ or executing
133134
cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release -G Ninja ../llvm/
134135
cmake --build . --target llvm-tblgen clang-tblgen --parallel $(nproc --all)
135136
$env:PWD_DIR= $PWD.Path
136-
$env:NATIVE_DIR="$env:PWD_DIR/bin/"
137+
$env:NATIVE_LLVM_BUILD_DIR=="$env:PWD_DIR"
138+
$env:NATIVE_LLVM_BIN_DIR=="$env:PWD_DIR/bin/"
137139
cd ..
138140
mkdir build
139141
cd build
@@ -155,7 +157,7 @@ or executing
155157
-DLLVM_BUILD_TOOLS=OFF `
156158
-DLLVM_ENABLE_LIBPFM=OFF `
157159
-DCLANG_BUILD_TOOLS=OFF `
158-
-DLLVM_NATIVE_TOOL_DIR="$env:NATIVE_DIR" `
160+
-DLLVM_NATIVE_TOOL_DIR="$env:NATIVE_BIN_DIR" `
159161
-G Ninja `
160162
-DCMAKE_C_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
161163
-DCMAKE_CXX_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
@@ -218,11 +220,10 @@ On Linux and osx:
218220

219221
.. code:: bash
220222
221-
cd ../CppInterOp/
222-
NATIVE_LLVM_BUILD_DIR=$(pwd)/../llvm-project/native_build
223223
mkdir -p native_cppinterop_build && cd native_cppinterop_build
224224
cmake -DCMAKE_BUILD_TYPE=Release \
225225
-DLLVM_DIR=$NATIVE_LLVM_BUILD_DIR/lib/cmake/llvm \
226+
-DCMAKE_CXX_STANDARD=17 \
226227
-DCPPINTEROP_BUILD_TABLEGEN_ONLY=ON \
227228
../
228229
cmake --build . --target cppinterop-tblgen -j $(nproc --all)
@@ -233,12 +234,11 @@ On Windows:
233234

234235
.. code:: powershell
235236
236-
cd ..\CppInterOp\
237-
$env:NATIVE_LLVM_BUILD_DIR="$env:PWD_DIR\llvm-project\native_build"
238237
mkdir native_cppinterop_build
239238
cd native_cppinterop_build
240239
cmake -DCMAKE_BUILD_TYPE=Release `
241240
-DLLVM_DIR="$env:NATIVE_LLVM_BUILD_DIR\lib\cmake\llvm" `
241+
-DCMAKE_CXX_STANDARD=17 `
242242
-DCPPINTEROP_BUILD_TABLEGEN_ONLY=ON `
243243
..\
244244
cmake --build . --target cppinterop-tblgen -j $(nproc --all)

utils/TableGen/TableGen.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ bool CppInterOpTableGenMain(raw_ostream& OS, const RecordKeeper& Records) {
4040
case GenCppInterOpDecl:
4141
EmitCppInterOpDecl(Records, OS);
4242
break;
43-
default:
44-
return true;
4543
}
4644
return false;
4745
}

0 commit comments

Comments
 (0)