-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (196 loc) · 7.49 KB
/
ci.yml
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
188
189
190
191
192
193
194
195
196
197
198
name: CI
on:
push:
branches:
- main
- github-actions*
pull_request:
jobs:
test-on-pkru-enabled-host:
runs-on: self-hosted
continue-on-error: ${{ matrix.ia2-tracer == 'ON' }}
strategy:
fail-fast: true
matrix:
build-type: [Release, Debug]
c_compiler: [clang, gcc]
linker: [lld, bfd]
ia2-debug: [ON, OFF]
ia2-tracer: [ON, OFF]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Build
run: |
LLVM_DIR=`llvm-config --cmakedir`
Clang_DIR=`realpath $LLVM_DIR/../clang`
rm -rf build
mkdir build
pushd build
cmake .. \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_FLAGS="-fuse-ld=${{ matrix.linker }}" \
-DClang_DIR=$Clang_DIR \
-DLLVM_DIR=$LLVM_DIR \
-DLLVM_EXTERNAL_LIT=$HOME/.local/bin/lit \
-DIA2_DEBUG=${{ matrix.ia2-debug }} \
-DIA2_TRACER=${{ matrix.ia2-tracer }} \
-G Ninja
ninja
popd
- name: Check
run: |
pushd build
ninja -v check
popd
build-nginx:
runs-on: self-hosted
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Build nginx
run: |
LLVM_DIR=`llvm-config --cmakedir`
Clang_DIR=`realpath $LLVM_DIR/../clang`
pushd external/nginx
IA2_CMAKE_FLAGS="
-DCMAKE_BUILD_TYPE=Release
-DClang_DIR=$Clang_DIR
-DLLVM_DIR=$LLVM_DIR" \
./reconfigure
pushd build/nginx
make
popd
popd
aarch64-wip-test:
runs-on: ubuntu-latest
steps:
- name: Install dep packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: |
gcc-aarch64-linux-gnu
g++-aarch64-linux-gnu
libc6-arm64-cross
libc6-dev-arm64-cross
clang-15
pkg-config
cmake
ninja-build
llvm-15-dev
libclang-15-dev
zlib1g-dev
libcapstone-dev
version: 1.0 # version of cache to load
- name: Check out code
uses: actions/checkout@v4
- name: Cache built QEMU
id: cache-qemu
uses: actions/cache@v4
with:
path: qemu/build
key: ${{ runner.os }}-qemu
- name: Check out QEMU
if: steps.cache-qemu.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: immunant/qemu
path: ${{ github.workspace }}/qemu
- name: Build QEMU
if: steps.cache-qemu.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}/qemu
run: ./build.sh
- name: Cache built Clang
id: cache-clang
uses: actions/cache@v4
with:
path: |
llvm-project/build/bin
llvm-project/build/lib/clang
key: ${{ runner.os }}-clang-2
- name: Cache built runtime libraries
id: cache-rtlibs
uses: actions/cache@v4
with:
path: |
build-rtlibs/compiler-rt/lib/linux
build-rtlibs/lib
build-rtlibs/include
key: ${{ runner.os }}-rtlibs
# cloning llvm is required if we need to build rtlibs, but the cached clang would already be in the directory that git wants to create
- name: Move cached clang out of the way of git clone
if: steps.cache-clang.outputs.cache-hit == 'true' && steps.cache-rtlibs.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}
run: |
mv llvm-project llvm-project-built
# if we need to build either clang or rtlibs, clone our LLVM fork
- name: Check out LLVM
if: steps.cache-clang.outputs.cache-hit != 'true' || steps.cache-rtlibs.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: immunant/llvm-project
ref: fw/instrument-llvm-ir
path: ${{ github.workspace }}/llvm-project
- name: Build Clang
if: steps.cache-clang.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}/llvm-project
run: |
# first free up space used by unnecessary host tool cache to make room to build clang
df -h /
cd /opt
find . -maxdepth 1 -mindepth 1 '!' -path ./containerd '!' -path ./actionarchivecache \
'!' -path ./runner '!' -path ./runner-cache -exec rm -rf '{}' ';'
df -h /
cd -
./build.sh
# free up space used by libs; our desired clang binary statically links them
rm -rf build/lib/*.a
# if clang was cached, move it into the git tree to the same location as it would be built
- name: Move cached Clang
if: steps.cache-clang.outputs.cache-hit == 'true' && steps.cache-rtlibs.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}
run: |
mkdir -p llvm-project
mv llvm-project-built/* llvm-project/
- name: Build runtime libraries
if: steps.cache-rtlibs.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}/llvm-project
run: |
./cross-build-rtlibs.sh
mv build-rtlibs ../
# move rtlibs into the git tree to where IA2 build expects them
- name: Move cached runtime libraries
working-directory: ${{ github.workspace }}/llvm-project
run: |
mv ../build-rtlibs ./
- name: Test ARM build
run: |
LLVM_DIR=`llvm-config-15 --cmakedir`
Clang_DIR=`realpath $LLVM_DIR/../clang`
mkdir build
pushd build
rtlibs_dir="$(pwd)/../llvm-project/build-rtlibs"
cross_link_flags="-B${rtlibs_dir}/compiler-rt/lib/linux -L${rtlibs_dir}/lib \
--rtlib=compiler-rt --unwindlib=libunwind"
cross_flags="-isystem /usr/aarch64-linux-gnu/include --gcc-toolchain=/usr \
-march=armv8.5-a+memtag -ffixed-x18 --rtlib=compiler-rt --stdlib=libc++ \
-I${rtlibs_dir}/include/c++/v1"
export LDFLAGS="-L/usr/aarch64-linux-gnu/lib"
cmake .. \
-DCMAKE_CROSSCOMPILING_EMULATOR=${{ github.workspace }}/qemu/build/qemu-aarch64 \
-DCMAKE_TOOLCHAIN_FILE=../cmake/aarch64-toolchain.cmake \
-DCMAKE_C_COMPILER=`pwd`/../llvm-project/build/bin/clang-19 \
-DCMAKE_CXX_COMPILER=`pwd`/../llvm-project/build/bin/clang-19 \
-DCMAKE_OBJCOPY=/usr/bin/llvm-objcopy-15 \
-DCMAKE_C_FLAGS="$cross_flags" \
-DCMAKE_CXX_FLAGS="$cross_flags" \
-DCMAKE_EXE_LINKER_FLAGS="$cross_link_flags -lm -Wl,-rpath-link,${rtlibs_dir}/lib" \
-DCMAKE_SHARED_LINKER_FLAGS="$cross_link_flags -Wl,-rpath,${rtlibs_dir}/lib" \
-DClang_DIR=$Clang_DIR \
-DCLANG_EXE=`which clang-15` \
-DLLVM_DIR=$LLVM_DIR \
-G Ninja
ninja -v check
popd