Skip to contentSkip to conversation

riscv: Pass -mno-relax only on lld < 15.0.0

PATCH In review Palmer Dabbelt 3 participants 4 messages Sep 18, 2022 – Sep 23, 2022 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Pass -mno-relax only on lld < 15.0.0

From: Fangrui Song <[email protected]>

lld since llvm:6611d58f5bbc ("[ELF] Relax R_RISCV_ALIGN"), which will be included in the 15.0.0 release, has implemented some RISC-V linker relaxation. -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to suppress R_RISCV_ALIGN which older lld can not handle:

ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax

---
Fanguri poked me about this one on IRC, I'm not sure what happened but it didn't make it to my inbox (and neither did the replies, which is kind of scary). Rather that trying to resurrect that thread from lore, I figured it would be best to just send the v2 as the commit message needed a bit of cleanup.

Changes since v1 <[email protected]>:

* Clean up the commit message a bit.

---
 arch/riscv/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/riscv/Makefile +2 -0
index 3fa8ef336822..e7d52a2301e2 100644
@@ -37,6 +37,7 @@ else
 endif
 
 ifeq ($(CONFIG_LD_IS_LLD),y)
+ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM
 	KBUILD_AFLAGS += -Wa,-mno-relax
 endif
 endif
+endif
 
 # ISA string setting
 riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Tested-by on v1 1/1
#1 lore raw
Quoted 17 lines · Palmer Dabbelt

From: Fangrui Song <[email protected]>

lld since llvm:6611d58f5bbc ("[ELF] Relax R_RISCV_ALIGN"), which will be included in the 15.0.0 release, has implemented some RISC-V linker relaxation. -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to suppress R_RISCV_ALIGN which older lld can not handle:

ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax

Quoted 6 lines

---
Fanguri poked me about this one on IRC, I'm not sure what happened but it didn't make it to my inbox (and neither did the replies, which is kind of scary). Rather that trying to resurrect that thread from lore, I figured it would be best to just send the v2 as the commit message needed a bit of cleanup.

One of the replies was a T-b from Nathan:
https://lore.kernel.org/linux-riscv/YsxfiKC%[email protected]/
dunno if you wanna pick that up or he wants to resend..

I gave it a whirl too, so:

Quoted 36 lines

Changes since v1 <[email protected]>:

* Clean up the commit message a bit.

---
 arch/riscv/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/riscv/Makefile +2 -0
index 3fa8ef336822..e7d52a2301e2 100644
@@ -37,6 +37,7 @@ else
 endif
 
 ifeq ($(CONFIG_LD_IS_LLD),y)
+ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM
 	KBUILD_AFLAGS += -Wa,-mno-relax
 endif
 endif
+endif
 
 # ISA string setting
 riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#2 lore raw
Quoted 25 lines · On Sun, 18 Sep 2022 02:57:11 PDT (-0700), [email protected] wrote:
Quoted 17 lines · Palmer Dabbelt

From: Fangrui Song <[email protected]>

lld since llvm:6611d58f5bbc ("[ELF] Relax R_RISCV_ALIGN"), which will be included in the 15.0.0 release, has implemented some RISC-V linker relaxation. -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to suppress R_RISCV_ALIGN which older lld can not handle:

ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax

Quoted 6 lines

---
Fanguri poked me about this one on IRC, I'm not sure what happened but it didn't make it to my inbox (and neither did the replies, which is kind of scary). Rather that trying to resurrect that thread from lore, I figured it would be best to just send the v2 as the commit message needed a bit of cleanup.

Quoted 6 lines

One of the replies was a T-b from Nathan:
https://lore.kernel.org/linux-riscv/YsxfiKC%[email protected]/
dunno if you wanna pick that up or he wants to resend..

I gave it a whirl too, so:

Thanks, I just picked both up.

Quoted 33 lines
Quoted 33 lines

Changes since v1 <[email protected]>:

* Clean up the commit message a bit.

---
 arch/riscv/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/riscv/Makefile +2 -1
index 3fa8ef336822..e7d52a2301e2 100644
@@ -37,6 +37,7 @@ else
 endif
 
 ifeq ($(CONFIG_LD_IS_LLD),y)
+ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM
 	KBUILD_AFLAGS += -Wa,-mno-relax
 endif
 endif
+endif
 
 # ISA string setting
 riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
--

2.34.1

Quoted 4 lines
Quoted 4 lines

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#3 lore raw
Quoted 26 lines · Palmer Dabbelt
Quoted 25 lines · On Sun, 18 Sep 2022 02:57:11 PDT (-0700), [email protected] wrote:
Quoted 23 lines · Palmer Dabbelt

From: Fangrui Song <[email protected]>

lld since llvm:6611d58f5bbc ("[ELF] Relax R_RISCV_ALIGN"), which will be included in the 15.0.0 release, has implemented some RISC-V linker relaxation. -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to suppress R_RISCV_ALIGN which older lld can not handle:

ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax

---
Fanguri poked me about this one on IRC, I'm not sure what happened but it didn't make it to my inbox (and neither did the replies, which is kind of scary). Rather that trying to resurrect that thread from lore, I figured it would be best to just send the v2 as the commit message needed a bit of cleanup.

Quoted 8 lines
Quoted 6 lines

One of the replies was a T-b from Nathan:
https://lore.kernel.org/linux-riscv/YsxfiKC%[email protected]/
dunno if you wanna pick that up or he wants to resend..

I gave it a whirl too, so:

Thanks, I just picked both up.

and turns out I'd forgotten the stable tag, so I'm gonig to hold this one off until next week.

Quoted 34 lines
Quoted 34 lines
Quoted 34 lines

Changes since v1 <[email protected]>:

* Clean up the commit message a bit.

---
 arch/riscv/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/riscv/Makefile +2 -1
index 3fa8ef336822..e7d52a2301e2 100644
@@ -37,6 +37,7 @@ else
 endif
 
 ifeq ($(CONFIG_LD_IS_LLD),y)
+ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM
 	KBUILD_AFLAGS += -Wa,-mno-relax
 endif
 endif
+endif
 
 # ISA string setting
 riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
--

2.34.1

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv