linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: install-extmod-build: Properly fix CC expansion when ccache is used
@ 2025-11-09 22:26 Abel Vesa
  2025-11-09 23:41 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Abel Vesa @ 2025-11-09 22:26 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Masahiro Yamada
  Cc: Jeff Johnson, linux-kbuild, linux-kernel, Abel Vesa

Currently, when cross-compiling and ccache is used, the expanding of CC
turns out to be without any quotes, leading to the following error:

make[4]: *** No rule to make target 'aarch64-linux-gnu-gcc'.  Stop.
make[3]: *** [Makefile:2164: run-command] Error 2

And it makes sense, because after expansion it ends up like this:

make run-command KBUILD_RUN_COMMAND=+$(MAKE) \
HOSTCC=ccache aarch64-linux-gnu-gcc VPATH= srcroot=. $(build)= ...

So add another set of double quotes, this time escaped, to make sure the
aarch64-linux-gnu-gcc isn't expanded to something that looks like an
entirely separate target.

Fixes: 140332b6ed72 ("kbuild: fix linux-headers package build when $(CC) cannot link userspace")
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
 scripts/package/install-extmod-build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/package/install-extmod-build b/scripts/package/install-extmod-build
index 054fdf45cc37a8717444b8094daf3e1150a8ccf5..6cce5c41552d520bf069487352fd26417b0b3899 100755
--- a/scripts/package/install-extmod-build
+++ b/scripts/package/install-extmod-build
@@ -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)='"$(realpath --relative-to=. "${destdir}")"/scripts
+	"${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC='\""${CC}"\"' VPATH= srcroot=. $(build)='"$(realpath --relative-to=. "${destdir}")"/scripts
 
 	rm -f "${destdir}/scripts/Kbuild"
 fi

---
base-commit: 9c0826a5d9aa4d52206dd89976858457a2a8a7ed
change-id: 20251109-kbuild-install-extmod-build-fix-cc-expand-third-try-2cb1540cadbf

Best regards,
-- 
Abel Vesa <abel.vesa@linaro.org>


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

* Re: [PATCH] kbuild: install-extmod-build: Properly fix CC expansion when ccache is used
  2025-11-09 22:26 [PATCH] kbuild: install-extmod-build: Properly fix CC expansion when ccache is used Abel Vesa
@ 2025-11-09 23:41 ` Nathan Chancellor
  2025-11-10  8:28   ` Abel Vesa
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2025-11-09 23:41 UTC (permalink / raw)
  To: Abel Vesa
  Cc: Nicolas Schier, Masahiro Yamada, Jeff Johnson, linux-kbuild,
	linux-kernel

On Mon, Nov 10, 2025 at 12:26:31AM +0200, Abel Vesa wrote:
> Currently, when cross-compiling and ccache is used, the expanding of CC
> turns out to be without any quotes, leading to the following error:
> 
> make[4]: *** No rule to make target 'aarch64-linux-gnu-gcc'.  Stop.
> make[3]: *** [Makefile:2164: run-command] Error 2
> 
> And it makes sense, because after expansion it ends up like this:
> 
> make run-command KBUILD_RUN_COMMAND=+$(MAKE) \
> HOSTCC=ccache aarch64-linux-gnu-gcc VPATH= srcroot=. $(build)= ...

Yup, good old shell quoting... :(

> So add another set of double quotes, this time escaped, to make sure the
> aarch64-linux-gnu-gcc isn't expanded to something that looks like an
> entirely separate target.
> 
> Fixes: 140332b6ed72 ("kbuild: fix linux-headers package build when $(CC) cannot link userspace")
> Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> ---
>  scripts/package/install-extmod-build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/package/install-extmod-build b/scripts/package/install-extmod-build
> index 054fdf45cc37a8717444b8094daf3e1150a8ccf5..6cce5c41552d520bf069487352fd26417b0b3899 100755
> --- a/scripts/package/install-extmod-build
> +++ b/scripts/package/install-extmod-build
> @@ -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)='"$(realpath --relative-to=. "${destdir}")"/scripts
> +	"${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC='\""${CC}"\"' VPATH= srcroot=. $(build)='"$(realpath --relative-to=. "${destdir}")"/scripts

Can we avoid the need for escaping the " by just moving it to the other
side of the '?

  "${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC="'"${CC}"'" VPATH= srcroot=. $(build)='"$(realpath --relative-to=. "${destdir}")"/scripts

This whole command is really hard to read but I don't really see an
obvious way to simplify it.

>  
>  	rm -f "${destdir}/scripts/Kbuild"
>  fi
> 
> ---
> base-commit: 9c0826a5d9aa4d52206dd89976858457a2a8a7ed
> change-id: 20251109-kbuild-install-extmod-build-fix-cc-expand-third-try-2cb1540cadbf
> 
> Best regards,
> -- 
> Abel Vesa <abel.vesa@linaro.org>
> 

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

* Re: [PATCH] kbuild: install-extmod-build: Properly fix CC expansion when ccache is used
  2025-11-09 23:41 ` Nathan Chancellor
@ 2025-11-10  8:28   ` Abel Vesa
  0 siblings, 0 replies; 3+ messages in thread
From: Abel Vesa @ 2025-11-10  8:28 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nicolas Schier, Masahiro Yamada, Jeff Johnson, linux-kbuild,
	linux-kernel

On 25-11-09 16:41:24, Nathan Chancellor wrote:
> On Mon, Nov 10, 2025 at 12:26:31AM +0200, Abel Vesa wrote:
> > Currently, when cross-compiling and ccache is used, the expanding of CC
> > turns out to be without any quotes, leading to the following error:
> > 
> > make[4]: *** No rule to make target 'aarch64-linux-gnu-gcc'.  Stop.
> > make[3]: *** [Makefile:2164: run-command] Error 2
> > 
> > And it makes sense, because after expansion it ends up like this:
> > 
> > make run-command KBUILD_RUN_COMMAND=+$(MAKE) \
> > HOSTCC=ccache aarch64-linux-gnu-gcc VPATH= srcroot=. $(build)= ...
> 
> Yup, good old shell quoting... :(
> 
> > So add another set of double quotes, this time escaped, to make sure the
> > aarch64-linux-gnu-gcc isn't expanded to something that looks like an
> > entirely separate target.
> > 
> > Fixes: 140332b6ed72 ("kbuild: fix linux-headers package build when $(CC) cannot link userspace")
> > Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> > ---
> >  scripts/package/install-extmod-build | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/package/install-extmod-build b/scripts/package/install-extmod-build
> > index 054fdf45cc37a8717444b8094daf3e1150a8ccf5..6cce5c41552d520bf069487352fd26417b0b3899 100755
> > --- a/scripts/package/install-extmod-build
> > +++ b/scripts/package/install-extmod-build
> > @@ -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)='"$(realpath --relative-to=. "${destdir}")"/scripts
> > +	"${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC='\""${CC}"\"' VPATH= srcroot=. $(build)='"$(realpath --relative-to=. "${destdir}")"/scripts
> 
> Can we avoid the need for escaping the " by just moving it to the other
> side of the '?
> 
>   "${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC="'"${CC}"'" VPATH= srcroot=. $(build)='"$(realpath --relative-to=. "${destdir}")"/scripts
> 

Yep, this does the trick.

Will send v2.

> This whole command is really hard to read but I don't really see an
> obvious way to simplify it.

Yeah, the only part I think can be simplied is pre-expanding the value
after $(build)=, maybe ...

> 
> >  
> >  	rm -f "${destdir}/scripts/Kbuild"
> >  fi
> > 
> > ---
> > base-commit: 9c0826a5d9aa4d52206dd89976858457a2a8a7ed
> > change-id: 20251109-kbuild-install-extmod-build-fix-cc-expand-third-try-2cb1540cadbf
> > 
> > Best regards,
> > -- 
> > Abel Vesa <abel.vesa@linaro.org>
> > 

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

end of thread, other threads:[~2025-11-10  8:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-09 22:26 [PATCH] kbuild: install-extmod-build: Properly fix CC expansion when ccache is used Abel Vesa
2025-11-09 23:41 ` Nathan Chancellor
2025-11-10  8:28   ` Abel Vesa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).