-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_kernel.sh
More file actions
executable file
·68 lines (56 loc) · 1.73 KB
/
build_kernel.sh
File metadata and controls
executable file
·68 lines (56 loc) · 1.73 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
#!/usr/bin/env bash
set -euo pipefail
set -x
if [ -z "${DISABLE_CONTAINER_CHECK:-}" ]; then
./container.sh ./build_kernel.sh
exit 0
fi
clone()
{
./clone.sh \
linux \
https://github.com/torvalds/linux \
v6.17 \
patches/linux-include-linux-compiler-add-DEBUGGER-attribute-for-functions.patch
}
build()
{
export CC_NO_DEBUG_MACROS=1
pushd $(readlink -f linux)
rm -f .config
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig -j$(nproc)
# reduce number of timer interrupts
scripts/config --disable CONFIG_HZ_250
scripts/config --enable CONFIG_HZ_100
# nvme
scripts/config --enable BLK_DEV_NVME
# iommufd
# https://docs.kernel.org/driver-api/vfio.html#vfio-device-cdev
scripts/config --enable IOMMUFD
scripts/config --enable VFIO_DEVICE_CDEV
scripts/config --enable ARM_SMMU_V3_IOMMUFD
# speed up boot by disabling ftrace
scripts/config --disable CONFIG_FTRACE
# disable all modules
sed -i -e 's/=m$/=n/' .config
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- olddefconfig -j$(nproc)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- all -j$(nproc)
# compile commands
./scripts/clang-tools/gen_compile_commands.py
sed -i ./compile_commands.json \
-e 's/-femit-struct-debug-baseonly//' \
-e 's/-fconserve-stack//' \
-e 's/-fno-allow-store-data-races//' \
-e 's/-mabi=lp64//' \
-e 's/aarch64-linux-gnu-gcc/clang -target aarch64-pc-none-gnu -Wno-unknown-warning-option -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang/'
popd
unset CC_NO_DEBUG_MACROS
}
output()
{
mkdir -p out
rsync ./linux/arch/arm64/boot/Image.gz out/
}
clone
build
output