[<prev] [next>] [day] [month] [year] [list]
Message-ID: <9AE2FD1B8A570866+20250513101106.28584-1-xizheyin@smail.nju.edu.cn>
Date: Tue, 13 May 2025 18:11:06 +0800
From: Xizhe Yin <xizheyin@...il.nju.edu.cn>
To: linux-kernel@...r.kernel.org,
linux-kbuild@...r.kernel.org,
rust-for-linux@...r.kernel.org
Cc: Masahiro Yamada <masahiroy@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nicolas.schier@...ux.dev>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>,
xizheyin <xizheyin@...il.nju.edu.cn>
Subject: [PATCH] rust: rename expanded Rust file extension from .rsi to .expanded.rs
From: xizheyin <xizheyin@...il.nju.edu.cn>
The build system currently uses .rsi as the extension for expanded
Rust files. This extension comes from the C/assembly world and is not
recognized as a Rust file, making it both unintuitive and hard to
remember.
Rename the extension to .expanded.rs, which clearly indicates the file
contains expanded Rust code. Use source file basename for --crate-name
to prevent rustc from treating .expanded as part of the crate name.
Link: https://github.com/Rust-for-Linux/linux/issues/1158
Closes: https://github.com/Rust-for-Linux/linux/issues/1158
Suggested-by: Benno Lossin <benno.lossin@...ton.me>
Signed-off-by: xizheyin <xizheyin@...il.nju.edu.cn>
---
.gitignore | 2 +-
Makefile | 6 +++---
scripts/Makefile.build | 10 +++++-----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/.gitignore b/.gitignore
index f2f63e47fb88..c6786f5d5d24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,7 +42,7 @@
*.patch
*.rmeta
*.rpm
-*.rsi
+*.expanded.rs
*.s
*.so
*.so.dbg
diff --git a/Makefile b/Makefile
index 64c514f4bc19..443719123eb5 100644
--- a/Makefile
+++ b/Makefile
@@ -298,7 +298,7 @@ no-dot-config-targets := $(clean-targets) \
outputmakefile rustavailable rustfmt rustfmtcheck
no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
image_name
-single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/
+single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.expanded.rs %.s %/
config-build :=
mixed-build :=
@@ -1714,7 +1714,7 @@ help:
@echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
@echo ' (requires kernel .config)'
@echo ' dir/file.[os] - Build specified target only'
- @echo ' dir/file.rsi - Build macro expanded source, similar to C preprocessing.'
+ @echo ' dir/file.expanded.rs - Build macro expanded source, similar to C preprocessing.'
@echo ' Run with RUSTFMT=n to skip reformatting if needed.'
@echo ' The output is not intended to be compilable.'
@echo ' dir/file.ll - Build the LLVM assembly file'
@@ -2011,7 +2011,7 @@ $(clean-dirs):
clean: $(clean-dirs)
$(call cmd,rmfiles)
@find . $(RCS_FIND_IGNORE) \
- \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
+ \( -name '*.[aios]' -o -name '*.expanded.rs' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '*.ko.*' \
-o -name '*.dtb' -o -name '*.dtbo' \
-o -name '*.dtb.S' -o -name '*.dtbo.S' \
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index da2d720c964a..77b4a54ae2eb 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -244,7 +244,7 @@ rust_common_cmd = \
-Zcrate-attr='feature($(rust_allowed_features))' \
-Zunstable-options --extern pin_init --extern kernel \
--crate-type rlib -L $(objtree)/rust/ \
- --crate-name $(basename $(notdir $@)) \
+ --crate-name $(basename $(notdir $<)) \
--sysroot=/dev/null \
--out-dir $(dir $@) --emit=dep-info=$(depfile)
@@ -267,13 +267,13 @@ endef
$(obj)/%.o: $(obj)/%.rs FORCE
+$(call if_changed_rule,rustc_o_rs)
-quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
- cmd_rustc_rsi_rs = \
+quiet_cmd_rustc_expanded_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
+ cmd_rustc_expanded_rs = \
$(rust_common_cmd) -Zunpretty=expanded $< >$@; \
command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@
-$(obj)/%.rsi: $(obj)/%.rs FORCE
- +$(call if_changed_dep,rustc_rsi_rs)
+$(obj)/%.expanded.rs: $(obj)/%.rs FORCE
+ +$(call if_changed_dep,rustc_expanded_rs)
quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $<
--
2.49.0
Powered by blists - more mailing lists