From: Nathan Chancellor <nathan@kernel.org>
To: Mohamad Alsadhan <mo@sdhn.cc>, Miguel Ojeda <ojeda@kernel.org>
Cc: nsc@kernel.org, linux-kbuild@vger.kernel.org,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kbuild: host: use single executable for rustc -C linker
Date: Wed, 25 Feb 2026 14:45:23 -0700 [thread overview]
Message-ID: <20260225214523.GA4062959@ax162> (raw)
In-Reply-To: <20260225102819.16553-1-mo@sdhn.cc>
On Wed, Feb 25, 2026 at 01:28:19PM +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 ...
>
> Use the last word of HOSTCC as the linker executable for host
> Rust tools. This preserves wrapper usage for C host tools while
> ensuring rustc receives a single executable path.
>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1224
>
> Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc>
Miguel, as this is a Rust fix, do you want to take it? If so:
Acked-by: Nathan Chancellor <nathan@kernel.org>
Otherwise, I could take it via kbuild-fixes for 7.0.
> ---
> scripts/Makefile.host | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.host b/scripts/Makefile.host
> index c1dedf646..22eab2734 100644
> --- a/scripts/Makefile.host
> +++ b/scripts/Makefile.host
> @@ -87,11 +87,18 @@ hostcxx_flags = -Wp,-MMD,$(depfile) \
> $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
> $(HOSTCXXFLAGS_$(target-stem).o)
>
> +# rustc's `-C linker=` expects a single executable path, not a command line.
> +# HOSTCC may be a multi-word command when wrapped (e.g. "ccache gcc"),
> +# which would otherwise be split by the shell and mis-parsed by rustc.
> +#
> +# Use a dedicated variable for the linker program used by host Rust tools.
> +HOSTRUSTC_LINKER ?= $(lastword $(HOSTCC))
I would probably use HOSTRUSTC_LD to mirror how the rest of Kbuild
refers to the linker.
> +
> # `--out-dir` is required to avoid temporaries being created by `rustc` in the
> # current working directory, which may be not accessible in the out-of-tree
> # modules case.
> hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \
> - -Clinker-flavor=gcc -Clinker=$(HOSTCC) \
> + -Clinker-flavor=gcc -Clinker=$(HOSTRUSTC_LINKER) \
> -Clink-args='$(call escsq,$(KBUILD_HOSTLDFLAGS))' \
> $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \
> $(HOSTRUSTFLAGS_$(target-stem))
> --
> 2.52.0
>
next prev parent reply other threads:[~2026-02-25 21:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 10:28 [PATCH] kbuild: host: use single executable for rustc -C linker Mohamad Alsadhan
2026-02-25 21:45 ` Nathan Chancellor [this message]
2026-02-26 10:12 ` Gary Guo
2026-02-27 13:27 ` [PATCH v2] " Mohamad Alsadhan
2026-03-11 5:56 ` Miguel Ojeda
2026-03-11 9:35 ` Mohamad Alsadhan
2026-03-11 14:02 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260225214523.GA4062959@ax162 \
--to=nathan@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mo@sdhn.cc \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox