From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: "Masahiro Yamada" <masahiroy@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nicolas@fjasle.eu>,
"Richard Weinberger" <richard@nod.at>,
"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
"Johannes Berg" <johannes@sipsolutions.net>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Jonathan Corbet" <corbet@lwn.net>, "Alex Shi" <alexs@kernel.org>,
"Yanteng Si" <siyanteng@loongson.cn>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-um@lists.infradead.org, rust-for-linux@vger.kernel.org,
linux-mips@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, llvm@lists.linux.dev,
Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [PATCH 1/3] rust: Introduce HAVE_GENERATE_RUST_TARGET config option
Date: Tue, 03 Sep 2024 18:14:34 +0100 [thread overview]
Message-ID: <20240903-mips-rust-v1-1-0fdf0b2fd58f@flygoat.com> (raw)
In-Reply-To: <20240903-mips-rust-v1-0-0fdf0b2fd58f@flygoat.com>
scripts/generate_rust_target.rs is used by several architectures
to generate target.json target spec file.
However the enablement of this feature was controlled by target
specific Makefile pieces spreading everywhere.
Introduce HAVE_GENERATE_RUST_TARGET config option as a centralized
switch to control the per-arch usage of generate_rust_target.rs.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
Makefile | 4 ++++
arch/Kconfig | 8 ++++++++
arch/um/Kconfig | 1 +
arch/x86/Makefile | 1 -
arch/x86/Makefile.um | 1 -
rust/Makefile | 2 +-
scripts/Makefile | 4 +---
7 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 2c1db7a6f793..1310e7910fc4 100644
--- a/Makefile
+++ b/Makefile
@@ -560,6 +560,7 @@ KBUILD_RUSTFLAGS := $(rust_common_flags) \
-Zfunction-sections=n \
-Wclippy::float_arithmetic
+
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
KBUILD_RUSTFLAGS_KERNEL :=
@@ -807,6 +808,9 @@ KBUILD_CFLAGS += -Os
KBUILD_RUSTFLAGS += -Copt-level=s
endif
+ifdef CONFIG_HAVE_GENERATE_RUST_TARGET
+KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
+endif
# Always set `debug-assertions` and `overflow-checks` because their default
# depends on `opt-level` and `debug-assertions`, respectively.
KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
diff --git a/arch/Kconfig b/arch/Kconfig
index 4e2eaba9e305..eb3ff6cf8501 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -377,6 +377,14 @@ config HAVE_RUST
This symbol should be selected by an architecture if it
supports Rust.
+config HAVE_GENERATE_RUST_TARGET
+ bool
+ depends on HAVE_RUST
+ help
+ This symbol should be selected by an architecture if it
+ supports generating Rust target files with
+ scripts/generate_rust_target.rs.
+
config HAVE_FUNCTION_ARG_ACCESS_API
bool
help
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index dca84fd6d00a..414e5b01d575 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -32,6 +32,7 @@ config UML
select TTY # Needed for line.c
select HAVE_ARCH_VMAP_STACK
select HAVE_RUST
+ select HAVE_GENERATE_RUST_TARGET if X86_32 || X86_64
select ARCH_HAS_UBSAN
config MMU
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index a1883a30a5d8..cbd707f88a63 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -75,7 +75,6 @@ export BITS
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
#
KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
-KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
#
diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um
index a46b1397ad01..2106a2bd152b 100644
--- a/arch/x86/Makefile.um
+++ b/arch/x86/Makefile.um
@@ -9,7 +9,6 @@ core-y += arch/x86/crypto/
#
ifeq ($(CONFIG_CC_IS_CLANG),y)
KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
-KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
endif
diff --git a/rust/Makefile b/rust/Makefile
index 99204e33f1dd..fe3640b98011 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -378,7 +378,7 @@ $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--re
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
+$(call if_changed_rule,rustc_library)
-ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),)
+ifdef CONFIG_HAVE_GENERATE_RUST_TARGET
$(obj)/core.o: scripts/target.json
endif
diff --git a/scripts/Makefile b/scripts/Makefile
index dccef663ca82..33258a856a1a 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -12,13 +12,11 @@ hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder
hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen
-ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),)
-always-$(CONFIG_RUST) += target.json
+always-$(CONFIG_HAVE_GENERATE_RUST_TARGET) += target.json
filechk_rust_target = $< < include/config/auto.conf
$(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE
$(call filechk,rust_target)
-endif
hostprogs += generate_rust_target
generate_rust_target-rust := y
--
2.46.0
next prev parent reply other threads:[~2024-09-03 17:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 17:14 [PATCH 0/3] rust: Initial MIPS support Jiaxun Yang
2024-09-03 17:14 ` Jiaxun Yang [this message]
2024-09-03 17:43 ` [PATCH 1/3] rust: Introduce HAVE_GENERATE_RUST_TARGET config option Miguel Ojeda
2024-09-03 17:57 ` Johannes Berg
2024-09-03 17:14 ` [PATCH 2/3] MIPS: Rename mips_instruction type to workaround bindgen issue Jiaxun Yang
2024-09-03 17:43 ` Miguel Ojeda
2024-09-03 17:54 ` Jiaxun Yang
2024-09-04 8:12 ` Geert Uytterhoeven
2024-09-06 9:03 ` Maciej W. Rozycki
2024-09-03 17:14 ` [PATCH 3/3] rust: Enable for MIPS Jiaxun Yang
2024-09-03 17:44 ` Miguel Ojeda
2024-09-03 17:53 ` Jiaxun Yang
2024-09-03 18:17 ` Miguel Ojeda
2024-09-03 18:31 ` Jiaxun Yang
2024-09-03 19:01 ` Miguel Ojeda
2024-09-04 7:38 ` Jiaxun Yang
2024-09-04 8:28 ` Miguel Ojeda
2024-09-03 17:45 ` [PATCH 0/3] rust: Initial MIPS support 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=20240903-mips-rust-v1-1-0fdf0b2fd58f@flygoat.com \
--to=jiaxun.yang@flygoat.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=alexs@kernel.org \
--cc=aliceryhl@google.com \
--cc=anton.ivanov@cambridgegreys.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=gary@garyguo.net \
--cc=hpa@zytor.com \
--cc=johannes@sipsolutions.net \
--cc=justinstitt@google.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=masahiroy@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
--cc=ojeda@kernel.org \
--cc=richard@nod.at \
--cc=rostedt@goodmis.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=siyanteng@loongson.cn \
--cc=tglx@linutronix.de \
--cc=tsbogend@alpha.franken.de \
--cc=wedsonaf@gmail.com \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).