scripts/gen-btf.sh: Use CONFIG_SHELL for execution
Ihor Solodrai
reviewerPATCH 1/1 scripts/gen-btf.sh: Use CONFIG_SHELL for execution
According to the docs [1], kernel build scripts should be executed via CONFIG_SHELL, which is sh by default.
Fixup gen-btf.sh to be runnable with sh, and use CONFIG_SHELL at every invocation site.
See relevant discussion for context [2].
[1] https://docs.kernel.org/kbuild/makefiles.html#script-invocation
[2] https://lore.kernel.org/bpf/CAADnVQ+dxmSNoJAGb6xV89ffUCKXe5CJXovXZt22nv5iYFV5mw@mail.gmail.com/
--- scripts/Makefile.modfinal | 2 +- scripts/gen-btf.sh | 8 ++++---- scripts/link-vmlinux.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
scripts/Makefile.modfinal +1 -1
@@ -43,7 +43,7 @@ quiet_cmd_btf_ko = BTF [M] $@ if [ ! -f $(objtree)/vmlinux ]; then \ printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \ else \ - $(srctree)/scripts/gen-btf.sh --btf_base $(objtree)/vmlinux $@; \ + $(CONFIG_SHELL) $(srctree)/scripts/gen-btf.sh --btf_base $(objtree)/vmlinux $@; \ fi; # Same as newer-prereqs, but allows to exclude specified extra dependencies
scripts/gen-btf.sh +4 -4
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2025 Meta Platforms, Inc. and affiliates. #
@@ -81,7 +81,7 @@ gen_btf_data() gen_btf_o() { - local btf_data=${ELF_FILE}.btf.o + btf_data=${ELF_FILE}.btf.o # Create ${btf_data} which contains just .BTF section but no symbols. Add # SHF_ALLOC because .BTF will be part of the vmlinux image. --strip-all
@@ -107,11 +107,11 @@ embed_btf_data() ${OBJCOPY} --add-section .BTF=${ELF_FILE}.BTF ${ELF_FILE} # a module might not have a .BTF_ids or .BTF.base section - local btf_base="${ELF_FILE}.BTF.base" + btf_base="${ELF_FILE}.BTF.base" if [ -f "${btf_base}" ]; then ${OBJCOPY} --add-section .BTF.base=${btf_base} ${ELF_FILE} fi - local btf_ids="${ELF_FILE}.BTF_ids" + btf_ids="${ELF_FILE}.BTF_ids" if [ -f "${btf_ids}" ]; then ${RESOLVE_BTFIDS} --patch_btfids ${btf_ids} ${ELF_FILE} fi
scripts/link-vmlinux.sh +1 -1
@@ -206,7 +206,7 @@ fi if is_enabled CONFIG_DEBUG_INFO_BTF; then info BTF .tmp_vmlinux1 - if ! ${srctree}/scripts/gen-btf.sh .tmp_vmlinux1; then + if ! ${CONFIG_SHELL} ${srctree}/scripts/gen-btf.sh .tmp_vmlinux1; then echo >&2 "Failed to generate BTF for vmlinux" echo >&2 "Try to disable CONFIG_DEBUG_INFO_BTF" exit 1
Signature · 1 line
2.52.0
Quoted 6 lines · Ihor Solodrai
According to the docs [1], kernel build scripts should be executed via
CONFIG_SHELL, which is sh by default.Fixup
gen-btf.shto be runnable with sh, and useCONFIG_SHELLat every invocation site.
Quoted 6 lines
See relevant discussion for context [2].
[1] https://docs.kernel.org/kbuild/makefiles.html#script-invocation
[2] https://lore.kernel.org/bpf/CAADnVQ+dxmSNoJAGb6xV89ffUCKXe5CJXovXZt22nv5iYFV5mw@mail.gmail.com/Signed-off-by Ihor Solodrai <[email protected]>
I can indeed build again when applying this on top of linux-next. Thanks.
You probably also want to carry some Reported-by, Suggested-by and Fixes tags here.
Best,
Gary
Quoted 65 lines
--- scripts/Makefile.modfinal | 2 +- scripts/gen-btf.sh | 8 ++++---- scripts/link-vmlinux.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)scripts/Makefile.modfinal +1
-1@@ -43,7 +43,7 @@ quiet_cmd_btf_ko = BTF [M] $@ if [ ! -f $(objtree)/vmlinux ]; then \ printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \ else \ - $(srctree)/scripts/gen-btf.sh --btf_base $(objtree)/vmlinux $@; \ + $(CONFIG_SHELL) $(srctree)/scripts/gen-btf.sh --btf_base $(objtree)/vmlinux $@; \ fi; # Same as newer-prereqs, but allows to exclude specified extra dependenciesscripts/gen-btf.sh +4
-4@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2025 Meta Platforms, Inc. and affiliates. #@@ -81,7 +81,7 @@ gen_btf_data() gen_btf_o() { - local btf_data=${ELF_FILE}.btf.o + btf_data=${ELF_FILE}.btf.o # Create ${btf_data} which contains just .BTF section but no symbols. Add # SHF_ALLOC because .BTF will be part of the vmlinux image. --strip-all@@ -107,11 +107,11 @@ embed_btf_data() ${OBJCOPY} --add-section .BTF=${ELF_FILE}.BTF ${ELF_FILE} # a module might not have a .BTF_ids or .BTF.base section - local btf_base="${ELF_FILE}.BTF.base" + btf_base="${ELF_FILE}.BTF.base" if [ -f "${btf_base}" ]; then ${OBJCOPY} --add-section .BTF.base=${btf_base} ${ELF_FILE} fi - local btf_ids="${ELF_FILE}.BTF_ids" + btf_ids="${ELF_FILE}.BTF_ids" if [ -f "${btf_ids}" ]; then ${RESOLVE_BTFIDS} --patch_btfids ${btf_ids} ${ELF_FILE} fiscripts/link-vmlinux.sh +1
-1@@ -206,7 +206,7 @@ fi if is_enabled CONFIG_DEBUG_INFO_BTF; then info BTF .tmp_vmlinux1 - if ! ${srctree}/scripts/gen-btf.sh .tmp_vmlinux1; then + if ! ${CONFIG_SHELL} ${srctree}/scripts/gen-btf.sh .tmp_vmlinux1; then echo >&2 "Failed to generate BTF for vmlinux" echo >&2 "Try to disable CONFIG_DEBUG_INFO_BTF" exit 1
Ihor Solodrai
reviewerQuoted 12 lines · Gary Guo
Quoted 11 lines · Ihor Solodrai
According to the docs [1], kernel build scripts should be executed via
CONFIG_SHELL, which is sh by default.Fixup
gen-btf.shto be runnable with sh, and useCONFIG_SHELLat every invocation site.See relevant discussion for context [2].
[1] https://docs.kernel.org/kbuild/makefiles.html#script-invocation
[2] https://lore.kernel.org/bpf/CAADnVQ+dxmSNoJAGb6xV89ffUCKXe5CJXovXZt22nv5iYFV5mw@mail.gmail.com/
Quoted 7 lines
Quoted 1 line
Signed-off-by Ihor Solodrai <[email protected]>I can indeed build again when applying this on top of linux-next. Thanks.
Tested-by Gary Guo <[email protected]>You probably also want to carry some Reported-by, Suggested-by and Fixes tags here.
You're right. This should do it:
Alexei, please lmk if I should re-send with tags.
Quoted 3 lines
Quoted 3 lines
[...]
Quoted 22 lines · Ihor Solodrai
Quoted 12 lines · Gary Guo
Quoted 11 lines · Ihor Solodrai
According to the docs [1], kernel build scripts should be executed via
CONFIG_SHELL, which is sh by default.Fixup
gen-btf.shto be runnable with sh, and useCONFIG_SHELLat every invocation site.See relevant discussion for context [2].
[1] https://docs.kernel.org/kbuild/makefiles.html#script-invocation
[2] https://lore.kernel.org/bpf/CAADnVQ+dxmSNoJAGb6xV89ffUCKXe5CJXovXZt22nv5iYFV5mw@mail.gmail.com/Quoted 7 lines
Quoted 1 line
Signed-off-by Ihor Solodrai <[email protected]>I can indeed build again when applying this on top of linux-next. Thanks.
Tested-by Gary Guo <[email protected]>You probably also want to carry some Reported-by, Suggested-by and Fixes tags here.
Quoted 7 lines
You're right. This should do it:
Reported-by Gary Guo <[email protected]>Suggested-by Thomas Weißschuh <[email protected]>Fixes 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output")Alexei, please lmk if I should re-send with tags.
All good. Applied manually.
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 9 lines · On Wed, 21 Jan 2026 10:16:17 -0800 you wrote:
According to the docs [1], kernel build scripts should be executed via
CONFIG_SHELL, which is sh by default.Fixup
gen-btf.shto be runnable with sh, and useCONFIG_SHELLat every invocation site.See relevant discussion for context [2].
[...]
Here is the summary with links:
- [bpf-next,v1] scripts/gen-btf.sh: Use CONFIG_SHELL for execution
https://git.kernel.org/bpf/bpf-next/c/26ad5d6e7630
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html