Re: [PATCH v8] kbuild: host: use single executable for rustc -C linker

From: Nicolas Schier

Date: Mon May 11 2026 - 07:26:15 EST


On Mon, May 11, 2026 at 03:59:15PM +0900, Nathan Chancellor wrote:
> Hi Mohamad,
>
> On Sat, May 09, 2026 at 01:19:38PM +0300, Mohamad Alsadhan wrote:
> > rustc's -C linker= option expects a single executable path. When
> > HOSTCC contains a wrapper (e.g. "ccache gcc"), passing
> > `-Clinker=$(HOSTCC)` results in the shell splitting the value into
> > multiple words, and rustc interprets the additional word as an
> > input filename:
> >
> > error: multiple input filenames provided ...
> >
> > Generate a small wrapper script and pass it to -Clinker e.g.
> >
> > ```
> > #!/bin/sh
> > ccache gcc "$@"
> > ```
> >
> > Note that the wrapper intentionally avoids a leading `exec` to
> > naturally support leading environment assignments such as:
> > `VAR=VAL ccache gcc`.
> >
> > This fix should be general enough to address most if not all cases
> > (incl. wrappers or subcommands) and avoids surprises of simpler fixes
> > like just defaulting to gcc.
> >
> > This avoids passing the user command as an environment variable as
> > that would be more challenging to trace and debug shell expansions.
> >
> > Link: https://github.com/Rust-for-Linux/linux/issues/1224
> > Suggested-by: Yoann Congal <yoann.congal@xxxxxxxx>
> > Signed-off-by: Mohamad Alsadhan <mo@xxxxxxx>
>
> Thanks, this seems reasonable from a Kbuild perspective (although
> Nicolas may have other comments) and it appears to work for me. I expect
> this to go via the Rust tree.
>
> Acked-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx>
>
> > diff --git a/Makefile b/Makefile
> > index 1a219bf1c..5ebeef67f 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1651,7 +1651,8 @@ CLEAN_FILES += vmlinux.symvers modules-only.symvers \
> > modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
> > compile_commands.json rust/test \
> > rust-project.json .vmlinux.objs .vmlinux.export.c \
> > - .builtin-dtbs-list .builtin-dtb.S
> > + .builtin-dtbs-list .builtin-dtb.S \

(If it'd go through kbuild, I'd fix the spaces-only here during patch
application.)

Thanks, no further objections.

Reviewed-by: Nicolas Schier <nsc@xxxxxxxxxx>

--
Nicolas