FROMLIST: rust: add PROCMACROLDFLAGS

These are additional flags to be passed when linking proc macros for the
Rust toolchain. If unset, it defaults to $(HOSTLDFLAGS).

This is needed because the list of flags to link hostprogs is not
necessarily the same as the list of flags used to link libmacros.so.
When we build proc macros, we need the latter, not the
former. To distinguish between the two, introduce this new variable
to stand out from HOSTLDFLAGS used to link other host progs.

Signed-off-by: HONG Yifan <elsk@google.com>

Bug: 373900675
Link: https://lore.kernel.org/r/20241017210430.2401398-2-elsk@google.com
Change-Id: Ifc678501880633e1074fea24bf1c4ec563b07a7e
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
HONG Yifan
2024-10-17 21:04:30 +00:00
committed by Treehugger Robot
parent ef1f4c9120
commit 5ff498e7bc
3 changed files with 9 additions and 1 deletions
+7
View File
@@ -96,6 +96,13 @@ HOSTRUSTFLAGS
-------------
Additional flags to be passed to $(HOSTRUSTC) when building host programs.
PROCMACROLDFLAGS
-------------
Additional flags to be passed when linking Rust proc macros. Since proc macros
are loaded by rustc at build time, they must be linked in a way that is
compatible with the rustc toolchain being used. If unset, it defaults to
$(HOSTLDFLAGS).
HOSTLDFLAGS
-----------
Additional flags to be passed when linking host programs.
+1
View File
@@ -483,6 +483,7 @@ KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \
-I $(srctree)/scripts/include
KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
-Zallow-features= $(HOSTRUSTFLAGS)
KBUILD_PROCMACROLDFLAGS := $(or $(PROCMACROLDFLAGS),$(HOSTLDFLAGS))
KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
+1 -1
View File
@@ -336,7 +336,7 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
cmd_rustc_procmacro = \
$(RUSTC_OR_CLIPPY) $(rust_common_flags) \
-Clinker-flavor=gcc -Clinker=$(HOSTCC) \
-Clink-args='$(call escsq,$(KBUILD_HOSTLDFLAGS))' \
-Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \
--emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
--crate-type proc-macro \
--crate-name $(patsubst lib%.so,%,$(notdir $@)) $<