* [RFC PATCH 1/3] docs: rust: quick-start: Add another way to install
2025-09-03 9:53 [RFC PATCH 0/3] Fix objtool warnings with RUST on LoongArch Tiezhu Yang
@ 2025-09-03 9:53 ` Tiezhu Yang
2025-09-03 10:11 ` Miguel Ojeda
2025-09-03 9:53 ` [RFC PATCH 2/3] LoongArch: Make LTO case independent in Makefile Tiezhu Yang
2025-09-03 9:53 ` [RFC PATCH 3/3] LoongArch: Handle table jump option for RUST Tiezhu Yang
2 siblings, 1 reply; 8+ messages in thread
From: Tiezhu Yang @ 2025-09-03 9:53 UTC (permalink / raw)
To: Huacai Chen, Miguel Ojeda
Cc: WANG Rui, rust-for-linux, loongarch, linux-kernel
When compiling with LLVM and CONFIG_RUST is set, there is build error on
LoongArch:
--> rust/kernel/lib.rs:331:13
|
331 | loc.file_with_nul()
| ^^^^^^^^^^^^^ method not found in `&'a Location<'a>`
error: aborting due to 1 previous error
It seems that the latest version of rustc is not compatible, in order to
install the workable rustc version for LoongArch, there is another simple
and easy way, add it to the Quick Start guide.
Suggested-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
Documentation/rust/quick-start.rst | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/rust/quick-start.rst b/Documentation/rust/quick-start.rst
index 155f7107329a..fdd9f54f4fe4 100644
--- a/Documentation/rust/quick-start.rst
+++ b/Documentation/rust/quick-start.rst
@@ -21,6 +21,20 @@ Alternatively, the next two "Requirements" sections explain each component and
how to install them through ``rustup``, the standalone installers from Rust
and/or building them.
+Additionally, if you want to install a specified version, you can remove the
+exist packages from your Linux distribution first, e.g. for Fedora Linux::
+
+ dnf remove rust
+
+and run the following in your terminal::
+
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+
+then follow the onscreen instructions to install from the official release
+channels, enabling you to easily switch between stable, beta, and nightly
+compilers and keep them updated. Please see https://rustup.rs/ for more
+information.
+
The rest of the document explains other aspects on how to get started.
--
2.42.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC PATCH 1/3] docs: rust: quick-start: Add another way to install
2025-09-03 9:53 ` [RFC PATCH 1/3] docs: rust: quick-start: Add another way to install Tiezhu Yang
@ 2025-09-03 10:11 ` Miguel Ojeda
2025-09-04 3:55 ` Tiezhu Yang
0 siblings, 1 reply; 8+ messages in thread
From: Miguel Ojeda @ 2025-09-03 10:11 UTC (permalink / raw)
To: Tiezhu Yang
Cc: Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
linux-kernel
On Wed, Sep 3, 2025 at 11:53 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> It seems that the latest version of rustc is not compatible, in order to
This is only in nightly Rust -- we have a couple commits in -next that
make Rust >= 1.91 work. Could you please try those? i.e. starting at
8851e27d2cb9 ("rust: support Rust >= 1.91.0 target spec"). They should
land in e.g. -rc5.
Regarding `rustup`: we could link to the install instructions, but I
don't think it is a good idea to replicate a particular `curl` line
that could change upstream (e.g. the domain changing hands),
especially one that installs something on the fly.
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC PATCH 1/3] docs: rust: quick-start: Add another way to install
2025-09-03 10:11 ` Miguel Ojeda
@ 2025-09-04 3:55 ` Tiezhu Yang
0 siblings, 0 replies; 8+ messages in thread
From: Tiezhu Yang @ 2025-09-04 3:55 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
linux-kernel
On 2025/9/3 下午6:11, Miguel Ojeda wrote:
> On Wed, Sep 3, 2025 at 11:53 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>
>> It seems that the latest version of rustc is not compatible, in order to
>
> This is only in nightly Rust -- we have a couple commits in -next that
> make Rust >= 1.91 work. Could you please try those? i.e. starting at
> 8851e27d2cb9 ("rust: support Rust >= 1.91.0 target spec"). They should
> land in e.g. -rc5.
OK, will try.
> Regarding `rustup`: we could link to the install instructions, but I
> don't think it is a good idea to replicate a particular `curl` line
> that could change upstream (e.g. the domain changing hands),
> especially one that installs something on the fly.
I will drop this patch in the next version.
Thanks,
Tiezhu
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 2/3] LoongArch: Make LTO case independent in Makefile
2025-09-03 9:53 [RFC PATCH 0/3] Fix objtool warnings with RUST on LoongArch Tiezhu Yang
2025-09-03 9:53 ` [RFC PATCH 1/3] docs: rust: quick-start: Add another way to install Tiezhu Yang
@ 2025-09-03 9:53 ` Tiezhu Yang
2025-09-03 9:53 ` [RFC PATCH 3/3] LoongArch: Handle table jump option for RUST Tiezhu Yang
2 siblings, 0 replies; 8+ messages in thread
From: Tiezhu Yang @ 2025-09-03 9:53 UTC (permalink / raw)
To: Huacai Chen, Miguel Ojeda
Cc: WANG Rui, rust-for-linux, loongarch, linux-kernel
LTO is not only used for Clang, it maybe used for Rust, make LTO case out
of CONFIG_CC_HAS_ANNOTATE_TABLEJUMP in Makefile.
This is preparation for later patch, no function changes.
Suggested-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/loongarch/Makefile | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index a3a9759414f4..9d80af7f75c8 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -102,16 +102,16 @@ KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)
ifdef CONFIG_OBJTOOL
ifdef CONFIG_CC_HAS_ANNOTATE_TABLEJUMP
+KBUILD_CFLAGS += -mannotate-tablejump
+else
+KBUILD_CFLAGS += -fno-jump-tables # keep compatibility with older compilers
+endif
+ifdef CONFIG_LTO_CLANG
# The annotate-tablejump option can not be passed to LLVM backend when LTO is enabled.
# Ensure it is aware of linker with LTO, '--loongarch-annotate-tablejump' also needs to
# be passed via '-mllvm' to ld.lld.
-KBUILD_CFLAGS += -mannotate-tablejump
-ifdef CONFIG_LTO_CLANG
KBUILD_LDFLAGS += -mllvm --loongarch-annotate-tablejump
endif
-else
-KBUILD_CFLAGS += -fno-jump-tables # keep compatibility with older compilers
-endif
endif
KBUILD_RUSTFLAGS += --target=loongarch64-unknown-none-softfloat -Ccode-model=small
--
2.42.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 3/3] LoongArch: Handle table jump option for RUST
2025-09-03 9:53 [RFC PATCH 0/3] Fix objtool warnings with RUST on LoongArch Tiezhu Yang
2025-09-03 9:53 ` [RFC PATCH 1/3] docs: rust: quick-start: Add another way to install Tiezhu Yang
2025-09-03 9:53 ` [RFC PATCH 2/3] LoongArch: Make LTO case independent in Makefile Tiezhu Yang
@ 2025-09-03 9:53 ` Tiezhu Yang
2025-09-03 10:28 ` Miguel Ojeda
2 siblings, 1 reply; 8+ messages in thread
From: Tiezhu Yang @ 2025-09-03 9:53 UTC (permalink / raw)
To: Huacai Chen, Miguel Ojeda
Cc: WANG Rui, rust-for-linux, loongarch, linux-kernel
When compiling with LLVM and CONFIG_RUST is set, there exist objtool
warnings "sibling call from callable instruction with modified stack
frame" in rust/core.o and rust/kernel.o.
For this special case, the related object file shows that there is no
generated relocation section '.rela.discard.tablejump_annotate' for the
table jump instruction jirl, thus objtool can not know that what is the
actual destination address.
If the rustc has the option "-Cllvm-args=--loongarch-annotate-tablejump",
pass the option to enable jump table for objtool, otherwise it is better
to remain -Zno-jump-tables to keep compatibility with older rustc.
How to test:
(1) Please install rustc 1.78.0 (without annotate-tablejump option) or
1.87.0 (with annotate-tablejump option), do not use the latest version
for now, otherwise there may be build error:
--> rust/kernel/lib.rs:331:13
|
331 | loc.file_with_nul()
| ^^^^^^^^^^^^^ method not found in `&'a Location<'a>`
error: aborting due to 1 previous error
(2) Execute the following command:
$ rustup component add rust-src
$ make LLVM=1 rustavailable
$ make ARCH=loongarch LLVM=1 clean defconfig
$ scripts/config -d MODVERSIONS \
-e RUST -e SAMPLES -e SAMPLES_RUST \
-e SAMPLE_RUST_CONFIGFS -e SAMPLE_RUST_MINIMAL \
-e SAMPLE_RUST_MISC_DEVICE -e SAMPLE_RUST_PRINT \
-e SAMPLE_RUST_DMA -e SAMPLE_RUST_DRIVER_PCI \
-e SAMPLE_RUST_DRIVER_PLATFORM -e SAMPLE_RUST_DRIVER_FAUX \
-e SAMPLE_RUST_DRIVER_AUXILIARY -e SAMPLE_RUST_HOSTPROGS
$ make ARCH=loongarch LLVM=1 olddefconfig all
Suggested-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/loongarch/Kconfig | 4 ++++
arch/loongarch/Makefile | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index f0abc38c40ac..57933a717e92 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -298,6 +298,10 @@ config AS_HAS_LVZ_EXTENSION
config CC_HAS_ANNOTATE_TABLEJUMP
def_bool $(cc-option,-mannotate-tablejump)
+config RUSTC_HAS_ANNOTATE_TABLEJUMP
+ depends on RUST
+ def_bool $(rustc-option,-Cllvm-args=--loongarch-annotate-tablejump)
+
menu "Kernel type and options"
source "kernel/Kconfig.hz"
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index 9d80af7f75c8..b26d47707031 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -106,6 +106,12 @@ KBUILD_CFLAGS += -mannotate-tablejump
else
KBUILD_CFLAGS += -fno-jump-tables # keep compatibility with older compilers
endif
+ifdef CONFIG_RUSTC_HAS_ANNOTATE_TABLEJUMP
+# Pass '--loongarch-annotate-tablejump' via '-Cllvm-args' to rustc when RUST is enabled.
+KBUILD_RUSTFLAGS += -Cllvm-args=--loongarch-annotate-tablejump
+else
+KBUILD_RUSTFLAGS += -Zno-jump-tables # keep compatibility with older compilers
+endif
ifdef CONFIG_LTO_CLANG
# The annotate-tablejump option can not be passed to LLVM backend when LTO is enabled.
# Ensure it is aware of linker with LTO, '--loongarch-annotate-tablejump' also needs to
--
2.42.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC PATCH 3/3] LoongArch: Handle table jump option for RUST
2025-09-03 9:53 ` [RFC PATCH 3/3] LoongArch: Handle table jump option for RUST Tiezhu Yang
@ 2025-09-03 10:28 ` Miguel Ojeda
2025-09-04 3:57 ` Tiezhu Yang
0 siblings, 1 reply; 8+ messages in thread
From: Miguel Ojeda @ 2025-09-03 10:28 UTC (permalink / raw)
To: Tiezhu Yang
Cc: Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
linux-kernel
On Wed, Sep 3, 2025 at 11:53 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> When compiling with LLVM and CONFIG_RUST is set, there exist objtool
> warnings "sibling call from callable instruction with modified stack
> frame" in rust/core.o and rust/kernel.o.
Thanks for fixing this! I have seen it for a long time in my CI:
I think this is:
Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: https://lore.kernel.org/rust-for-linux/CANiq72mNeCuPkCDrG2db3w=AX+O-zYrfprisDPmRac_qh65Dmg@mail.gmail.com/
Perhaps consider adding an example of the warning in the log for
future Lore searches:
rust/core.o: warning: objtool:
_RNvXs1_NtNtCs5QSdWC790r4_4core5ascii10ascii_charNtB5_9AsciiCharNtNtB9_3fmt5Debug3fmt+0x54:
sibling call from callable instruction with modified stack frame
> (1) Please install rustc 1.78.0 (without annotate-tablejump option) or
> 1.87.0 (with annotate-tablejump option), do not use the latest version
> for now, otherwise there may be build error:
Nightly is not a released version, and it is expected that it breaks
from time to time. Even beta may break. We are ~2 months away from
that release.
In any case, I don't think this information is related to this commit.
> +config RUSTC_HAS_ANNOTATE_TABLEJUMP
> + depends on RUST
> + def_bool $(rustc-option,-Cllvm-args=--loongarch-annotate-tablejump)
I think this may be fine given it is `-Cllvm-args` and anyway
LoongArch doesn't use a `target.json` (which is great!), but please
double-check reading what I wrote in 46e24a545cdb ("rust:
kasan/kbuild: fix missing flags on first build") just in case.
I hope this helps!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC PATCH 3/3] LoongArch: Handle table jump option for RUST
2025-09-03 10:28 ` Miguel Ojeda
@ 2025-09-04 3:57 ` Tiezhu Yang
0 siblings, 0 replies; 8+ messages in thread
From: Tiezhu Yang @ 2025-09-04 3:57 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
linux-kernel
On 2025/9/3 下午6:28, Miguel Ojeda wrote:
> On Wed, Sep 3, 2025 at 11:53 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>
>> When compiling with LLVM and CONFIG_RUST is set, there exist objtool
>> warnings "sibling call from callable instruction with modified stack
>> frame" in rust/core.o and rust/kernel.o.
>
> Thanks for fixing this! I have seen it for a long time in my CI:
>
> I think this is:
>
> Reported-by: Miguel Ojeda <ojeda@kernel.org>
> Closes: https://lore.kernel.org/rust-for-linux/CANiq72mNeCuPkCDrG2db3w=AX+O-zYrfprisDPmRac_qh65Dmg@mail.gmail.com/
>
> Perhaps consider adding an example of the warning in the log for
> future Lore searches:
>
> rust/core.o: warning: objtool:
> _RNvXs1_NtNtCs5QSdWC790r4_4core5ascii10ascii_charNtB5_9AsciiCharNtNtB9_3fmt5Debug3fmt+0x54:
> sibling call from callable instruction with modified stack frame
OK, will update the commit message in the next version.
>> (1) Please install rustc 1.78.0 (without annotate-tablejump option) or
>> 1.87.0 (with annotate-tablejump option), do not use the latest version
>> for now, otherwise there may be build error:
>
> Nightly is not a released version, and it is expected that it breaks
> from time to time. Even beta may break. We are ~2 months away from
> that release.
>
> In any case, I don't think this information is related to this commit.
OK, I will remove the above info in the commit message.
>> +config RUSTC_HAS_ANNOTATE_TABLEJUMP
>> + depends on RUST
>> + def_bool $(rustc-option,-Cllvm-args=--loongarch-annotate-tablejump)
>
> I think this may be fine given it is `-Cllvm-args` and anyway
> LoongArch doesn't use a `target.json` (which is great!), but please
> double-check reading what I wrote in 46e24a545cdb ("rust:
> kasan/kbuild: fix missing flags on first build") just in case.
OK, will do.
Thanks,
Tiezhu
^ permalink raw reply [flat|nested] 8+ messages in thread