mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] scripts/config: honor $KBUILD_OUTPUT by default
@ 2026-09-27 15:41 Dmitry Voytik
  2026-09-29  8:45 ` Nicolas Schier
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Voytik @ 2026-09-27 15:41 UTC (permalink / raw)
  To: Nicolas Schier, Nathan Chancellor
  Cc: Nicolas Schier, Rong Zhang, linux-kernel, linux-kbuild, Dmitry Voytik

If $KBUILD_OUTPUT is set, use it by default if --file is not passed.

Fix the issue when the script silently updates a stale .config in
the root directory, while the user expects ${KBUILD_OUTPUT}/.config
to be updated.
The problem can be worked around with --file, but this is easy to miss,
and is inconsistent with how the Makefile and other tools work
(e.g., scripts/diffconfig).

How to reproduce the issue:
	rm .config
	export KBUILD_OUTPUT=.out
	make defconfig
	./scripts/config \
	       -e CONFIG_UBSAN
	grep: .config: No such file or directory

Signed-off-by: Dmitry Voytik <voytikd@gmail.com>
---
v3:
 - Added an example in the commit message how to reproduce the issue
v2:
 - Addressed comments by sashiko:
   - https://sashiko.dev/#/patchset/20260920064350.17999-1-voytikd%40gmail.com
   - use basename when --refresh is used
   - remove echo which can be misleading when --file is passed
v1:
 - https://lore.kernel.org/all/20260920064350.17999-1-voytikd@gmail.com/
---
 scripts/config | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/config b/scripts/config
index 32428ea909c2..cdee67157fe1 100755
--- a/scripts/config
+++ b/scripts/config
@@ -130,6 +130,10 @@ on_exit() {
 trap on_exit EXIT
 
 FN=.config
+if [ -n "${KBUILD_OUTPUT}" ]; then
+	FN=${KBUILD_OUTPUT}/${FN}
+fi
+
 CMDS=()
 while [[ $# -gt 0 ]]; do
 	if [ "$1" = "--file" ]; then
@@ -229,7 +233,7 @@ while [ "$1" != "" ] ; do
 		;;
 
 	--refresh)
-		yes "" | make oldconfig KCONFIG_CONFIG=$FN
+		yes "" | make oldconfig KCONFIG_CONFIG=$(basename $FN)
 		;;
 
 	*)
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] scripts/config: honor $KBUILD_OUTPUT by default
  2026-09-27 15:41 [PATCH v3] scripts/config: honor $KBUILD_OUTPUT by default Dmitry Voytik
@ 2026-09-29  8:45 ` Nicolas Schier
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Schier @ 2026-09-29  8:45 UTC (permalink / raw)
  To: Dmitry Voytik; +Cc: Nathan Chancellor, Rong Zhang, linux-kernel, linux-kbuild

On Sun, Sep 27, 2026 at 05:41:01PM +0200, Dmitry Voytik wrote:
> If $KBUILD_OUTPUT is set, use it by default if --file is not passed.
> 
> Fix the issue when the script silently updates a stale .config in
> the root directory, while the user expects ${KBUILD_OUTPUT}/.config
> to be updated.
> The problem can be worked around with --file, but this is easy to miss,
> and is inconsistent with how the Makefile and other tools work
> (e.g., scripts/diffconfig).
> 
> How to reproduce the issue:
> 	rm .config
> 	export KBUILD_OUTPUT=.out
> 	make defconfig
> 	./scripts/config \
> 	       -e CONFIG_UBSAN
> 	grep: .config: No such file or directory
> 
> Signed-off-by: Dmitry Voytik <voytikd@gmail.com>
> ---
> v3:
>  - Added an example in the commit message how to reproduce the issue
> v2:
>  - Addressed comments by sashiko:
>    - https://sashiko.dev/#/patchset/20260920064350.17999-1-voytikd%40gmail.com
>    - use basename when --refresh is used
>    - remove echo which can be misleading when --file is passed
> v1:
>  - https://lore.kernel.org/all/20260920064350.17999-1-voytikd@gmail.com/
> ---
>  scripts/config | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/config b/scripts/config
> index 32428ea909c2..cdee67157fe1 100755
> --- a/scripts/config
> +++ b/scripts/config
> @@ -130,6 +130,10 @@ on_exit() {
>  trap on_exit EXIT
>  
>  FN=.config
> +if [ -n "${KBUILD_OUTPUT}" ]; then
> +	FN=${KBUILD_OUTPUT}/${FN}
> +fi
> +
>  CMDS=()
>  while [[ $# -gt 0 ]]; do
>  	if [ "$1" = "--file" ]; then
> @@ -229,7 +233,7 @@ while [ "$1" != "" ] ; do
>  		;;
>  
>  	--refresh)
> -		yes "" | make oldconfig KCONFIG_CONFIG=$FN
> +		yes "" | make oldconfig KCONFIG_CONFIG=$(basename $FN)

Thanks for attempting to fix the '--refresh' option.  But this way,
this may lead to very unexpected behaviour, as it regardlessly modifies
the path to the config file, even if it was specified via --file.

If --file is given, it should take precedence over any KBUILD_OUTPUT
(or KCONFIG_CONFIG) from the environment and not be changed unrequested.

It would be a tiny bit nicer to just strip the KBUILD_OUTPUT path from
FN, e.g. (untested):

		yes "" | make oldconfig KCONFIG_CONFIG="${FN#${KBUILD_OUTPUT}/}"

But I am still not feeling happy with that.

-- 
Nicolas

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-29 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-27 15:41 [PATCH v3] scripts/config: honor $KBUILD_OUTPUT by default Dmitry Voytik
2026-09-29  8:45 ` Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®