diff mbox series

[1/2] riscv: Hoist linker relaxation disabling logic into Kconfig

Message ID 20231129-riscv-restrict-dwarf5-llvm-v1-1-ec0d368fb538@kernel.org (mailing list archive)
State Superseded
Headers show
Series RISC-V: Disable DWARF5 with known broken LLVM versions | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/build_rv32_defconfig.sh
conchuod/patch-1-test-2 success .github/scripts/patches/build_rv64_clang_allmodconfig.sh
conchuod/patch-1-test-3 success .github/scripts/patches/build_rv64_gcc_allmodconfig.sh
conchuod/patch-1-test-4 success .github/scripts/patches/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-1-test-5 success .github/scripts/patches/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-1-test-6 success .github/scripts/patches/checkpatch.sh
conchuod/patch-1-test-7 success .github/scripts/patches/dtb_warn_rv64.sh
conchuod/patch-1-test-8 success .github/scripts/patches/header_inline.sh
conchuod/patch-1-test-9 success .github/scripts/patches/kdoc.sh
conchuod/patch-1-test-10 success .github/scripts/patches/module_param.sh
conchuod/patch-1-test-11 success .github/scripts/patches/verify_fixes.sh
conchuod/patch-1-test-12 success .github/scripts/patches/verify_signedoff.sh

Commit Message

Nathan Chancellor Nov. 29, 2023, 11:29 p.m. UTC
Certain configurations may need to be disabled if linker relaxation is
in use, such as DWARF5 with ld.lld < 18. Hoist the logic of whether or
not linker relaxation is in use into Kconfig so decisions can be made at
configuration time.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/riscv/Kconfig  | 5 +++++
 arch/riscv/Makefile | 4 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

Comments

Fangrui Song Nov. 30, 2023, 4:06 p.m. UTC | #1
On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Certain configurations may need to be disabled if linker relaxation is
> in use, such as DWARF5 with ld.lld < 18. Hoist the logic of whether or
> not linker relaxation is in use into Kconfig so decisions can be made at
> configuration time.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/riscv/Kconfig  | 5 +++++
>  arch/riscv/Makefile | 4 +---
>  2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 95a2a06acc6a..72be1d8122a3 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -181,6 +181,11 @@ config HAVE_SHADOW_CALL_STACK
>         # https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
>         depends on $(ld-option,--no-relax-gp)
>
> +config RISCV_USE_LINKER_RELAXATION
> +       def_bool y
> +       # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> +       depends on !LD_IS_LLD || LLD_VERSION >= 150000
> +
>  config ARCH_MMAP_RND_BITS_MIN
>         default 18 if 64BIT
>         default 8
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index a74be78678eb..e383aa9e2757 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -43,8 +43,7 @@ else
>         KBUILD_LDFLAGS += -melf32lriscv
>  endif
>
> -ifeq ($(CONFIG_LD_IS_LLD),y)
> -ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
> +ifndef CONFIG_RISCV_USE_LINKER_RELAXATION
>         KBUILD_CFLAGS += -mno-relax
>         KBUILD_AFLAGS += -mno-relax
>  ifndef CONFIG_AS_IS_LLVM
> @@ -52,7 +51,6 @@ ifndef CONFIG_AS_IS_LLVM
>         KBUILD_AFLAGS += -Wa,-mno-relax
>  endif
>  endif
> -endif
>
>  ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
>         KBUILD_LDFLAGS += --no-relax-gp
>
> --
> 2.43.0


Reviewed-by: Fangrui Song <maskray@google.com>
diff mbox series

Patch

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 95a2a06acc6a..72be1d8122a3 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -181,6 +181,11 @@  config HAVE_SHADOW_CALL_STACK
 	# https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
 	depends on $(ld-option,--no-relax-gp)
 
+config RISCV_USE_LINKER_RELAXATION
+	def_bool y
+	# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
+	depends on !LD_IS_LLD || LLD_VERSION >= 150000
+
 config ARCH_MMAP_RND_BITS_MIN
 	default 18 if 64BIT
 	default 8
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index a74be78678eb..e383aa9e2757 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -43,8 +43,7 @@  else
 	KBUILD_LDFLAGS += -melf32lriscv
 endif
 
-ifeq ($(CONFIG_LD_IS_LLD),y)
-ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
+ifndef CONFIG_RISCV_USE_LINKER_RELAXATION
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
@@ -52,7 +51,6 @@  ifndef CONFIG_AS_IS_LLVM
 	KBUILD_AFLAGS += -Wa,-mno-relax
 endif
 endif
-endif
 
 ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
 	KBUILD_LDFLAGS += --no-relax-gp