rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: Respect HOSTCC when linking for host
@ 2023-09-15 17:28 Matthew Maurer
  2023-09-15 22:51 ` Martin Rodriguez Reboredo
  2023-09-16 16:52 ` Finn Behrens
  0 siblings, 2 replies; 13+ messages in thread
From: Matthew Maurer @ 2023-09-15 17:28 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Masahiro Yamada
  Cc: Matthew Maurer, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, rust-for-linux, linux-kernel,
	linux-kbuild

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@google.com>
---
 rust/Makefile         | 1 +
 scripts/Makefile.host | 1 +
 2 files changed, 2 insertions(+)

diff --git a/rust/Makefile b/rust/Makefile
index 87958e864be0..2a2352638f11 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -383,6 +383,7 @@ $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE
 quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
       cmd_rustc_procmacro = \
 	$(RUSTC_OR_CLIPPY) $(rust_common_flags) \
+		-C linker-flavor=gcc -C linker=$(HOSTCC) \
 		--emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
 		--crate-type proc-macro \
 		--crate-name $(patsubst lib%.so,%,$(notdir $@)) $<
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 8f7f842b54f9..0aa95a3af1c4 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -91,6 +91,7 @@ hostcxx_flags  = -Wp,-MMD,$(depfile) \
 # current working directory, which may be not accessible in the out-of-tree
 # modules case.
 hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \
+		 -C linker-flavor=gcc -C linker=$(HOSTCC) \
                  $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \
                  $(HOSTRUSTFLAGS_$(target-stem))
 
-- 
2.42.0.459.ge4e396fd5e-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-09-26 16:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-15 17:28 [PATCH] rust: Respect HOSTCC when linking for host Matthew Maurer
2023-09-15 22:51 ` Martin Rodriguez Reboredo
2023-09-16 16:52 ` Finn Behrens
2023-09-16 17:53   ` Björn Roy Baron
2023-09-16 18:06     ` Finn Behrens
2023-09-16 19:54       ` Matthew Maurer
2023-09-16 22:39         ` Finn Behrens
2023-09-17 13:24         ` Martin Rodriguez Reboredo
2023-09-18 15:24         ` Nick Desaulniers
2023-09-18 16:38           ` Matthew Maurer
2023-09-18 18:43             ` Nick Desaulniers
2023-09-18 18:55               ` Matthew Maurer
2023-09-26 16:51                 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).