Skip to contentSkip to conversation

setlocalversion: use ${objtree}/include/config/auto.conf

PATCH Superseded HONG Yifan 2 participants 8 messages Mar 12, 2025 – Mar 24, 2025

lore
Share & tools
lore

HONG Yifan

author
#0 lore raw

PATCH 1/1 setlocalversion: use ${objtree}/include/config/auto.conf

setlocalversion reads include/config/auto.conf, which is located below $(objtree) with commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some in-kernel build artifacts").

Hence, the setlocalversion script needs to use
$(objtree)/include/config/auto.conf as well.

Note that $(objtree) is not necessarily . when O (aka KBUILD_OUTPUT) is set, because of commit 13b25489b6f8 ("kbuild: change working directory to external module directory with M=").

---
Implementation note: Should I test -z ${objtree} before using it? Otherwise it looks at /include/config/auto.conf which is wrong.
Or should I fall back to . if objtree is not found in the environment variables?
I could also exit 1 if $objtree is not set. Please let me know what you think.

 scripts/setlocalversion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/setlocalversion +1 -1
index 28169d7e143b..88f54eb5a7c2 100755
@@ -186,7 +186,7 @@ if ${no_local}; then
 	exit 0
 fi
 
-if ! test -e include/config/auto.conf; then
+if ! test -e ${objtree}/include/config/auto.conf; then
 	echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
 	exit 1
 fi

--
2.49.0.rc0.332.g42c0ae87b1-goog

#1 lore raw
Quoted 11 lines · HONG Yifan

setlocalversion reads include/config/auto.conf, which is located below $(objtree) with commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some in-kernel build artifacts").

Hence, the setlocalversion script needs to use
$(objtree)/include/config/auto.conf as well.

Note that $(objtree) is not necessarily . when O (aka KBUILD_OUTPUT) is set, because of commit 13b25489b6f8 ("kbuild: change working directory to external module directory with M=").

Is this a real issue?
If so, please attach some commands to reproduce an issue.

setlocalversion is invoked only at line 1238 of the top-level Makefile, within the check "ifeq ($(KBUILD_EXTMOD),)"
So, it is never called with external module builds.

Quoted 27 lines

---
Implementation note: Should I test -z ${objtree} before using it? Otherwise it looks at /include/config/auto.conf which is wrong.
Or should I fall back to . if objtree is not found in the environment variables?
I could also exit 1 if $objtree is not set. Please let me know what you think.

 scripts/setlocalversion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/setlocalversion +1 -2
index 28169d7e143b..88f54eb5a7c2 100755
@@ -186,7 +186,7 @@ if ${no_local}; then
        exit 0
 fi
 
-if ! test -e include/config/auto.conf; then
+if ! test -e ${objtree}/include/config/auto.conf; then
        echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
        exit 1
 fi
--

2.49.0.rc0.332.g42c0ae87b1-goog

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 14 lines · Masahiro Yamada
Quoted 11 lines · HONG Yifan

setlocalversion reads include/config/auto.conf, which is located below $(objtree) with commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some in-kernel build artifacts").

Hence, the setlocalversion script needs to use
$(objtree)/include/config/auto.conf as well.

Note that $(objtree) is not necessarily . when O (aka KBUILD_OUTPUT) is set, because of commit 13b25489b6f8 ("kbuild: change working directory to external module directory with M=").

Quoted 6 lines

Is this a real issue?
If so, please attach some commands to reproduce an issue.

setlocalversion is invoked only at line 1238 of the top-level Makefile, within the check "ifeq ($(KBUILD_EXTMOD),)"
So, it is never called with external module builds.

Thanks Masahiro. You are right; this is not a real issue as the code is right now.

In our case, we have this issue because we have
https://lore.kernel.org/all/[email protected]/
("[PATCH v6] modules: introduce the MODULE_SCMVERSION config")
in our tree to support the SCM version for modules. The patch was not accepted so
we applied this patch locally. Hence, technically this patch should also only be applied locally by us. The paragraph that says "Note that $(objtree) is not necessarily ...." is not correct.

Still, I think it makes sense to be consistent with other places that mentions include/config/auto.conf.

Should I update the commit message and send another patch? Or would you like to reject this change?

Quoted 39 lines
Quoted 32 lines

---
Implementation note: Should I test -z ${objtree} before using it? Otherwise it looks at /include/config/auto.conf which is wrong.
Or should I fall back to . if objtree is not found in the environment variables?
I could also exit 1 if $objtree is not set. Please let me know what you think.

 scripts/setlocalversion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/setlocalversion +1 -2
index 28169d7e143b..88f54eb5a7c2 100755
@@ -186,7 +186,7 @@ if ${no_local}; then
        exit 0
 fi
 
-if ! test -e include/config/auto.conf; then
+if ! test -e ${objtree}/include/config/auto.conf; then
        echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
        exit 1
 fi
--
Quoted 2 lines

2.49.0.rc0.332.g42c0ae87b1-goog

--
Best Regards
Masahiro Yamada

#3 lore raw
Quoted 67 lines · Yifan
Quoted 14 lines · Masahiro Yamada
Quoted 11 lines · HONG Yifan

setlocalversion reads include/config/auto.conf, which is located below $(objtree) with commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some in-kernel build artifacts").

Hence, the setlocalversion script needs to use
$(objtree)/include/config/auto.conf as well.

Note that $(objtree) is not necessarily . when O (aka KBUILD_OUTPUT) is set, because of commit 13b25489b6f8 ("kbuild: change working directory to external module directory with M=").

Quoted 6 lines

Is this a real issue?
If so, please attach some commands to reproduce an issue.

setlocalversion is invoked only at line 1238 of the top-level Makefile, within the check "ifeq ($(KBUILD_EXTMOD),)"
So, it is never called with external module builds.

Thanks Masahiro. You are right; this is not a real issue as the code is right now.

In our case, we have this issue because we have
https://lore.kernel.org/all/[email protected]/
("[PATCH v6] modules: introduce the MODULE_SCMVERSION config")
in our tree to support the SCM version for modules. The patch was not accepted so
we applied this patch locally. Hence, technically this patch should also only be applied locally by us. The paragraph that says "Note that $(objtree) is not necessarily ...." is not correct.

Still, I think it makes sense to be consistent with other places that mentions include/config/auto.conf.

Should I update the commit message and send another patch? Or would you like to reject this change?

Quoted 26 lines
Quoted 26 lines

---
Implementation note: Should I test -z ${objtree} before using it? Otherwise it looks at /include/config/auto.conf which is wrong.
Or should I fall back to . if objtree is not found in the environment variables?
I could also exit 1 if $objtree is not set. Please let me know what you think.

 scripts/setlocalversion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/setlocalversion +0 -0
index 28169d7e143b..88f54eb5a7c2 100755
@@ -186,7 +186,7 @@ if ${no_local}; then
        exit 0
 fi
 
Quoted 5 lines
Quoted 5 lines

scripts/setlocalversion if ${no_local}; then · line 192

Quoted 5 lines
scripts/setlocalversion +1 -1
-if ! test -e include/config/auto.conf; then
+if ! test -e ${objtree}/include/config/auto.conf; then
        echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
        exit 1
 fi

Actually, I noticed two more include/config/auto.conf mentions below this line. If the overall idea looks good to you, I'll upload a separate version that fixes the two mentions below as well.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

--
2.49.0.rc0.332.g42c0ae87b1-goog

--
Best Regards
Masahiro Yamada

#4 lore raw
In reply to Hong, Yifan
Quoted 35 lines · Yifan
Quoted 14 lines · Masahiro Yamada
Quoted 11 lines · HONG Yifan

setlocalversion reads include/config/auto.conf, which is located below $(objtree) with commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some in-kernel build artifacts").

Hence, the setlocalversion script needs to use
$(objtree)/include/config/auto.conf as well.

Note that $(objtree) is not necessarily . when O (aka KBUILD_OUTPUT) is set, because of commit 13b25489b6f8 ("kbuild: change working directory to external module directory with M=").

Quoted 6 lines

Is this a real issue?
If so, please attach some commands to reproduce an issue.

setlocalversion is invoked only at line 1238 of the top-level Makefile, within the check "ifeq ($(KBUILD_EXTMOD),)"
So, it is never called with external module builds.

Thanks Masahiro. You are right; this is not a real issue as the code is right now.

In our case, we have this issue because we have
https://lore.kernel.org/all/[email protected]/
("[PATCH v6] modules: introduce the MODULE_SCMVERSION config")
in our tree to support the SCM version for modules. The patch was not accepted so
we applied this patch locally. Hence, technically this patch should also only be applied locally by us. The paragraph that says "Note that $(objtree) is not necessarily ...." is not correct.

Quoted 5 lines

Still, I think it makes sense to be consistent with other places that mentions include/config/auto.conf.

Should I update the commit message and send another patch? Or would you like to reject this change?

OK, I will accept this if the commit message correctly describes this.

And, please fix up all the 3 occurrences for consistency.

Thanks.

Quoted 40 lines
Quoted 40 lines
Quoted 33 lines

---
Implementation note: Should I test -z ${objtree} before using it? Otherwise it looks at /include/config/auto.conf which is wrong.
Or should I fall back to . if objtree is not found in the environment variables?
I could also exit 1 if $objtree is not set. Please let me know what you think.

 scripts/setlocalversion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/setlocalversion +1 -2
index 28169d7e143b..88f54eb5a7c2 100755
@@ -186,7 +186,7 @@ if ${no_local}; then
        exit 0
 fi
 
-if ! test -e include/config/auto.conf; then
+if ! test -e ${objtree}/include/config/auto.conf; then
        echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
        exit 1
 fi
--
Quoted 2 lines

2.49.0.rc0.332.g42c0ae87b1-goog

--
Best Regards
Masahiro Yamada

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#5 lore raw

PATCH v2 1/1 setlocalversion: use ${objtree}/include/config/auto.conf

setlocalversion reads include/config/auto.conf, which is located below $(objtree) with commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some in-kernel build artifacts").

To be consistent, the setlocalversion script should use ${objtree}/include/config/auto.conf as well.

---
v1: https://lore.kernel.org/lkml/[email protected]/
v1 -> v2: fixed the other two locations of include/config/auto.conf in setlocalversion script; also removed incorrect claim in commit message.

 scripts/setlocalversion | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/setlocalversion +3 -3
index 28169d7e143b..c13fe6e585e9 100755
@@ -186,16 +186,16 @@ if ${no_local}; then
 	exit 0
 fi
 
-if ! test -e include/config/auto.conf; then
+if ! test -e ${objtree}/include/config/auto.conf; then
 	echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
 	exit 1
 fi
 
 # version string from CONFIG_LOCALVERSION
-config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' include/config/auto.conf)
+config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' ${objtree}/include/config/auto.conf)
 
 # scm version string if not at the kernel version tag or at the file_localversion
-if grep -q "^CONFIG_LOCALVERSION_AUTO=y$" include/config/auto.conf; then
+if grep -q "^CONFIG_LOCALVERSION_AUTO=y$" ${objtree}/include/config/auto.conf; then
 	# full scm version string
 	scm_version="$(scm_version)"
 elif [ "${LOCALVERSION+set}" != "set" ]; then

--
2.49.0.rc1.451.g8f38331e32-goog

#6 lore raw
Quoted 6 lines · HONG Yifan

setlocalversion reads include/config/auto.conf, which is located below $(objtree) with commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some in-kernel build artifacts").

To be consistent, the setlocalversion script should use

"To be consistent" is too weak because we do not add $(objtree)/ to include/config/auto.conf

Just run "git grep include/config/auto.conf"

You will see more include/config/auto.conf instances that lack $(objtree)/ prefix.

So, "To be consistent" is not a reason.

You described why Google needs to have this
specifically scripts/setlocalversion.

Without that explained, I do not understand _why_.

Quoted 16 lines

${objtree}/include/config/auto.conf as well.

---
v1: https://lore.kernel.org/lkml/[email protected]/
v1 -> v2: fixed the other two locations of include/config/auto.conf in setlocalversion script; also removed incorrect claim in commit message.

 scripts/setlocalversion | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/setlocalversion +0 -0
index 28169d7e143b..c13fe6e585e9 100755

scripts/setlocalversion if ${no_local}; then · line 189

Quoted 5 lines
scripts/setlocalversion +1 -1
@@ -186,16 +186,16 @@ if ${no_local}; then
        exit 0
 fi
 
-if ! test -e include/config/auto.conf; then
+if ! test -e ${objtree}/include/config/auto.conf; then

Please quote

"${objtree}/include/config/auto.conf"

to avoid a shellcheck warning.

Quoted 17 lines
scripts/setlocalversion +2 -3
        echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
        exit 1
 fi
 
 # version string from CONFIG_LOCALVERSION
-config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' include/config/auto.conf)
+config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' ${objtree}/include/config/auto.conf)
 
 # scm version string if not at the kernel version tag or at the file_localversion
-if grep -q "^CONFIG_LOCALVERSION_AUTO=y$" include/config/auto.conf; then
+if grep -q "^CONFIG_LOCALVERSION_AUTO=y$" ${objtree}/include/config/auto.conf; then
        # full scm version string
        scm_version="$(scm_version)"
 elif [ "${LOCALVERSION+set}" != "set" ]; then
--

2.49.0.rc1.451.g8f38331e32-goog

Signature · 2 lines
Best Regards
Masahiro Yamada
#7 lore raw
Quoted 17 lines · Masahiro Yamada
Quoted 6 lines · HONG Yifan

setlocalversion reads include/config/auto.conf, which is located below $(objtree) with commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some in-kernel build artifacts").

To be consistent, the setlocalversion script should use

"To be consistent" is too weak because we do not add $(objtree)/ to include/config/auto.conf

Just run "git grep include/config/auto.conf"

You will see more include/config/auto.conf instances that lack $(objtree)/ prefix.

Quoted 7 lines

So, "To be consistent" is not a reason.

You described why Google needs to have this
specifically scripts/setlocalversion.

Without that explained, I do not understand _why_.

Without the context of Google's out-of-tree patch, I can't really think of any good reason other than "To be consistent". Would it be better if I quote
https://lore.kernel.org/all/[email protected]/
("[PATCH v6] modules: introduce the MODULE_SCMVERSION config") in the commit message, explaining that "prepending $(objtree)/ is required for this other patch to work"?

Quoted 56 lines
Quoted 18 lines

${objtree}/include/config/auto.conf as well.

---
v1: https://lore.kernel.org/lkml/[email protected]/
v1 -> v2: fixed the other two locations of include/config/auto.conf in setlocalversion script; also removed incorrect claim in commit message.

 scripts/setlocalversion | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/setlocalversion +0 -0
index 28169d7e143b..c13fe6e585e9 100755

scripts/setlocalversion if ${no_local}; then · line 189

Quoted 5 lines
scripts/setlocalversion +1 -1
@@ -186,16 +186,16 @@ if ${no_local}; then
        exit 0
 fi
 
-if ! test -e include/config/auto.conf; then
+if ! test -e ${objtree}/include/config/auto.conf; then

Please quote

"${objtree}/include/config/auto.conf"

to avoid a shellcheck warning.

Quoted 15 lines
scripts/setlocalversion +2 -3
        echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
        exit 1
 fi
 
 # version string from CONFIG_LOCALVERSION
-config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' include/config/auto.conf)
+config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' ${objtree}/include/config/auto.conf)
 
 # scm version string if not at the kernel version tag or at the file_localversion
-if grep -q "^CONFIG_LOCALVERSION_AUTO=y$" include/config/auto.conf; then
+if grep -q "^CONFIG_LOCALVERSION_AUTO=y$" ${objtree}/include/config/auto.conf; then
        # full scm version string
        scm_version="$(scm_version)"
 elif [ "${LOCALVERSION+set}" != "set" ]; then
--
Quoted 2 lines

2.49.0.rc1.451.g8f38331e32-goog

--
Best Regards
Masahiro Yamada