All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch
@ 2025-09-09  9:27 Tiezhu Yang
  2025-09-09  9:27 ` [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile Tiezhu Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Tiezhu Yang @ 2025-09-09  9:27 UTC (permalink / raw)
  To: Huacai Chen, Miguel Ojeda
  Cc: WANG Rui, rust-for-linux, loongarch, linux-kernel

This series is to fix objtool warnings when compiling with LLVM and
CONFIG_RUST is set, thanks WANG Rui and Miguel for your suggestions
about RUST.

The second patch uses the option -Zno-jump-tables, here is a related
discussion:

https://github.com/rust-lang/rust/pull/145974#issuecomment-3236418282

Tiezhu Yang (2):
  LoongArch: Make LTO case independent in Makefile
  LoongArch: Handle jump tables option for RUST

 arch/loongarch/Kconfig  |  4 ++++
 arch/loongarch/Makefile | 16 +++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

-- 
2.42.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-09  9:27 [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch Tiezhu Yang
@ 2025-09-09  9:27 ` Tiezhu Yang
  2025-09-20  6:15   ` Nathan Chancellor
  2025-09-09  9:27 ` [PATCH v1 2/2] LoongArch: Handle jump tables option for RUST Tiezhu Yang
  2025-09-18  9:15 ` [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch Huacai Chen
  2 siblings, 1 reply; 15+ messages in thread
From: Tiezhu Yang @ 2025-09-09  9:27 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 related	[flat|nested] 15+ messages in thread

* [PATCH v1 2/2] LoongArch: Handle jump tables option for RUST
  2025-09-09  9:27 [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch Tiezhu Yang
  2025-09-09  9:27 ` [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile Tiezhu Yang
@ 2025-09-09  9:27 ` Tiezhu Yang
  2025-09-09 10:16   ` Miguel Ojeda
  2025-09-18  9:15 ` [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch Huacai Chen
  2 siblings, 1 reply; 15+ messages in thread
From: Tiezhu Yang @ 2025-09-09  9:27 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 in rust/core.o and rust/kernel.o, like this:

    rust/core.o: warning: objtool:
_RNvXs1_NtNtCs5QSdWC790r4_4core5ascii10ascii_charNtB5_9AsciiCharNtNtB9_3fmt5Debug3fmt+0x54:
sibling call from callable instruction with modified stack frame

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 tables for objtool, otherwise it should
pass "-Zno-jump-tables" to keep compatibility with older rustc.

How to test:

  $ 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

Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: https://lore.kernel.org/rust-for-linux/CANiq72mNeCuPkCDrG2db3w=AX+O-zYrfprisDPmRac_qh65Dmg@mail.gmail.com/
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 related	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 2/2] LoongArch: Handle jump tables option for RUST
  2025-09-09  9:27 ` [PATCH v1 2/2] LoongArch: Handle jump tables option for RUST Tiezhu Yang
@ 2025-09-09 10:16   ` Miguel Ojeda
  2025-09-09 18:06     ` Matthew Maurer
  0 siblings, 1 reply; 15+ messages in thread
From: Miguel Ojeda @ 2025-09-09 10:16 UTC (permalink / raw)
  To: Tiezhu Yang, Matthew Maurer
  Cc: Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
	linux-kernel

On Tue, Sep 9, 2025 at 11:27 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> +config RUSTC_HAS_ANNOTATE_TABLEJUMP
> +       depends on RUST
> +       def_bool $(rustc-option,-Cllvm-args=--loongarch-annotate-tablejump)

I am not sure if this needs the `depends on` -- from a quick test, it
seems to run regardless of it (and your `ifdef` below doesn't care
either). Cc'ing Matthew in case he remembers why the docs mention that
the Kconfig one should be guarded by `RUST_IS_AVAILABLE`.

In any case, it shouldn't hurt and it is only on the LoongArch Makefile.

If you will be taking this through the LoongArch tree:

Acked-by: Miguel Ojeda <ojeda@kernel.org>

Thanks again for fixing this!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 2/2] LoongArch: Handle jump tables option for RUST
  2025-09-09 10:16   ` Miguel Ojeda
@ 2025-09-09 18:06     ` Matthew Maurer
  2025-09-09 20:14       ` Miguel Ojeda
  0 siblings, 1 reply; 15+ messages in thread
From: Matthew Maurer @ 2025-09-09 18:06 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Tiezhu Yang, Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux,
	loongarch, linux-kernel

On Tue, Sep 9, 2025 at 3:16 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Tue, Sep 9, 2025 at 11:27 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> >
> > +config RUSTC_HAS_ANNOTATE_TABLEJUMP
> > +       depends on RUST
> > +       def_bool $(rustc-option,-Cllvm-args=--loongarch-annotate-tablejump)
>
> I am not sure if this needs the `depends on` -- from a quick test, it
> seems to run regardless of it (and your `ifdef` below doesn't care
> either). Cc'ing Matthew in case he remembers why the docs mention that
> the Kconfig one should be guarded by `RUST_IS_AVAILABLE`.

I think this isn't needed. I added it initially because Kconfig was
dying when `rustc` was not on the path, but I'm not sure how I managed
that, since `success,trap` should guard against that (perhaps I was
doing something wrong in earlier development, fixed it, and didn't
remove the restriction). I have tested `rustc-option` with an
intentionally missing `rustc`, and Kconfig doesn't seem to be taken
down (and it gets a no answer), so the change to the macro means that
doc warning should be removed.

>
> In any case, it shouldn't hurt and it is only on the LoongArch Makefile.
>
> If you will be taking this through the LoongArch tree:
>
> Acked-by: Miguel Ojeda <ojeda@kernel.org>
>
> Thanks again for fixing this!
>
> Cheers,
> Miguel

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 2/2] LoongArch: Handle jump tables option for RUST
  2025-09-09 18:06     ` Matthew Maurer
@ 2025-09-09 20:14       ` Miguel Ojeda
  0 siblings, 0 replies; 15+ messages in thread
From: Miguel Ojeda @ 2025-09-09 20:14 UTC (permalink / raw)
  To: Matthew Maurer
  Cc: Tiezhu Yang, Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux,
	loongarch, linux-kernel

On Tue, Sep 9, 2025 at 8:06 PM Matthew Maurer <mmaurer@google.com> wrote:
>
> I think this isn't needed. I added it initially because Kconfig was
> dying when `rustc` was not on the path, but I'm not sure how I managed
> that, since `success,trap` should guard against that (perhaps I was
> doing something wrong in earlier development, fixed it, and didn't
> remove the restriction). I have tested `rustc-option` with an
> intentionally missing `rustc`, and Kconfig doesn't seem to be taken
> down (and it gets a no answer), so the change to the macro means that
> doc warning should be removed.

Yeah, that matches my test then, thanks! (and for the patch)

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch
  2025-09-09  9:27 [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch Tiezhu Yang
  2025-09-09  9:27 ` [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile Tiezhu Yang
  2025-09-09  9:27 ` [PATCH v1 2/2] LoongArch: Handle jump tables option for RUST Tiezhu Yang
@ 2025-09-18  9:15 ` Huacai Chen
  2 siblings, 0 replies; 15+ messages in thread
From: Huacai Chen @ 2025-09-18  9:15 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Miguel Ojeda, WANG Rui, rust-for-linux, loongarch, linux-kernel

Applied, thanks.

Huacai

On Tue, Sep 9, 2025 at 5:27 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> This series is to fix objtool warnings when compiling with LLVM and
> CONFIG_RUST is set, thanks WANG Rui and Miguel for your suggestions
> about RUST.
>
> The second patch uses the option -Zno-jump-tables, here is a related
> discussion:
>
> https://github.com/rust-lang/rust/pull/145974#issuecomment-3236418282
>
> Tiezhu Yang (2):
>   LoongArch: Make LTO case independent in Makefile
>   LoongArch: Handle jump tables option for RUST
>
>  arch/loongarch/Kconfig  |  4 ++++
>  arch/loongarch/Makefile | 16 +++++++++++-----
>  2 files changed, 15 insertions(+), 5 deletions(-)
>
> --
> 2.42.0
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-09  9:27 ` [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile Tiezhu Yang
@ 2025-09-20  6:15   ` Nathan Chancellor
  2025-09-20  8:23     ` Huacai Chen
  0 siblings, 1 reply; 15+ messages in thread
From: Nathan Chancellor @ 2025-09-20  6:15 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
	linux-kernel, llvm

Hi Tiezhu,

On Tue, Sep 09, 2025 at 05:27:06PM +0800, Tiezhu Yang wrote:
> 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
> 

This change is now in -next as commit b15212824a01 ("LoongArch: Make LTO
case independent in Makefile"), where it breaks the build for clang-18,
as '--loongarch-annotate-tablejump' is unimplemented there but there is
no version check before using it.

  $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 mrproper defconfig

  $ scripts/config -d LTO_NONE -e LTO_CLANG_THIN

  $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 olddefconfig vmlinuz.efi
  ld.lld: error: -mllvm: ld.lld: Unknown command line argument '--loongarch-annotate-tablejump'.
  ...

  $ scripts/config -s CC_HAS_ANNOTATE_TABLEJUMP
  undef

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-20  6:15   ` Nathan Chancellor
@ 2025-09-20  8:23     ` Huacai Chen
  2025-09-20  9:19       ` Tiezhu Yang
  0 siblings, 1 reply; 15+ messages in thread
From: Huacai Chen @ 2025-09-20  8:23 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Tiezhu Yang, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
	linux-kernel, llvm

On Sat, Sep 20, 2025 at 2:15 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi Tiezhu,
>
> On Tue, Sep 09, 2025 at 05:27:06PM +0800, Tiezhu Yang wrote:
> > 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
> >
>
> This change is now in -next as commit b15212824a01 ("LoongArch: Make LTO
> case independent in Makefile"), where it breaks the build for clang-18,
> as '--loongarch-annotate-tablejump' is unimplemented there but there is
> no version check before using it.
>
>   $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 mrproper defconfig
>
>   $ scripts/config -d LTO_NONE -e LTO_CLANG_THIN
>
>   $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 olddefconfig vmlinuz.efi
>   ld.lld: error: -mllvm: ld.lld: Unknown command line argument '--loongarch-annotate-tablejump'.
>   ...
>
>   $ scripts/config -s CC_HAS_ANNOTATE_TABLEJUMP
>   undef
Hmm, maybe we need this?
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index ae419e32f22e..fcfa793f9bb0 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -115,7 +115,7 @@ 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_LDFLAGS                 += -mllvm
--loongarch-annotate-tablejump
+KBUILD_LDFLAGS                 += $(call ld-option,-mllvm
--loongarch-annotate-tablejump)
 endif
 endif
>
> Cheers,
> Nathan

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-20  8:23     ` Huacai Chen
@ 2025-09-20  9:19       ` Tiezhu Yang
  2025-09-20 10:22         ` Tiezhu Yang
  0 siblings, 1 reply; 15+ messages in thread
From: Tiezhu Yang @ 2025-09-20  9:19 UTC (permalink / raw)
  To: Huacai Chen, Nathan Chancellor
  Cc: Miguel Ojeda, WANG Rui, rust-for-linux, loongarch, linux-kernel,
	llvm

On 9/20/25 16:23, Huacai Chen wrote:
> On Sat, Sep 20, 2025 at 2:15 PM Nathan Chancellor <nathan@kernel.org> wrote:
>>
>> Hi Tiezhu,
>>
>> On Tue, Sep 09, 2025 at 05:27:06PM +0800, Tiezhu Yang wrote:
>>> 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
>>>
>>
>> This change is now in -next as commit b15212824a01 ("LoongArch: Make LTO
>> case independent in Makefile"), where it breaks the build for clang-18,
>> as '--loongarch-annotate-tablejump' is unimplemented there but there is
>> no version check before using it.
>>
>>    $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 mrproper defconfig
>>
>>    $ scripts/config -d LTO_NONE -e LTO_CLANG_THIN
>>
>>    $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 olddefconfig vmlinuz.efi
>>    ld.lld: error: -mllvm: ld.lld: Unknown command line argument '--loongarch-annotate-tablejump'.
>>    ...
>>
>>    $ scripts/config -s CC_HAS_ANNOTATE_TABLEJUMP
>>    undef
> Hmm, maybe we need this?
> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> index ae419e32f22e..fcfa793f9bb0 100644
> --- a/arch/loongarch/Makefile
> +++ b/arch/loongarch/Makefile
> @@ -115,7 +115,7 @@ 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_LDFLAGS                 += -mllvm
> --loongarch-annotate-tablejump
> +KBUILD_LDFLAGS                 += $(call ld-option,-mllvm
> --loongarch-annotate-tablejump)
>   endif
>   endif

We need to handle the other case to use -fno-jump-tables if llvm does
not support -loongarch-annotate-tablejump.

So, it is better to update the minimal version of llvm to 20, which
includes the following two important commits:

[LoongArch] Add options for annotate tablejump
https://github.com/llvm/llvm-project/commit/4c2c17756739

[LoongArch] Avoid indirect branch jumps using the ra register
https://github.com/llvm/llvm-project/commit/21ef17c62645

If you are OK, I will send a patch to modify the following file:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/min-tool-version.sh#n29

and keep arch/loongarch/Makefile as is.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-20  9:19       ` Tiezhu Yang
@ 2025-09-20 10:22         ` Tiezhu Yang
  2025-09-20 11:41           ` Huacai Chen
  0 siblings, 1 reply; 15+ messages in thread
From: Tiezhu Yang @ 2025-09-20 10:22 UTC (permalink / raw)
  To: Huacai Chen, Nathan Chancellor
  Cc: Miguel Ojeda, WANG Rui, rust-for-linux, loongarch, linux-kernel,
	llvm

On 9/20/25 17:19, Tiezhu Yang wrote:
> On 9/20/25 16:23, Huacai Chen wrote:
>> On Sat, Sep 20, 2025 at 2:15 PM Nathan Chancellor <nathan@kernel.org> 
>> wrote:
>>>
>>> Hi Tiezhu,
>>>
>>> On Tue, Sep 09, 2025 at 05:27:06PM +0800, Tiezhu Yang wrote:
>>>> 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
>>>>
>>>
>>> This change is now in -next as commit b15212824a01 ("LoongArch: Make LTO
>>> case independent in Makefile"), where it breaks the build for clang-18,
>>> as '--loongarch-annotate-tablejump' is unimplemented there but there is
>>> no version check before using it.
>>>
>>>    $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 mrproper defconfig
>>>
>>>    $ scripts/config -d LTO_NONE -e LTO_CLANG_THIN
>>>
>>>    $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 olddefconfig vmlinuz.efi
>>>    ld.lld: error: -mllvm: ld.lld: Unknown command line argument 
>>> '--loongarch-annotate-tablejump'.
>>>    ...
>>>
>>>    $ scripts/config -s CC_HAS_ANNOTATE_TABLEJUMP
>>>    undef
>> Hmm, maybe we need this?
>> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
>> index ae419e32f22e..fcfa793f9bb0 100644
>> --- a/arch/loongarch/Makefile
>> +++ b/arch/loongarch/Makefile
>> @@ -115,7 +115,7 @@ 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_LDFLAGS                 += -mllvm
>> --loongarch-annotate-tablejump
>> +KBUILD_LDFLAGS                 += $(call ld-option,-mllvm
>> --loongarch-annotate-tablejump)
>>   endif
>>   endif
> 
> We need to handle the other case to use -fno-jump-tables if llvm does
> not support -loongarch-annotate-tablejump.
> 
> So, it is better to update the minimal version of llvm to 20, which
> includes the following two important commits:
> 
> [LoongArch] Add options for annotate tablejump
> https://github.com/llvm/llvm-project/commit/4c2c17756739
> 
> [LoongArch] Avoid indirect branch jumps using the ra register
> https://github.com/llvm/llvm-project/commit/21ef17c62645
> 
> If you are OK, I will send a patch to modify the following file:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/min-tool-version.sh#n29 
> 
> 
> and keep arch/loongarch/Makefile as is.

The other way is to keep scripts/min-tool-version.sh as is, and only
modify arch/loongarch/Makefile, something like this (not tested):

config LLD_HAS_ANNOTATE_TABLEJUMP
	def_bool LLD_VERSION >= 200000

ifdef CONFIG_LTO_CLANG
ifdef CONFIG_LLD_HAS_ANNOTATE_TABLEJUMP
KBUILD_LDFLAGS			+= -mllvm --loongarch-annotate-tablejump
else
KBUILD_LDFLAGS			+= -mllvm --no-jump-tables
endif

Update the minimal llvm version or change Makefile to compat various
llvm versions, which one do you prefer? Pease let me know.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-20 10:22         ` Tiezhu Yang
@ 2025-09-20 11:41           ` Huacai Chen
  2025-09-20 12:52             ` Tiezhu Yang
  0 siblings, 1 reply; 15+ messages in thread
From: Huacai Chen @ 2025-09-20 11:41 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Nathan Chancellor, Miguel Ojeda, WANG Rui, rust-for-linux,
	loongarch, linux-kernel, llvm

On Sat, Sep 20, 2025 at 6:22 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> On 9/20/25 17:19, Tiezhu Yang wrote:
> > On 9/20/25 16:23, Huacai Chen wrote:
> >> On Sat, Sep 20, 2025 at 2:15 PM Nathan Chancellor <nathan@kernel.org>
> >> wrote:
> >>>
> >>> Hi Tiezhu,
> >>>
> >>> On Tue, Sep 09, 2025 at 05:27:06PM +0800, Tiezhu Yang wrote:
> >>>> 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
> >>>>
> >>>
> >>> This change is now in -next as commit b15212824a01 ("LoongArch: Make LTO
> >>> case independent in Makefile"), where it breaks the build for clang-18,
> >>> as '--loongarch-annotate-tablejump' is unimplemented there but there is
> >>> no version check before using it.
> >>>
> >>>    $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 mrproper defconfig
> >>>
> >>>    $ scripts/config -d LTO_NONE -e LTO_CLANG_THIN
> >>>
> >>>    $ make -skj"$(nproc)" ARCH=loongarch LLVM=1 olddefconfig vmlinuz.efi
> >>>    ld.lld: error: -mllvm: ld.lld: Unknown command line argument
> >>> '--loongarch-annotate-tablejump'.
> >>>    ...
> >>>
> >>>    $ scripts/config -s CC_HAS_ANNOTATE_TABLEJUMP
> >>>    undef
> >> Hmm, maybe we need this?
> >> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> >> index ae419e32f22e..fcfa793f9bb0 100644
> >> --- a/arch/loongarch/Makefile
> >> +++ b/arch/loongarch/Makefile
> >> @@ -115,7 +115,7 @@ 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_LDFLAGS                 += -mllvm
> >> --loongarch-annotate-tablejump
> >> +KBUILD_LDFLAGS                 += $(call ld-option,-mllvm
> >> --loongarch-annotate-tablejump)
> >>   endif
> >>   endif
> >
> > We need to handle the other case to use -fno-jump-tables if llvm does
> > not support -loongarch-annotate-tablejump.
> >
> > So, it is better to update the minimal version of llvm to 20, which
> > includes the following two important commits:
> >
> > [LoongArch] Add options for annotate tablejump
> > https://github.com/llvm/llvm-project/commit/4c2c17756739
> >
> > [LoongArch] Avoid indirect branch jumps using the ra register
> > https://github.com/llvm/llvm-project/commit/21ef17c62645
> >
> > If you are OK, I will send a patch to modify the following file:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/min-tool-version.sh#n29
> >
> >
> > and keep arch/loongarch/Makefile as is.
>
> The other way is to keep scripts/min-tool-version.sh as is, and only
> modify arch/loongarch/Makefile, something like this (not tested):
>
> config LLD_HAS_ANNOTATE_TABLEJUMP
>         def_bool LLD_VERSION >= 200000
>
> ifdef CONFIG_LTO_CLANG
> ifdef CONFIG_LLD_HAS_ANNOTATE_TABLEJUMP
> KBUILD_LDFLAGS                  += -mllvm --loongarch-annotate-tablejump
> else
> KBUILD_LDFLAGS                  += -mllvm --no-jump-tables
> endif
So complicated?

I think below is enough, no?
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_LDFLAGS                  += $(call ld-option,-mllvm
--loongarch-annotate-tablejump,-mllvm --no-jump-tables)
endif

Huacai
>
> Update the minimal llvm version or change Makefile to compat various
> llvm versions, which one do you prefer? Pease let me know.
>
> Thanks,
> Tiezhu
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-20 11:41           ` Huacai Chen
@ 2025-09-20 12:52             ` Tiezhu Yang
  2025-09-23  1:10               ` Nathan Chancellor
  0 siblings, 1 reply; 15+ messages in thread
From: Tiezhu Yang @ 2025-09-20 12:52 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Nathan Chancellor, Miguel Ojeda, WANG Rui, rust-for-linux,
	loongarch, linux-kernel, llvm

On 9/20/25 19:41, Huacai Chen wrote:
...

>>> We need to handle the other case to use -fno-jump-tables if llvm does
>>> not support -loongarch-annotate-tablejump.
>>>
>>> So, it is better to update the minimal version of llvm to 20, which
>>> includes the following two important commits:
>>>
>>> [LoongArch] Add options for annotate tablejump
>>> https://github.com/llvm/llvm-project/commit/4c2c17756739
>>>
>>> [LoongArch] Avoid indirect branch jumps using the ra register
>>> https://github.com/llvm/llvm-project/commit/21ef17c62645
>>>
>>> If you are OK, I will send a patch to modify the following file:
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/min-tool-version.sh#n29
>>>
>>>
>>> and keep arch/loongarch/Makefile as is.
>>
>> The other way is to keep scripts/min-tool-version.sh as is, and only
>> modify arch/loongarch/Makefile, something like this (not tested):
>>
>> config LLD_HAS_ANNOTATE_TABLEJUMP
>>          def_bool LLD_VERSION >= 200000
>>
>> ifdef CONFIG_LTO_CLANG
>> ifdef CONFIG_LLD_HAS_ANNOTATE_TABLEJUMP
>> KBUILD_LDFLAGS                  += -mllvm --loongarch-annotate-tablejump
>> else
>> KBUILD_LDFLAGS                  += -mllvm --no-jump-tables
>> endif
> So complicated?
> 
> I think below is enough, no?
> 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_LDFLAGS                  += $(call ld-option,-mllvm
> --loongarch-annotate-tablejump,-mllvm --no-jump-tables)
> endif

I do not know whether this is valid, you can test it with llvm 18
and llvm 20 if you think it is a proper way.

But IIRC, there is objtool warning with llvm 18, I reported to llvm
developer Wang Lei and he fixed it as the following commit:

[LoongArch] Avoid indirect branch jumps using the ra register
https://github.com/llvm/llvm-project/commit/21ef17c62645

Actually, the above commit solved a performance issue of llvm compiler,
so I prefer to update the minimal llvm version to 20 for LoongArch.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-20 12:52             ` Tiezhu Yang
@ 2025-09-23  1:10               ` Nathan Chancellor
  2025-09-23  3:13                 ` Tiezhu Yang
  0 siblings, 1 reply; 15+ messages in thread
From: Nathan Chancellor @ 2025-09-23  1:10 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
	linux-kernel, llvm

> > > ifdef CONFIG_LTO_CLANG
> > > ifdef CONFIG_LLD_HAS_ANNOTATE_TABLEJUMP
> > > KBUILD_LDFLAGS                  += -mllvm --loongarch-annotate-tablejump
> > > else
> > > KBUILD_LDFLAGS                  += -mllvm --no-jump-tables
> > > endif

There is no '--no-jump-tables' LLVM option so this will not work.
Shouldn't -fno-jump-tables and -Zno-jump-tables take care of generating
jump tables?

> I do not know whether this is valid, you can test it with llvm 18
> and llvm 20 if you think it is a proper way.

For what it's worth, Huacai's original suggestion of

    KBUILD_LDFLAGS += $(call ld-option,-mllvm --loongarch-annotate-tablejump)

appears to work for me and I do not see any objtool warnings with LTO
enabled but I might be missing something.

> But IIRC, there is objtool warning with llvm 18, I reported to llvm
> developer Wang Lei and he fixed it as the following commit:
> 
> [LoongArch] Avoid indirect branch jumps using the ra register
> https://github.com/llvm/llvm-project/commit/21ef17c62645
> 
> Actually, the above commit solved a performance issue of llvm compiler,
> so I prefer to update the minimal llvm version to 20 for LoongArch.

I tend to let architecture maintainers make the call around minimum
supported versions of compilers, so if that is how you would like to
proceed, I am fine with that. I will say LLVM 20 is pretty new (released
on March 4th, 2025) but I expect most of your users to probably be using
bleeding edge tools for all the changes you make in the compiler and
lower level libraries?

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile
  2025-09-23  1:10               ` Nathan Chancellor
@ 2025-09-23  3:13                 ` Tiezhu Yang
  0 siblings, 0 replies; 15+ messages in thread
From: Tiezhu Yang @ 2025-09-23  3:13 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Huacai Chen, Miguel Ojeda, WANG Rui, rust-for-linux, loongarch,
	linux-kernel, llvm

On 2025/9/23 上午9:10, Nathan Chancellor wrote:
>>>> ifdef CONFIG_LTO_CLANG
>>>> ifdef CONFIG_LLD_HAS_ANNOTATE_TABLEJUMP
>>>> KBUILD_LDFLAGS                  += -mllvm --loongarch-annotate-tablejump
>>>> else
>>>> KBUILD_LDFLAGS                  += -mllvm --no-jump-tables
>>>> endif
> 
> There is no '--no-jump-tables' LLVM option so this will not work.
> Shouldn't -fno-jump-tables and -Zno-jump-tables take care of generating
> jump tables?
> 
>> I do not know whether this is valid, you can test it with llvm 18
>> and llvm 20 if you think it is a proper way.
> 
> For what it's worth, Huacai's original suggestion of
> 
>      KBUILD_LDFLAGS += $(call ld-option,-mllvm --loongarch-annotate-tablejump)
> 
> appears to work for me and I do not see any objtool warnings with LTO
> enabled but I might be missing something.

As discussed offline, Huacai will test this change and submit a patch
later.

>> But IIRC, there is objtool warning with llvm 18, I reported to llvm
>> developer Wang Lei and he fixed it as the following commit:
>>
>> [LoongArch] Avoid indirect branch jumps using the ra register
>> https://github.com/llvm/llvm-project/commit/21ef17c62645
>>
>> Actually, the above commit solved a performance issue of llvm compiler,
>> so I prefer to update the minimal llvm version to 20 for LoongArch.
> 
> I tend to let architecture maintainers make the call around minimum
> supported versions of compilers, so if that is how you would like to
> proceed, I am fine with that. I will say LLVM 20 is pretty new (released
> on March 4th, 2025) but I expect most of your users to probably be using
> bleeding edge tools for all the changes you make in the compiler and
> lower level libraries?

Usually, I like to use the latest LLVM upstream version to test the
kernel, but maybe somebody only uses the lower version, so keep the
minimal version as is.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-09-23  3:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09  9:27 [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch Tiezhu Yang
2025-09-09  9:27 ` [PATCH v1 1/2] LoongArch: Make LTO case independent in Makefile Tiezhu Yang
2025-09-20  6:15   ` Nathan Chancellor
2025-09-20  8:23     ` Huacai Chen
2025-09-20  9:19       ` Tiezhu Yang
2025-09-20 10:22         ` Tiezhu Yang
2025-09-20 11:41           ` Huacai Chen
2025-09-20 12:52             ` Tiezhu Yang
2025-09-23  1:10               ` Nathan Chancellor
2025-09-23  3:13                 ` Tiezhu Yang
2025-09-09  9:27 ` [PATCH v1 2/2] LoongArch: Handle jump tables option for RUST Tiezhu Yang
2025-09-09 10:16   ` Miguel Ojeda
2025-09-09 18:06     ` Matthew Maurer
2025-09-09 20:14       ` Miguel Ojeda
2025-09-18  9:15 ` [PATCH v1 0/2] Fix objtool warnings with RUST on LoongArch Huacai Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.