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

From: Nicolas Schier

Date: Tue Apr 07 2026 - 16:30:39 EST


On Tue, Mar 31, 2026 at 03:08:01AM +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
> exec 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>
> ---
> v5 -> v6:
> - Add fix to `rust/Makefile` as well (Yoann)
> - Include script to `.gitignore` and make clean (Nicolas)
> - Add back the outer `exec` to the command

What is the reason for re-adding the 'exec'?


--
Nicolas