Debian Codegraph @

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

raw
1 From a1bc199b0aa9540632057d719b1c22879c1ec10f Mon Sep 17 00:00:00 2001
2 Message-Id: <a1bc199b0aa9540632057d719b1c22879c1ec10f.1685663408.git.osandov@osandov.com>
3 From: Jiri Olsa <[email protected]>
4 Date: Fri, 29 Oct 2021 14:57:29 +0200
5 Subject: [PATCH] kbuild: Unify options for BTF generation for vmlinux and
6 modules
7
8 Using new PAHOLE_FLAGS variable to pass extra arguments to
9 pahole for both vmlinux and modules BTF data generation.
10
11 Adding new scripts/pahole-flags.sh script that detect and
12 prints pahole options.
13
14 [ fixed issues found by kernel test robot ]
15
16 Signed-off-by: Jiri Olsa <[email protected]>
17 Signed-off-by: Andrii Nakryiko <[email protected]>
18 Acked-by: Andrii Nakryiko <[email protected]>
19 Link: https://lore.kernel.org/bpf/[email protected]
20 (cherry picked from commit 9741e07ece7c247dd65e1aa01e16b683f01c05a8)
21 [Omar: fix up context for RESOLVE_BTFIDS and --btf_gen_floats, remove
22 --btf_gen_floats from pahole-flags.sh, squash in 'exit 0' change from
23 merge commit fc02cb2b37fe]
24 Signed-off-by: Omar Sandoval <[email protected]>
25 ---
26 Makefile | 3 +++
27 scripts/Makefile.modfinal | 2 +-
28 scripts/link-vmlinux.sh | 8 +-------
29 scripts/pahole-flags.sh | 17 +++++++++++++++++
30 4 files changed, 22 insertions(+), 8 deletions(-)
31 create mode 100755 scripts/pahole-flags.sh
32
33 diff --git a/Makefile b/Makefile
34 index ff363cc6b11f..e728e4faa4bc 100644
35 --- a/Makefile
36 +++ b/Makefile
37 @@ -464,6 +464,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 @@ -517,6 +519,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 aef583f824dc..4212c576e10c 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 55bcfa85873c..cff7ef9a5773 100755
69 --- a/scripts/link-vmlinux.sh
70 +++ b/scripts/link-vmlinux.sh
71 @@ -140,7 +140,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 @@ -155,13 +154,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 -
88 info "BTF" ${2}
89 - LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${extra_paholeopt} ${1}
90 + LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${PAHOLE_FLAGS} ${1}
91
92 # Create ${2} which contains just .BTF section but no symbols. Add
93 # SHF_ALLOC because .BTF will be part of the vmlinux image. --strip-all
94 diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
95 new file mode 100755
96 index 000000000000..27445cb72974
97 --- /dev/null
98 +++ b/scripts/pahole-flags.sh
99 @@ -0,0 +1,17 @@
100 +#!/bin/sh
101 +# SPDX-License-Identifier: GPL-2.0
102 +
103 +extra_paholeopt=
104 +
105 +if ! [ -x "$(command -v ${PAHOLE})" ]; then
106 + exit 0
107 +fi
108 +
109 +pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
110 +
111 +if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
112 + # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
113 + extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
114 +fi
115 +
116 +echo ${extra_paholeopt}
117 --
118 2.40.1
119