Skip to contentSkip to conversation

kbuild: install-extmod-build: Fix build when specifying KBUILD_OUTPUT

PATCH Superseded Inochi Amaoto 2 participants 2 messages Feb 23, 2025 – Mar 5, 2025 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: install-extmod-build: Fix build when specifying KBUILD_OUTPUT

Since commit 5f73e7d0386d ("kbuild: refactor cross-compiling linux-headers package"), the linux-headers pacman package fails to build when "O=" is set. The build system complains:

/mnt/chroot/linux/scripts/Makefile.build:41: mnt/chroots/linux-mainline/pacman/linux-upstream/pkg/linux-upstream-headers/usr//lib/modules/6.14.0-rc3-00350-g771dba31fffc/build/scripts/Makefile: No such file or directory

This is because the "srcroot" variable is set to "." and the "build" variable is set to the absolute path. This makes the "src" variables point to wrong directory.

Change the "build" variable to a relative path to "." to fix build.

Fixes 5f73e7d0386d ("kbuild: refactor cross-compiling linux-headers package")
---
 scripts/package/install-extmod-build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/install-extmod-build +1 -1
index 2966473b4660..c0357ba2ff72 100755
@@ -63,7 +63,7 @@ if [ "${CC}" != "${HOSTCC}" ]; then
 	# Clear VPATH and srcroot because the source files reside in the output
 	# directory.
 	# shellcheck disable=SC2016 # $(MAKE) and $(build) will be expanded by Make
-	"${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC='"${CC}"' VPATH= srcroot=. $(build)='"${destdir}"/scripts
+	"${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC='"${CC}"' VPATH= srcroot=. $(build)='"$(realpath --relative-base=. ${destdir})"/scripts
 
 	rm -f "${destdir}/scripts/Kbuild"
 fi
Signature · 1 line
2.48.1
#1 lore raw
Quoted 25 lines · Inochi Amaoto

Since commit 5f73e7d0386d ("kbuild: refactor cross-compiling linux-headers package"), the linux-headers pacman package fails to build when "O=" is set. The build system complains:

/mnt/chroot/linux/scripts/Makefile.build:41: mnt/chroots/linux-mainline/pacman/linux-upstream/pkg/linux-upstream-headers/usr//lib/modules/6.14.0-rc3-00350-g771dba31fffc/build/scripts/Makefile: No such file or directory

This is because the "srcroot" variable is set to "." and the "build" variable is set to the absolute path. This makes the "src" variables point to wrong directory.

Change the "build" variable to a relative path to "." to fix build.

Fixes 5f73e7d0386d ("kbuild: refactor cross-compiling linux-headers package")
---
 scripts/package/install-extmod-build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/install-extmod-build +0 -0
index 2966473b4660..c0357ba2ff72 100755

scripts/package/install-extmod-build if [ "${CC}" != "${HOSTCC}" ]; then · line 66

Quoted 5 lines
scripts/package/install-extmod-build +1 -1
@@ -63,7 +63,7 @@ if [ "${CC}" != "${HOSTCC}" ]; then
        # Clear VPATH and srcroot because the source files reside in the output
        # directory.
        # shellcheck disable=SC2016 # $(MAKE) and $(build) will be expanded by Make
-       "${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC='"${CC}"' VPATH= srcroot=. $(build)='"${destdir}"/scripts
+       "${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC='"${CC}"' VPATH= srcroot=. $(build)='"$(realpath --relative-base=. ${destdir})"/scripts

Looks good to me, but a nit.

This will introduce a new shellcheck warning:

C2086 (info): Double quote to prevent globbing and word splitting.

Please keep the double-quotes around ${destdir}

"$(realpath --relative-base=. "${destdir}")"

Quoted 5 lines
scripts/package/install-extmod-build +0 -1
        rm -f "${destdir}/scripts/Kbuild"
 fi
--

2.48.1

--
Best Regards
Masahiro Yamada