2022-08-27 17:59:16

by Xi Ruoyao

[permalink] [raw]
Subject: [PATCH 1/8] LoongArch: Add CONFIG_CC_HAS_EXPLICIT_RELOCS

GNU as >= 2.40 and GCC >= 13 will support using explicit relocation
hints in the assembly code, instead of la.* macros. The usage of
explicit relocation hints can improve code generation so it's enabled
by default by GCC >= 13. We need to adapt the kernel for this change,
introduce CONFIG_CC_HAS_EXPLICIT_RELOCS so we can use it in later
patches.

Signed-off-by: Xi Ruoyao <[email protected]>
---
arch/loongarch/Kconfig | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index 810096bbf853..e7cfd451024b 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -203,6 +203,9 @@ config SCHED_OMIT_FRAME_POINTER
bool
default y

+config CC_HAS_EXPLICIT_RELOCS
+ def_bool $(cc-option,-mexplicit-relocs) && $(as-instr,x:pcalau12i \$t0$(comma)%pc_hi20(x))
+
menu "Kernel type and options"

source "kernel/Kconfig.hz"
--
2.37.0


2022-08-28 14:20:54

by Huacai Chen

[permalink] [raw]
Subject: Re: [PATCH 1/8] LoongArch: Add CONFIG_CC_HAS_EXPLICIT_RELOCS

Hi, Ruoyao,

On Sun, Aug 28, 2022 at 1:55 AM Xi Ruoyao <[email protected]> wrote:
>
> GNU as >= 2.40 and GCC >= 13 will support using explicit relocation
> hints in the assembly code, instead of la.* macros. The usage of
> explicit relocation hints can improve code generation so it's enabled
> by default by GCC >= 13. We need to adapt the kernel for this change,
> introduce CONFIG_CC_HAS_EXPLICIT_RELOCS so we can use it in later
> patches.
>
> Signed-off-by: Xi Ruoyao <[email protected]>
> ---
> arch/loongarch/Kconfig | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
> index 810096bbf853..e7cfd451024b 100644
> --- a/arch/loongarch/Kconfig
> +++ b/arch/loongarch/Kconfig
> @@ -203,6 +203,9 @@ config SCHED_OMIT_FRAME_POINTER
> bool
> default y
>
> +config CC_HAS_EXPLICIT_RELOCS
> + def_bool $(cc-option,-mexplicit-relocs) && $(as-instr,x:pcalau12i \$t0$(comma)%pc_hi20(x))
Is it possible that we only change the Makefile and not touch Kconfig?



Huacai
> +
> menu "Kernel type and options"
>
> source "kernel/Kconfig.hz"
> --
> 2.37.0
>
>

2022-08-28 16:22:54

by Xi Ruoyao

[permalink] [raw]
Subject: Re: [PATCH 1/8] LoongArch: Add CONFIG_CC_HAS_EXPLICIT_RELOCS

On Sun, 2022-08-28 at 22:15 +0800, Huacai Chen wrote:
> > +config CC_HAS_EXPLICIT_RELOCS
> > +       def_bool $(cc-option,-mexplicit-relocs) && $(as-
> > instr,x:pcalau12i \$t0$(comma)%pc_hi20(x))
> Is it possible that we only change the Makefile and not touch Kconfig?

I guess we can, but if we'll introduce objtool we can

select HAVE_OBJTOOL if CC_HAS_EXPLICIT_RELOCS

then.

--
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University

2022-08-29 04:50:26

by Huacai Chen

[permalink] [raw]
Subject: Re: [PATCH 1/8] LoongArch: Add CONFIG_CC_HAS_EXPLICIT_RELOCS

On Mon, Aug 29, 2022 at 12:20 AM Xi Ruoyao <[email protected]> wrote:
>
> On Sun, 2022-08-28 at 22:15 +0800, Huacai Chen wrote:
> > > +config CC_HAS_EXPLICIT_RELOCS
> > > + def_bool $(cc-option,-mexplicit-relocs) && $(as-
> > > instr,x:pcalau12i \$t0$(comma)%pc_hi20(x))
> > Is it possible that we only change the Makefile and not touch Kconfig?
>
> I guess we can, but if we'll introduce objtool we can
>
> select HAVE_OBJTOOL if CC_HAS_EXPLICIT_RELOCS
>
> then.
OK, you can keep your way.

Huacai
>
> --
> Xi Ruoyao <[email protected]>
> School of Aerospace Science and Technology, Xidian University