Skip to content

Commit 9213ab8

Browse files
committed
rust/CI: Adds ThinLTO builds to CI pipeline
Enables LTO for arm64 and x86_64 build in CI pipeline. This change introduces separate *.config files for arm64 which are based on current kernel-*.config files, with CONFIG_TLO* options applied. Since during LTO build some of the objects contain LLVM IR bitcode and binutils' size does not support such a format, .github/workflows/size.sh script filters out such files on reporting. Signed-off-by: Dariusz Sosnowski <[email protected]>
1 parent 75167a0 commit 9213ab8

File tree

6 files changed

+5935
-2
lines changed

6 files changed

+5935
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
output: [src] # [src, build]
1818
install: [rustup] # [rustup, standalone]
1919
sysroot: [common] # [common, custom]
20+
lto: [none] # [none, thin]
2021

2122
exclude:
2223
# arm 32-bit gcc not yet supported
@@ -34,6 +35,7 @@ jobs:
3435
# A few independent combinations to avoid exploding the matrix:
3536
# - The other option for `output`.
3637
# - Different releases for `rustc`.
38+
# - Explicitly enabling `lto` on platforms which support LTO.
3739
# - The other three (`install`, `sysroot`) combinations
3840
# (they are interrelated, so the cross-product needs to be tested)
3941
include:
@@ -44,6 +46,25 @@ jobs:
4446
output: build
4547
install: rustup
4648
sysroot: custom
49+
lto: none
50+
51+
- arch: arm64
52+
toolchain: llvm
53+
config: debug
54+
rustc: 1.55.0
55+
output: build
56+
install: rustup
57+
sysroot: custom
58+
lto: thin
59+
60+
- arch: arm64
61+
toolchain: llvm
62+
config: release
63+
rustc: 1.55.0
64+
output: build
65+
install: rustup
66+
sysroot: custom
67+
lto: thin
4768

4869
- arch: ppc64le
4970
toolchain: clang
@@ -52,6 +73,7 @@ jobs:
5273
output: build
5374
install: standalone
5475
sysroot: common
76+
lto: none
5577

5678
- arch: x86_64
5779
toolchain: llvm
@@ -60,6 +82,25 @@ jobs:
6082
output: build
6183
install: standalone
6284
sysroot: custom
85+
lto: none
86+
87+
- arch: x86_64
88+
toolchain: llvm
89+
config: debug
90+
rustc: 1.55.0
91+
output: src
92+
install: rustup
93+
sysroot: common
94+
lto: thin
95+
96+
- arch: x86_64
97+
toolchain: llvm
98+
config: release
99+
rustc: 1.55.0
100+
output: src
101+
install: rustup
102+
sysroot: common
103+
lto: thin
63104

64105
steps:
65106
# Setup: checkout
@@ -124,6 +165,12 @@ jobs:
124165
- if: matrix.toolchain == 'llvm'
125166
run: echo 'MAKE_TOOLCHAIN=LLVM=1' >> $GITHUB_ENV
126167

168+
# if arch is supported and ThinLTO is enabled, enable LLVM's integrated assembler
169+
- if: matrix.arch == 'arm64' && matrix.toolchain == 'llvm' && matrix.lto == 'thin'
170+
run: echo 'MAKE_LLVM_IAS=LLVM_IAS=1' >> $GITHUB_ENV
171+
- if: matrix.arch == 'x86_64' && matrix.toolchain == 'llvm' && matrix.lto == 'thin'
172+
run: echo 'MAKE_LLVM_IAS=LLVM_IAS=1' >> $GITHUB_ENV
173+
127174
- if: matrix.output == 'build'
128175
run: |
129176
echo 'MAKE_OUTPUT=O=build' >> $GITHUB_ENV
@@ -246,7 +293,10 @@ jobs:
246293
echo 'obj-m += rust_module_parameters_loadable_custom.o' >> samples/rust/Makefile
247294
248295
# Build
249-
- run: mv .github/workflows/kernel-${{ matrix.arch }}-${{ matrix.config }}.config .config
296+
- if: matrix.lto == 'none'
297+
run: mv .github/workflows/kernel-${{ matrix.arch }}-${{ matrix.config }}.config .config
298+
- if: matrix.lto == 'thin'
299+
run: mv .github/workflows/kernel-${{ matrix.arch }}-${{ matrix.config }}-thinlto.config .config
250300

251301
- if: matrix.output == 'build'
252302
run: |
@@ -389,7 +439,7 @@ jobs:
389439
${{ env.BUILD_DIR }}vmlinux \
390440
${{ env.BUILD_DIR }}${{ env.IMAGE_PATH }}
391441
392-
size \
442+
.github/workflows/size.sh \
393443
${{ env.BUILD_DIR }}samples/rust/*.o \
394444
${{ env.BUILD_DIR }}samples/rust/*.ko \
395445
${{ env.BUILD_DIR }}drivers/android/rust_binder.o \

0 commit comments

Comments
 (0)