Re: [PATCH v8] kbuild: host: use single executable for rustc -C linker
From: Nathan Chancellor
Date: Mon May 11 2026 - 03:01:46 EST
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 \
> + scripts/rustc-wrapper
What tree was this generated against? It conflicts with Linus's tree due
to commit a76e30c2479c ("kbuild: Delete .builtin-dtbs.S when running
make clean") that landed in 7.0-rc6.
>
> # Directories & files removed with 'make mrproper'
> MRPROPER_FILES += include/config include/generated \
--
Cheers,
Nathan