* [PATCH] LoongArch: rust: Use rustc option -Zdirect-access-external-data
@ 2024-07-03 11:06 WANG Rui
2024-07-08 17:52 ` Miguel Ojeda
0 siblings, 1 reply; 2+ messages in thread
From: WANG Rui @ 2024-07-03 11:06 UTC (permalink / raw)
To: Huacai Chen
Cc: WANG Xuerui, Xi Ruoyao, Xuefeng Li, loongarch, rust-for-linux,
linux-kernel, loongson-kernel, WANG Rui
-Zdirect-access-external-data is a new Rust compiler option added
in Rust 1.78, which we use to optimize the access of external data
in the Linux kernel's Rust code. This patch modifies the Rust code
in vmlinux to directly access externa data, using PC-REL instead of
GOT. However, Rust code whithin modules is constrained by the PC-REL
addressing range and is explicitly set to use an indirect method.
Signed-off-by: WANG Rui <wangrui@loongson.cn>
---
arch/loongarch/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index 8674e7e24c4a..ae3f80622f4c 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -105,7 +105,8 @@ KBUILD_CFLAGS += -fno-jump-tables
endif
KBUILD_RUSTFLAGS += --target=loongarch64-unknown-none-softfloat
-KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic
+KBUILD_RUSTFLAGS_KERNEL += -Zdirect-access-external-data=yes
+KBUILD_RUSTFLAGS_MODULE += -Zdirect-access-external-data=no
ifeq ($(CONFIG_RELOCATABLE),y)
KBUILD_CFLAGS_KERNEL += -fPIE
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] LoongArch: rust: Use rustc option -Zdirect-access-external-data
2024-07-03 11:06 [PATCH] LoongArch: rust: Use rustc option -Zdirect-access-external-data WANG Rui
@ 2024-07-08 17:52 ` Miguel Ojeda
0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2024-07-08 17:52 UTC (permalink / raw)
To: WANG Rui
Cc: Huacai Chen, WANG Xuerui, Xi Ruoyao, Xuefeng Li, loongarch,
rust-for-linux, linux-kernel, loongson-kernel
On Wed, Jul 3, 2024 at 1:24 PM WANG Rui <wangrui@loongson.cn> wrote:
>
> -Zdirect-access-external-data is a new Rust compiler option added
> in Rust 1.78, which we use to optimize the access of external data
> in the Linux kernel's Rust code. This patch modifies the Rust code
> in vmlinux to directly access externa data, using PC-REL instead of
> GOT. However, Rust code whithin modules is constrained by the PC-REL
> addressing range and is explicitly set to use an indirect method.
>
> Signed-off-by: WANG Rui <wangrui@loongson.cn>
I have created a tracking issue for this in
https://github.com/rust-lang/rust/issues/127488 since there was only
the MCP, I hope that helps.
I also added it to our #2 list of unstable features -- please feel
free to ping me in the future if you add others that you will need in
the kernel, I am happy to add the entry even before you send the patch
to the kernel in order to track things (in fact, even if it is not
implemented we can still track it in the other lists).
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Cheers,
Miguel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-08 17:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-03 11:06 [PATCH] LoongArch: rust: Use rustc option -Zdirect-access-external-data WANG Rui
2024-07-08 17:52 ` Miguel Ojeda
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).