Debian Codegraph @

vmtest/patches/5.15-kbuild-Unify-options-for-BTF-generation-for-vmlinux.patch

raw
1 From 0baced0e0938f2895ceba54038eaf15ed91032e7 Mon Sep 17 00:00:00 2001
2 Message-Id: <0baced0e0938f2895ceba54038eaf15ed91032e7.1676496740.git.osandov@osandov.com>
3 From: Jiri Olsa <[email protected]>
4 Date: Sun, 4 Sep 2022 15:19:00 +0200
5 Subject: [PATCH] kbuild: Unify options for BTF generation for vmlinux and
6 modules
7
8 commit e27f05147bff21408c1b8410ad8e90cd286e7952 upstream.
9
10 Using new PAHOLE_FLAGS variable to pass extra arguments to
11 pahole for both vmlinux and modules BTF data generation.
12
13 Adding new scripts/pahole-flags.sh script that detect and
14 prints pahole options.
15
16 [ fixed issues found by kernel test robot ]
17
18 Signed-off-by: Jiri Olsa <[email protected]>
19 Signed-off-by: Andrii Nakryiko <[email protected]>
20 Acked-by: Andrii Nakryiko <[email protected]>
21 Link: https://lore.kernel.org/bpf/[email protected]
22 Signed-off-by: Greg Kroah-Hartman <[email protected]>
23 [Omar: fold in "kbuild: fix up permissions on scripts/pahole-flags.sh"]
24 Signed-off-by: Omar Sandoval <[email protected]>
25 ---
26 Makefile | 3 +++
27 scripts/Makefile.modfinal | 2 +-
28 scripts/link-vmlinux.sh | 11 +----------
29 scripts/pahole-flags.sh | 20 ++++++++++++++++++++
30 4 files changed, 25 insertions(+), 11 deletions(-)
31 create mode 100755 scripts/pahole-flags.sh
32
33 diff --git a/Makefile b/Makefile
34 index 9142dbf41f0d..21316686af35 100644
35 --- a/Makefile
36 +++ b/Makefile
37 @@ -480,6 +480,8 @@ LZ4 = lz4c
38 XZ = xz
39 ZSTD = zstd
40
41 +PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh)
42 +
43 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
44 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
45 NOSTDINC_FLAGS :=
46 @@ -534,6 +536,7 @@ export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
47 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
48 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
49 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
50 +export PAHOLE_FLAGS
51
52 # Files to ignore in find ... statements
53
54 diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal
55 index ff805777431c..ce9661d968a3 100644
56 --- a/scripts/Makefile.modfinal
57 +++ b/scripts/Makefile.modfinal
58 @@ -40,7 +40,7 @@ quiet_cmd_ld_ko_o = LD [M] $@
59 quiet_cmd_btf_ko = BTF [M] $@
60 cmd_btf_ko = \
61 if [ -f vmlinux ]; then \
62 - LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J --btf_base vmlinux $@; \
63 + LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \
64 else \
65 printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
66 fi;
67 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
68 index 3819a461465d..57ef6accbb40 100755
69 --- a/scripts/link-vmlinux.sh
70 +++ b/scripts/link-vmlinux.sh
71 @@ -211,7 +211,6 @@ vmlinux_link()
72 gen_btf()
73 {
74 local pahole_ver
75 - local extra_paholeopt=
76
77 if ! [ -x "$(command -v ${PAHOLE})" ]; then
78 echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available"
79 @@ -226,16 +225,8 @@ gen_btf()
80
81 vmlinux_link ${1}
82
83 - if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
84 - # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
85 - extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
86 - fi
87 - if [ "${pahole_ver}" -ge "121" ]; then
88 - extra_paholeopt="${extra_paholeopt} --btf_gen_floats"
89 - fi
90 -
91 info "BTF" ${2}
92 - LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${extra_paholeopt} ${1}
93 + LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${PAHOLE_FLAGS} ${1}
94
95 # Create ${2} which contains just .BTF section but no symbols. Add
96 # SHF_ALLOC because .BTF will be part of the vmlinux image. --strip-all
97 diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
98 new file mode 100755
99 index 000000000000..e6093adf4c06
100 --- /dev/null
101 +++ b/scripts/pahole-flags.sh
102 @@ -0,0 +1,20 @@
103 +#!/bin/sh
104 +# SPDX-License-Identifier: GPL-2.0
105 +
106 +extra_paholeopt=
107 +
108 +if ! [ -x "$(command -v ${PAHOLE})" ]; then
109 + exit 0
110 +fi
111 +
112 +pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
113 +
114 +if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
115 + # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
116 + extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
117 +fi
118 +if [ "${pahole_ver}" -ge "121" ]; then
119 + extra_paholeopt="${extra_paholeopt} --btf_gen_floats"
120 +fi
121 +
122 +echo ${extra_paholeopt}
123 --
124 2.30.2
125