Re: [PATCH v2] rust: Respect HOSTCC when linking for host

From: Martin Rodriguez Reboredo
Date: Tue Sep 19 2023 - 15:18:20 EST


On 9/18/23 20:43, Matthew Maurer wrote:
Currently, rustc defaults to invoking `cc`, even if `HOSTCC` is defined,
resulting in build failures in hermetic environments where `cc` does not
exist. This includes both hostprogs and proc-macros.

Since we are setting the linker to `HOSTCC`, we set the linker flavor to
`gcc` explicitly.

Signed-off-by: Matthew Maurer <mmaurer@xxxxxxxxxx>
---

Updated the patch to reflect Nick's comment that KBUILD_HOSTLDFLAGS
should be respected as well.

I did not switch it to use HOSTLD for two reasons:
* That variable is not globally defined - it is only available in two
subdirectories of tools/
* C host scripts are linked by HOSTCC as well, even when linking a
collection of object files. It *prints* HOSTLD, but invokes HOSTCC.
See scripts/Makefile.host cmd_host-cmulti for an example.
[...]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@xxxxxxxxx>