* [PATCH] scripts/gen-btf.sh: fix shebang for NixOS
@ 2026-01-20 18:20 Gary Guo
2026-01-20 18:59 ` Ihor Solodrai
0 siblings, 1 reply; 10+ messages in thread
From: Gary Guo @ 2026-01-20 18:20 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Ihor Solodrai
Cc: Gary Guo, bpf, linux-kernel
From: Gary Guo <gary@garyguo.net>
NixOS only puts /usr/bin/env and /bin/sh at the standard location as
required by POSIX, but not other shells. Other program that kernel build
depends on is supplied via PATH, so shebang needs to use /usr/bin/env to
find them.
This has been done to a few other scripts already, e.g.
gen_test_kallsyms.sh or decode_stacktrace.sh.
Fixes: 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output")
Signed-off-by: Gary Guo <gary@garyguo.net>
---
scripts/gen-btf.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/gen-btf.sh b/scripts/gen-btf.sh
index be21ccee3487..4cd3159f2ddb 100755
--- a/scripts/gen-btf.sh
+++ b/scripts/gen-btf.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2025 Meta Platforms, Inc. and affiliates.
#
base-commit: 053966c344dbd346e71305f530e91ea77916189f
--
2.51.2
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-20 18:20 [PATCH] scripts/gen-btf.sh: fix shebang for NixOS Gary Guo @ 2026-01-20 18:59 ` Ihor Solodrai 2026-01-20 19:15 ` Gary Guo 0 siblings, 1 reply; 10+ messages in thread From: Ihor Solodrai @ 2026-01-20 18:59 UTC (permalink / raw) To: Gary Guo, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa Cc: bpf, linux-kernel On 1/20/26 10:20 AM, Gary Guo wrote: > From: Gary Guo <gary@garyguo.net> > > NixOS only puts /usr/bin/env and /bin/sh at the standard location as > required by POSIX, but not other shells. Other program that kernel build > depends on is supplied via PATH, so shebang needs to use /usr/bin/env to > find them. > > This has been done to a few other scripts already, e.g. > gen_test_kallsyms.sh or decode_stacktrace.sh. > > Fixes: 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output") > Signed-off-by: Gary Guo <gary@garyguo.net> > --- > scripts/gen-btf.sh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/gen-btf.sh b/scripts/gen-btf.sh > index be21ccee3487..4cd3159f2ddb 100755 > --- a/scripts/gen-btf.sh > +++ b/scripts/gen-btf.sh > @@ -1,4 +1,4 @@ > -#!/bin/bash > +#!/usr/bin/env bash > # SPDX-License-Identifier: GPL-2.0 > # Copyright (c) 2025 Meta Platforms, Inc. and affiliates. > # > > base-commit: 053966c344dbd346e71305f530e91ea77916189f Hi Gary, thanks for the patch. I'm guessing this came up because gen-btf.sh is part of the vmlinux build, and link-vmlinux.sh has #!/bin/sh (not bash). But I wonder if all of these need the same change then: $ git log --oneline -n1 24d479d26b25 (HEAD, tag: v6.19-rc6) Linux 6.19-rc6 $ grep -r '#!/bin/bash' ./scripts/ ./scripts/check-uapi.sh:#!/bin/bash ./scripts/decodecode:#!/bin/bash ./scripts/extract-fwblobs:#!/bin/bash ./scripts/gfp-translate:#!/bin/bash ./scripts/git-resolve.sh:#!/bin/bash ./scripts/mkuboot.sh:#!/bin/bash ./scripts/objdiff:#!/bin/bash ./scripts/objdump-func:#!/bin/bash ./scripts/prune-kernel:#!/bin/bash ./scripts/tags.sh:#!/bin/bash ./scripts/tracing/ftrace-bisect.sh:#!/bin/bash ./scripts/livepatch/klp-build:#!/bin/bash ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-20 18:59 ` Ihor Solodrai @ 2026-01-20 19:15 ` Gary Guo 2026-01-20 19:38 ` Thomas Weißschuh 0 siblings, 1 reply; 10+ messages in thread From: Gary Guo @ 2026-01-20 19:15 UTC (permalink / raw) To: Ihor Solodrai, Gary Guo, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa Cc: bpf, linux-kernel On Tue Jan 20, 2026 at 6:59 PM GMT, Ihor Solodrai wrote: > On 1/20/26 10:20 AM, Gary Guo wrote: >> From: Gary Guo <gary@garyguo.net> >> >> NixOS only puts /usr/bin/env and /bin/sh at the standard location as >> required by POSIX, but not other shells. Other program that kernel build >> depends on is supplied via PATH, so shebang needs to use /usr/bin/env to >> find them. >> >> This has been done to a few other scripts already, e.g. >> gen_test_kallsyms.sh or decode_stacktrace.sh. >> >> Fixes: 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output") >> Signed-off-by: Gary Guo <gary@garyguo.net> >> --- >> scripts/gen-btf.sh | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/scripts/gen-btf.sh b/scripts/gen-btf.sh >> index be21ccee3487..4cd3159f2ddb 100755 >> --- a/scripts/gen-btf.sh >> +++ b/scripts/gen-btf.sh >> @@ -1,4 +1,4 @@ >> -#!/bin/bash >> +#!/usr/bin/env bash >> # SPDX-License-Identifier: GPL-2.0 >> # Copyright (c) 2025 Meta Platforms, Inc. and affiliates. >> # >> >> base-commit: 053966c344dbd346e71305f530e91ea77916189f > > Hi Gary, thanks for the patch. > > I'm guessing this came up because gen-btf.sh is part of the vmlinux > build, and link-vmlinux.sh has #!/bin/sh (not bash). My typical experience is that when I see an error about /bin/bash not found, I just use "bash <script path>" instead without putting much think into it. gen-btf.sh is part of build so I don't get to invoke the script directly, hence the patch. Best, Gary > > But I wonder if all of these need the same change then: > > $ git log --oneline -n1 > 24d479d26b25 (HEAD, tag: v6.19-rc6) Linux 6.19-rc6 > $ grep -r '#!/bin/bash' ./scripts/ > ./scripts/check-uapi.sh:#!/bin/bash > ./scripts/decodecode:#!/bin/bash > ./scripts/extract-fwblobs:#!/bin/bash > ./scripts/gfp-translate:#!/bin/bash > ./scripts/git-resolve.sh:#!/bin/bash > ./scripts/mkuboot.sh:#!/bin/bash > ./scripts/objdiff:#!/bin/bash > ./scripts/objdump-func:#!/bin/bash > ./scripts/prune-kernel:#!/bin/bash > ./scripts/tags.sh:#!/bin/bash > ./scripts/tracing/ftrace-bisect.sh:#!/bin/bash > ./scripts/livepatch/klp-build:#!/bin/bash ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-20 19:15 ` Gary Guo @ 2026-01-20 19:38 ` Thomas Weißschuh 2026-01-20 19:53 ` Ihor Solodrai 0 siblings, 1 reply; 10+ messages in thread From: Thomas Weißschuh @ 2026-01-20 19:38 UTC (permalink / raw) To: Gary Guo Cc: Ihor Solodrai, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, linux-kernel On 2026-01-20 19:15:11+0000, Gary Guo wrote: > On Tue Jan 20, 2026 at 6:59 PM GMT, Ihor Solodrai wrote: > > On 1/20/26 10:20 AM, Gary Guo wrote: > >> From: Gary Guo <gary@garyguo.net> > >> > >> NixOS only puts /usr/bin/env and /bin/sh at the standard location as > >> required by POSIX, but not other shells. Other program that kernel build > >> depends on is supplied via PATH, so shebang needs to use /usr/bin/env to > >> find them. > >> > >> This has been done to a few other scripts already, e.g. > >> gen_test_kallsyms.sh or decode_stacktrace.sh. > >> > >> Fixes: 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output") > >> Signed-off-by: Gary Guo <gary@garyguo.net> > >> --- > >> scripts/gen-btf.sh | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/scripts/gen-btf.sh b/scripts/gen-btf.sh > >> index be21ccee3487..4cd3159f2ddb 100755 > >> --- a/scripts/gen-btf.sh > >> +++ b/scripts/gen-btf.sh > >> @@ -1,4 +1,4 @@ > >> -#!/bin/bash > >> +#!/usr/bin/env bash > >> # SPDX-License-Identifier: GPL-2.0 > >> # Copyright (c) 2025 Meta Platforms, Inc. and affiliates. > >> # > >> > >> base-commit: 053966c344dbd346e71305f530e91ea77916189f > > > > Hi Gary, thanks for the patch. > > > > I'm guessing this came up because gen-btf.sh is part of the vmlinux > > build, and link-vmlinux.sh has #!/bin/sh (not bash). > > My typical experience is that when I see an error about /bin/bash not found, I > just use "bash <script path>" instead without putting much think into it. > > gen-btf.sh is part of build so I don't get to invoke the script directly, hence > the patch. For the build we have $(CONFIG_SHELL) to stick before the script. It is only 'sh', but it is the well-known variable users know to override. IMO all script invocations should use this mechanism. Thomas ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-20 19:38 ` Thomas Weißschuh @ 2026-01-20 19:53 ` Ihor Solodrai 2026-01-20 23:54 ` Gary Guo 0 siblings, 1 reply; 10+ messages in thread From: Ihor Solodrai @ 2026-01-20 19:53 UTC (permalink / raw) To: Thomas Weißschuh, Gary Guo Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, linux-kernel On 1/20/26 11:38 AM, Thomas Weißschuh wrote: > On 2026-01-20 19:15:11+0000, Gary Guo wrote: >> On Tue Jan 20, 2026 at 6:59 PM GMT, Ihor Solodrai wrote: >>> On 1/20/26 10:20 AM, Gary Guo wrote: >>>> From: Gary Guo <gary@garyguo.net> >>>> >>>> NixOS only puts /usr/bin/env and /bin/sh at the standard location as >>>> required by POSIX, but not other shells. Other program that kernel build >>>> depends on is supplied via PATH, so shebang needs to use /usr/bin/env to >>>> find them. >>>> >>>> This has been done to a few other scripts already, e.g. >>>> gen_test_kallsyms.sh or decode_stacktrace.sh. >>>> >>>> Fixes: 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output") >>>> Signed-off-by: Gary Guo <gary@garyguo.net> >>>> --- >>>> scripts/gen-btf.sh | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/scripts/gen-btf.sh b/scripts/gen-btf.sh >>>> index be21ccee3487..4cd3159f2ddb 100755 >>>> --- a/scripts/gen-btf.sh >>>> +++ b/scripts/gen-btf.sh >>>> @@ -1,4 +1,4 @@ >>>> -#!/bin/bash >>>> +#!/usr/bin/env bash >>>> # SPDX-License-Identifier: GPL-2.0 >>>> # Copyright (c) 2025 Meta Platforms, Inc. and affiliates. >>>> # >>>> >>>> base-commit: 053966c344dbd346e71305f530e91ea77916189f >>> >>> Hi Gary, thanks for the patch. >>> >>> I'm guessing this came up because gen-btf.sh is part of the vmlinux >>> build, and link-vmlinux.sh has #!/bin/sh (not bash). >> >> My typical experience is that when I see an error about /bin/bash not found, I >> just use "bash <script path>" instead without putting much think into it. >> >> gen-btf.sh is part of build so I don't get to invoke the script directly, hence >> the patch. > > For the build we have $(CONFIG_SHELL) to stick before the script. > It is only 'sh', but it is the well-known variable users know to > override. IMO all script invocations should use this mechanism. There are two places where gen-btf.sh is invoked. In link-vmlinux.sh: if ! ${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 fi And in Makefile.modfinal: quiet_cmd_btf_ko = BTF [M] $@ cmd_btf_ko = \ 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 $@; \ fi; So it's trivial to put $(CONFIG_SHELL) in front of it. But then it must be migrated to #!/bin/sh, right? > > > Thomas ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-20 19:53 ` Ihor Solodrai @ 2026-01-20 23:54 ` Gary Guo 2026-01-21 4:49 ` Ihor Solodrai 0 siblings, 1 reply; 10+ messages in thread From: Gary Guo @ 2026-01-20 23:54 UTC (permalink / raw) To: Ihor Solodrai, Thomas Weißschuh, Gary Guo Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, linux-kernel On Tue Jan 20, 2026 at 7:53 PM GMT, Ihor Solodrai wrote: > On 1/20/26 11:38 AM, Thomas Weißschuh wrote: >> On 2026-01-20 19:15:11+0000, Gary Guo wrote: >>> On Tue Jan 20, 2026 at 6:59 PM GMT, Ihor Solodrai wrote: >>>> On 1/20/26 10:20 AM, Gary Guo wrote: >>>>> From: Gary Guo <gary@garyguo.net> >>>>> >>>>> NixOS only puts /usr/bin/env and /bin/sh at the standard location as >>>>> required by POSIX, but not other shells. Other program that kernel build >>>>> depends on is supplied via PATH, so shebang needs to use /usr/bin/env to >>>>> find them. >>>>> >>>>> This has been done to a few other scripts already, e.g. >>>>> gen_test_kallsyms.sh or decode_stacktrace.sh. >>>>> >>>>> Fixes: 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output") >>>>> Signed-off-by: Gary Guo <gary@garyguo.net> >>>>> --- >>>>> scripts/gen-btf.sh | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/scripts/gen-btf.sh b/scripts/gen-btf.sh >>>>> index be21ccee3487..4cd3159f2ddb 100755 >>>>> --- a/scripts/gen-btf.sh >>>>> +++ b/scripts/gen-btf.sh >>>>> @@ -1,4 +1,4 @@ >>>>> -#!/bin/bash >>>>> +#!/usr/bin/env bash >>>>> # SPDX-License-Identifier: GPL-2.0 >>>>> # Copyright (c) 2025 Meta Platforms, Inc. and affiliates. >>>>> # >>>>> >>>>> base-commit: 053966c344dbd346e71305f530e91ea77916189f >>>> >>>> Hi Gary, thanks for the patch. >>>> >>>> I'm guessing this came up because gen-btf.sh is part of the vmlinux >>>> build, and link-vmlinux.sh has #!/bin/sh (not bash). >>> >>> My typical experience is that when I see an error about /bin/bash not found, I >>> just use "bash <script path>" instead without putting much think into it. >>> >>> gen-btf.sh is part of build so I don't get to invoke the script directly, hence >>> the patch. >> >> For the build we have $(CONFIG_SHELL) to stick before the script. >> It is only 'sh', but it is the well-known variable users know to >> override. IMO all script invocations should use this mechanism. > > There are two places where gen-btf.sh is invoked. > > In link-vmlinux.sh: > > if ! ${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 > fi > > And in Makefile.modfinal: > > quiet_cmd_btf_ko = BTF [M] $@ > cmd_btf_ko = \ > 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 $@; \ > fi; > > So it's trivial to put $(CONFIG_SHELL) in front of it. But then it > must be migrated to #!/bin/sh, right? Documentation/kbuild/makefiles.rst says: Make rules may invoke scripts to build the kernel. The rules shall always provide the appropriate interpreter to execute the script. They shall not rely on the execute bits being set, and shall not invoke the script directly. For the convenience of manual script invocation, such as invoking ./scripts/checkpatch.pl, it is recommended to set execute bits on the scripts nonetheless. Kbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL), and $(PYTHON3) to refer to interpreters for the respective scripts. So I suppose it would need to migate to POSIX shell... Best, Gary ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-20 23:54 ` Gary Guo @ 2026-01-21 4:49 ` Ihor Solodrai 2026-01-21 4:52 ` Alexei Starovoitov 0 siblings, 1 reply; 10+ messages in thread From: Ihor Solodrai @ 2026-01-21 4:49 UTC (permalink / raw) To: Gary Guo, Thomas Weißschuh Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, linux-kernel On 1/20/26 3:54 PM, Gary Guo wrote: >> [...] >> >> So it's trivial to put $(CONFIG_SHELL) in front of it. But then it >> must be migrated to #!/bin/sh, right? > > Documentation/kbuild/makefiles.rst says: > > Make rules may invoke scripts to build the kernel. The rules shall > always provide the appropriate interpreter to execute the script. They > shall not rely on the execute bits being set, and shall not invoke the > script directly. For the convenience of manual script invocation, such > as invoking ./scripts/checkpatch.pl, it is recommended to set execute > bits on the scripts nonetheless. > > Kbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL), > and $(PYTHON3) to refer to interpreters for the respective > scripts. > > So I suppose it would need to migate to POSIX shell... That's my blunder then. I'll send a patch tomorrow to make gen-btf.sh runnable with /bin/sh > > Best, > Gary ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-21 4:49 ` Ihor Solodrai @ 2026-01-21 4:52 ` Alexei Starovoitov 2026-01-21 5:04 ` Ihor Solodrai 0 siblings, 1 reply; 10+ messages in thread From: Alexei Starovoitov @ 2026-01-21 4:52 UTC (permalink / raw) To: Ihor Solodrai Cc: Gary Guo, Thomas Weißschuh, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, LKML On Tue, Jan 20, 2026 at 8:50 PM Ihor Solodrai <ihor.solodrai@linux.dev> wrote: > > > > On 1/20/26 3:54 PM, Gary Guo wrote: > >> [...] > >> > >> So it's trivial to put $(CONFIG_SHELL) in front of it. But then it > >> must be migrated to #!/bin/sh, right? > > > > Documentation/kbuild/makefiles.rst says: > > > > Make rules may invoke scripts to build the kernel. The rules shall > > always provide the appropriate interpreter to execute the script. They > > shall not rely on the execute bits being set, and shall not invoke the > > script directly. For the convenience of manual script invocation, such > > as invoking ./scripts/checkpatch.pl, it is recommended to set execute > > bits on the scripts nonetheless. > > > > Kbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL), > > and $(PYTHON3) to refer to interpreters for the respective > > scripts. > > > > So I suppose it would need to migate to POSIX shell... > > That's my blunder then. > > I'll send a patch tomorrow to make gen-btf.sh runnable with /bin/sh Isn't the current patch enough? -#!/bin/bash +#!/usr/bin/env bash I don't think all kernel build scripts are pure 'sh'. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-21 4:52 ` Alexei Starovoitov @ 2026-01-21 5:04 ` Ihor Solodrai 2026-01-21 16:09 ` Alexei Starovoitov 0 siblings, 1 reply; 10+ messages in thread From: Ihor Solodrai @ 2026-01-21 5:04 UTC (permalink / raw) To: Alexei Starovoitov Cc: Gary Guo, Thomas Weißschuh, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, LKML On 1/20/26 8:52 PM, Alexei Starovoitov wrote: > On Tue, Jan 20, 2026 at 8:50 PM Ihor Solodrai <ihor.solodrai@linux.dev> wrote: >> >> >> >> On 1/20/26 3:54 PM, Gary Guo wrote: >>>> [...] >>>> >>>> So it's trivial to put $(CONFIG_SHELL) in front of it. But then it >>>> must be migrated to #!/bin/sh, right? >>> >>> Documentation/kbuild/makefiles.rst says: >>> >>> Make rules may invoke scripts to build the kernel. The rules shall >>> always provide the appropriate interpreter to execute the script. They >>> shall not rely on the execute bits being set, and shall not invoke the >>> script directly. For the convenience of manual script invocation, such >>> as invoking ./scripts/checkpatch.pl, it is recommended to set execute >>> bits on the scripts nonetheless. >>> >>> Kbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL), >>> and $(PYTHON3) to refer to interpreters for the respective >>> scripts. >>> >>> So I suppose it would need to migate to POSIX shell... >> >> That's my blunder then. >> >> I'll send a patch tomorrow to make gen-btf.sh runnable with /bin/sh > > Isn't the current patch enough? > -#!/bin/bash > +#!/usr/bin/env bash > > I don't think all kernel build scripts are pure 'sh'. Well, if we want to follow the makefiles.rst (and Thomas') recommendation, which is executing the script via $(CONFIG_SHELL), then we have to migrate to #!/bin/sh, because that's the default. This concerns only scripts in the kernel build pipeline AFAIU. But you may be right that this is not a strict rule, idk. It did come up quite late on the list. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scripts/gen-btf.sh: fix shebang for NixOS 2026-01-21 5:04 ` Ihor Solodrai @ 2026-01-21 16:09 ` Alexei Starovoitov 0 siblings, 0 replies; 10+ messages in thread From: Alexei Starovoitov @ 2026-01-21 16:09 UTC (permalink / raw) To: Ihor Solodrai Cc: Gary Guo, Thomas Weißschuh, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, LKML On Tue, Jan 20, 2026 at 9:04 PM Ihor Solodrai <ihor.solodrai@linux.dev> wrote: > > > > On 1/20/26 8:52 PM, Alexei Starovoitov wrote: > > On Tue, Jan 20, 2026 at 8:50 PM Ihor Solodrai <ihor.solodrai@linux.dev> wrote: > >> > >> > >> > >> On 1/20/26 3:54 PM, Gary Guo wrote: > >>>> [...] > >>>> > >>>> So it's trivial to put $(CONFIG_SHELL) in front of it. But then it > >>>> must be migrated to #!/bin/sh, right? > >>> > >>> Documentation/kbuild/makefiles.rst says: > >>> > >>> Make rules may invoke scripts to build the kernel. The rules shall > >>> always provide the appropriate interpreter to execute the script. They > >>> shall not rely on the execute bits being set, and shall not invoke the > >>> script directly. For the convenience of manual script invocation, such > >>> as invoking ./scripts/checkpatch.pl, it is recommended to set execute > >>> bits on the scripts nonetheless. > >>> > >>> Kbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL), > >>> and $(PYTHON3) to refer to interpreters for the respective > >>> scripts. > >>> > >>> So I suppose it would need to migate to POSIX shell... > >> > >> That's my blunder then. > >> > >> I'll send a patch tomorrow to make gen-btf.sh runnable with /bin/sh > > > > Isn't the current patch enough? > > -#!/bin/bash > > +#!/usr/bin/env bash > > > > I don't think all kernel build scripts are pure 'sh'. > > Well, if we want to follow the makefiles.rst (and Thomas') > recommendation, which is executing the script via $(CONFIG_SHELL), > then we have to migrate to #!/bin/sh, because that's the default. > > This concerns only scripts in the kernel build pipeline AFAIU. > > But you may be right that this is not a strict rule, idk. > It did come up quite late on the list. git grep CONFIG_SHELL|wc -l 68 ok, let's convert to pure sh then. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-01-21 16:10 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-01-20 18:20 [PATCH] scripts/gen-btf.sh: fix shebang for NixOS Gary Guo 2026-01-20 18:59 ` Ihor Solodrai 2026-01-20 19:15 ` Gary Guo 2026-01-20 19:38 ` Thomas Weißschuh 2026-01-20 19:53 ` Ihor Solodrai 2026-01-20 23:54 ` Gary Guo 2026-01-21 4:49 ` Ihor Solodrai 2026-01-21 4:52 ` Alexei Starovoitov 2026-01-21 5:04 ` Ihor Solodrai 2026-01-21 16:09 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox