|
Michel Lind |
de7e84 |
From 497649b03d28e429690b1b3c0eb6f1cde620ef7d Mon Sep 17 00:00:00 2001
|
|
Michel Lind |
de7e84 |
From: Song Liu <song@kernel.org>
|
|
Michel Lind |
de7e84 |
Date: Tue, 28 Jan 2025 17:13:31 -0800
|
|
Michel Lind |
de7e84 |
Subject: [PATCH 118/118] kpatch-build: lto: sed logic for --lto-obj-path in
|
|
Michel Lind |
de7e84 |
newer kernel
|
|
Michel Lind |
de7e84 |
|
|
Michel Lind |
de7e84 |
In newer kernel, the thinlto-cache-dir line is removed from Makefile.
|
|
Michel Lind |
de7e84 |
Therefore, we cannot use it to add theh --lto-obj-path option. Use
|
|
Michel Lind |
de7e84 |
a different sed logic for newer kernel.
|
|
Michel Lind |
de7e84 |
|
|
Michel Lind |
de7e84 |
Signed-off-by: Song Liu <song@kernel.org>
|
|
Michel Lind |
de7e84 |
---
|
|
Michel Lind |
de7e84 |
kpatch-build/kpatch-build | 8 +++++++-
|
|
Michel Lind |
de7e84 |
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
Michel Lind |
de7e84 |
|
|
Michel Lind |
de7e84 |
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
|
|
Michel Lind |
de7e84 |
index c284d77..a14fd48 100755
|
|
Michel Lind |
de7e84 |
--- a/kpatch-build/kpatch-build
|
|
Michel Lind |
de7e84 |
+++ b/kpatch-build/kpatch-build
|
|
Michel Lind |
de7e84 |
@@ -1244,7 +1244,13 @@ if [[ -n "$CONFIG_LTO_CLANG" ]]; then
|
|
Michel Lind |
de7e84 |
|
|
Michel Lind |
de7e84 |
# update Makefile so that ld.lld generate vmlinux.o.thinlto.o* files for vmlinux.o
|
|
Michel Lind |
de7e84 |
backup_kernel_file "Makefile"
|
|
Michel Lind |
de7e84 |
- sed -i "s/--thinlto-cache-dir=\$(extmod_prefix).thinlto-cache/--lto-obj-path=vmlinux.o.thinlto.o/g" "$KERNEL_SRCDIR"/Makefile
|
|
Michel Lind |
de7e84 |
+ # For older kernel (<=v6.9.4), replace the --thinlto-cache-dir line with --lto-obj-path=...
|
|
Michel Lind |
de7e84 |
+ # For newer kernel (>=v6.9.5), add the --lto-obj-path=... line after CONFIG_LTO_CLANG_THIN
|
|
Michel Lind |
de7e84 |
+ if grep -q thinlto-cache-dir "$KERNEL_SRCDIR"/Makefile ; then
|
|
Michel Lind |
de7e84 |
+ sed -i "s/--thinlto-cache-dir=\$(extmod_prefix).thinlto-cache/--lto-obj-path=vmlinux.o.thinlto.o/g" "$KERNEL_SRCDIR"/Makefile
|
|
Michel Lind |
de7e84 |
+ else
|
|
Michel Lind |
de7e84 |
+ sed -i "/CONFIG_LTO_CLANG_THIN/a KBUILD_LDFLAGS += --lto-obj-path=vmlinux.o.thinlto.o" "$KERNEL_SRCDIR"/Makefile
|
|
Michel Lind |
de7e84 |
+ fi
|
|
Michel Lind |
de7e84 |
|
|
Michel Lind |
de7e84 |
# update scripts/Makefile.build so that ld.lld generate XX.o.thinlto.o* files for modules
|
|
Michel Lind |
de7e84 |
backup_kernel_file "scripts/Makefile.build"
|
|
Michel Lind |
de7e84 |
--
|
|
Michel Lind |
de7e84 |
2.48.1
|
|
Michel Lind |
de7e84 |
|