[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240703110624.1301830-1-wangrui@loongson.cn>
Date: Wed, 3 Jul 2024 19:06:24 +0800
From: WANG Rui <wangrui@...ngson.cn>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: WANG Xuerui <kernel@...0n.name>,
Xi Ruoyao <xry111@...111.site>,
Xuefeng Li <lixuefeng@...ngson.cn>,
loongarch@...ts.linux.dev,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
loongson-kernel@...ts.loongnix.cn,
WANG Rui <wangrui@...ngson.cn>
Subject: [PATCH] LoongArch: rust: Use rustc option -Zdirect-access-external-data
-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@...ngson.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
Powered by blists - more mailing lists