-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathaction.yml
More file actions
187 lines (172 loc) · 7.89 KB
/
Copy pathaction.yml
File metadata and controls
187 lines (172 loc) · 7.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: 'Builds LLVM for WebAssembly'
description: 'This action builds LLVM for WebAssembly targets via emscripten'
inputs:
cache-hit:
required: true
runs:
using: composite
steps:
- name: Build LLVM/Cling on Unix systems if the cache is invalid (emscripten)
if: ${{ inputs.cache-hit != 'true' && runner.os != 'Windows' }}
shell: bash
run: |
./emsdk/emsdk activate ${{ env.EMSDK_VER }}
source ./emsdk/emsdk_env.sh
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
git clone https://github.com/root-project/cling.git
(cd cling && git checkout tags/v${{ matrix.cling-version }} \
&& git apply -v ../patches/llvm/cling1.2-LookupHelper.patch)
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git
fi
cd llvm-project
# Native tblgen bootstrap (host-side llvm-tblgen + clang-tblgen).
mkdir native_build
(cd native_build && \
cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release ../llvm/ && \
cmake --build . --target llvm-tblgen clang-tblgen --parallel $(nproc --all))
export NATIVE_DIR=$PWD/native_build/bin/
# Apply repl-only emscripten patches; cling has its own patch flow above.
if [[ "${cling_on}" != "ON" ]]; then
rt='${{ matrix.clang-runtime }}'
if [[ "$rt" =~ ^(19|20|21|22)$ ]]; then
git apply -v ../patches/llvm/emscripten-clang${rt}-*.patch
echo "Applied emscripten-clang${rt}-*.patch"
fi
fi
common_flags=(
-G Ninja
-DCMAKE_BUILD_TYPE=Release
-DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten
-DLLVM_TARGETS_TO_BUILD="${{ env.LLVM_TARGETS_TO_BUILD }}"
-DLLVM_ENABLE_PROJECTS="${{ env.LLVM_ENABLE_PROJECTS }}"
-DLLVM_NATIVE_TOOL_DIR="$NATIVE_DIR"
-DLLVM_ENABLE_LIBEDIT=OFF
-DLLVM_ENABLE_ZSTD=OFF
-DLLVM_ENABLE_LIBXML2=OFF
-DLLVM_ENABLE_LIBPFM=OFF
-DLLVM_ENABLE_THREADS=OFF
-DLLVM_INCLUDE_BENCHMARKS=OFF
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_BUILD_TOOLS=OFF
-DCLANG_BUILD_TOOLS=OFF
-DCLANG_ENABLE_STATIC_ANALYZER=OFF
-DCLANG_ENABLE_ARCMT=OFF
-DCLANG_ENABLE_BOOTSTRAP=OFF
-DCMAKE_CXX_FLAGS=-Dwait4=__syscall_wait4
"-DCMAKE_C_FLAGS_RELEASE=-Oz -g0 -DNDEBUG"
"-DCMAKE_CXX_FLAGS_RELEASE=-Oz -g0 -DNDEBUG"
-DLLVM_ENABLE_LTO=Full
)
if [[ "${cling_on}" == "ON" ]]; then
extra_flags=(-DLLVM_EXTERNAL_PROJECTS=cling -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling)
targets=(clang cling lld gtest_main)
else
extra_flags=()
targets=(libclang clangInterpreter clangStaticAnalyzerCore)
fi
mkdir build && cd build
emcmake cmake "${common_flags[@]}" "${extra_flags[@]}" ../llvm
EMCC_CFLAGS="-fwasm-exceptions" emmake ninja "${targets[@]}"
cd ..
# Trim source trees so the cache stays small. Cling rows additionally
# need llvm/{utils} for runtime tablegen lookups.
rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name "." ! -name "native_build")
keep=('!' -name include '!' -name lib '!' -name cmake '!' -name .)
if [[ "${cling_on}" == "ON" ]]; then
keep=('!' -name include '!' -name lib '!' -name cmake '!' -name utils '!' -name .)
fi
for d in llvm clang; do
(cd "$d" && rm -rf $(find . -maxdepth 1 "${keep[@]}"))
done
- name: Build LLVM/Cling on Windows systems if the cache is invalid (emscripten)
if: ${{ inputs.cache-hit != 'true' && runner.os == 'Windows' }}
shell: powershell
run: |
.\emsdk\emsdk activate ${{ env.EMSDK_VER }}
.\emsdk\emsdk_env.ps1
$cling_on = "${{ matrix.cling }}" -imatch "On"
if ( $cling_on ) {
git clone https://github.com/root-project/cling.git
Push-Location ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
Pop-Location
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
$env:CLING_DIR = Join-Path $PWD.Path "cling"
echo "CLING_DIR=$env:CLING_DIR"
} else {
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git
}
cd llvm-project
# Native tblgen bootstrap (host-side llvm-tblgen + clang-tblgen).
mkdir native_build | Out-Null
Push-Location native_build
cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release -G Ninja ../llvm/
cmake --build . --target llvm-tblgen clang-tblgen --parallel $(nproc --all)
$env:NATIVE_DIR = Join-Path $PWD.Path "bin"
Pop-Location
# Apply repl-only emscripten patches; cling has its own patch flow above.
if ( -not $cling_on ) {
$rt = "${{ matrix.clang-runtime }}"
if ( $rt -match "^(19|20|21|22)$" ) {
Get-ChildItem -Path "..\patches\llvm" -Filter "emscripten-clang${rt}-*.patch" | ForEach-Object {
git apply -v $_.FullName
}
echo "Applied emscripten-clang${rt}-*.patch"
}
}
$common_flags = @(
"-G", "Ninja"
"-DCMAKE_BUILD_TYPE=Release"
"-DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten"
"-DLLVM_TARGETS_TO_BUILD=${{ env.LLVM_TARGETS_TO_BUILD }}"
"-DLLVM_ENABLE_PROJECTS=${{ env.LLVM_ENABLE_PROJECTS }}"
"-DLLVM_NATIVE_TOOL_DIR=$env:NATIVE_DIR"
"-DLLVM_ENABLE_LIBEDIT=OFF"
"-DLLVM_ENABLE_ZSTD=OFF"
"-DLLVM_ENABLE_LIBXML2=OFF"
"-DLLVM_ENABLE_LIBPFM=OFF"
"-DLLVM_ENABLE_THREADS=OFF"
"-DLLVM_INCLUDE_BENCHMARKS=OFF"
"-DLLVM_INCLUDE_EXAMPLES=OFF"
"-DLLVM_INCLUDE_TESTS=OFF"
"-DLLVM_BUILD_TOOLS=OFF"
"-DCLANG_BUILD_TOOLS=OFF"
"-DCLANG_ENABLE_STATIC_ANALYZER=OFF"
"-DCLANG_ENABLE_ARCMT=OFF"
"-DCLANG_ENABLE_BOOTSTRAP=OFF"
"-DCMAKE_CXX_FLAGS=-Dwait4=__syscall_wait4"
"-DCMAKE_C_FLAGS_RELEASE=-Oz -g0 -DNDEBUG"
"-DCMAKE_CXX_FLAGS_RELEASE=-Oz -g0 -DNDEBUG"
"-DLLVM_ENABLE_LTO=Full"
)
if ( $cling_on ) {
$extra_flags = @("-DLLVM_EXTERNAL_PROJECTS=cling", "-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling")
$targets = @("clang", "cling", "lld", "gtest_main")
} else {
$extra_flags = @()
$targets = @("libclang", "clangInterpreter", "clangStaticAnalyzerCore")
}
mkdir build | Out-Null
cd build
emcmake cmake @common_flags @extra_flags ..\llvm
$env:EMCC_CFLAGS = "-fwasm-exceptions"
emmake ninja @targets
$env:EMCC_CFLAGS = ""
cd ..
# Trim source trees so the cache stays small. Cling rows additionally
# need llvm/{utils} for runtime tablegen lookups.
rm -r -force $(find.exe . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name "." ! -name "native_build")
$keep = @("!", "-name", "include", "!", "-name", "lib", "!", "-name", "cmake", "!", "-name", ".")
if ( $cling_on ) {
$keep = @("!", "-name", "include", "!", "-name", "lib", "!", "-name", "cmake", "!", "-name", "utils", "!", "-name", ".")
}
foreach ($d in @("llvm", "clang")) {
Push-Location $d
rm -r -force $(find.exe . -maxdepth 1 @keep)
Pop-Location
}