* [PATCH] riscv: Use -mno-relax when using lld linker
@ 2021-05-14 20:56 Khem Raj
2021-05-14 21:14 ` Nathan Chancellor
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Khem Raj @ 2021-05-14 20:56 UTC (permalink / raw)
To: linux-riscv, clang-built-linux
Cc: Khem Raj, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Nathan Chancellor, Nick Desaulniers
lld does not implement the RISCV relaxation optimizations like GNU ld
therefore disable it when building with LLVM=1, Also pass it to
assembler when using external GNU assembler ( LLVM_IAS != 1 ), this
ensures that relevant assembler option is also enabled along. if these
options are not used then we see following relocations in objects
0000000000000000 R_RISCV_ALIGN *ABS*+0x0000000000000002
These are then rejected by lld
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
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
---
arch/riscv/Makefile | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 3eb9590a0775..519f133e0d53 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -38,6 +38,15 @@ else
KBUILD_LDFLAGS += -melf32lriscv
endif
+ifeq ($(LLVM),1)
+ KBUILD_CFLAGS += -mno-relax
+ KBUILD_AFLAGS += -mno-relax
+ifneq ($(LLVM_IAS),1)
+ KBUILD_CFLAGS += -Wa,-mno-relax
+ KBUILD_AFLAGS += -Wa,-mno-relax
+endif
+endif
+
# ISA string setting
riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
--
2.31.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: Use -mno-relax when using lld linker
2021-05-14 20:56 [PATCH] riscv: Use -mno-relax when using lld linker Khem Raj
@ 2021-05-14 21:14 ` Nathan Chancellor
2021-05-14 21:14 ` Fāng-ruì Sòng
2021-05-29 18:40 ` Palmer Dabbelt
2 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2021-05-14 21:14 UTC (permalink / raw)
To: Khem Raj, linux-riscv, clang-built-linux
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Nick Desaulniers
Hi Khem,
On 5/14/2021 1:56 PM, Khem Raj wrote:
> lld does not implement the RISCV relaxation optimizations like GNU ld
> therefore disable it when building with LLVM=1, Also pass it to
> assembler when using external GNU assembler ( LLVM_IAS != 1 ), this
> ensures that relevant assembler option is also enabled along. if these
> options are not used then we see following relocations in objects
>
> 0000000000000000 R_RISCV_ALIGN *ABS*+0x0000000000000002
>
> These are then rejected by lld
> 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
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Paul Walmsley <paul.walmsley@sifive.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Albert Ou <aou@eecs.berkeley.edu>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
Thank you for the patch! I can build a ARCH=riscv defconfig kernel with
LLVM=1 now. LLVM_IAS=1 still needs work but we have outstanding issues
for that:
https://github.com/ClangBuiltLinux/linux/issues/1023
https://github.com/ClangBuiltLinux/linux/issues/1143
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
One comment below though.
> ---
> arch/riscv/Makefile | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 3eb9590a0775..519f133e0d53 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -38,6 +38,15 @@ else
> KBUILD_LDFLAGS += -melf32lriscv
> endif
>
> +ifeq ($(LLVM),1)
ifeq ($(CONFIG_LD_IS_LLD),y)
is a better choice so that LD=riscv64-linux-gnu-ld LLVM=1 can still work.
> + KBUILD_CFLAGS += -mno-relax
> + KBUILD_AFLAGS += -mno-relax
> +ifneq ($(LLVM_IAS),1)
> + KBUILD_CFLAGS += -Wa,-mno-relax
> + KBUILD_AFLAGS += -Wa,-mno-relax
> +endif
> +endif
> +
> # ISA string setting
> riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
> riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: Use -mno-relax when using lld linker
2021-05-14 20:56 [PATCH] riscv: Use -mno-relax when using lld linker Khem Raj
2021-05-14 21:14 ` Nathan Chancellor
@ 2021-05-14 21:14 ` Fāng-ruì Sòng
2021-05-29 18:40 ` Palmer Dabbelt
2 siblings, 0 replies; 5+ messages in thread
From: Fāng-ruì Sòng @ 2021-05-14 21:14 UTC (permalink / raw)
To: Khem Raj
Cc: linux-riscv, clang-built-linux, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Nathan Chancellor, Nick Desaulniers
On Fri, May 14, 2021 at 1:57 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> lld does not implement the RISCV relaxation optimizations like GNU ld
> therefore disable it when building with LLVM=1, Also pass it to
> assembler when using external GNU assembler ( LLVM_IAS != 1 ), this
> ensures that relevant assembler option is also enabled along. if these
> options are not used then we see following relocations in objects
>
> 0000000000000000 R_RISCV_ALIGN *ABS*+0x0000000000000002
>
> These are then rejected by lld
> 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
This means -mno-relax should emit .option norelax in the assembly.
I'll try fixing this in Clang 13.
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Paul Walmsley <paul.walmsley@sifive.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Albert Ou <aou@eecs.berkeley.edu>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> ---
> arch/riscv/Makefile | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 3eb9590a0775..519f133e0d53 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -38,6 +38,15 @@ else
> KBUILD_LDFLAGS += -melf32lriscv
> endif
>
> +ifeq ($(LLVM),1)
> + KBUILD_CFLAGS += -mno-relax
> + KBUILD_AFLAGS += -mno-relax
> +ifneq ($(LLVM_IAS),1)
> + KBUILD_CFLAGS += -Wa,-mno-relax
> + KBUILD_AFLAGS += -Wa,-mno-relax
> +endif
> +endif
> +
> # ISA string setting
> riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
> riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
> --
> 2.31.1
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210514205643.383422-1-raj.khem%40gmail.com.
--
宋方睿
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: Use -mno-relax when using lld linker
2021-05-14 20:56 [PATCH] riscv: Use -mno-relax when using lld linker Khem Raj
2021-05-14 21:14 ` Nathan Chancellor
2021-05-14 21:14 ` Fāng-ruì Sòng
@ 2021-05-29 18:40 ` Palmer Dabbelt
2021-05-29 18:42 ` Palmer Dabbelt
2 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2021-05-29 18:40 UTC (permalink / raw)
To: Khem Raj
Cc: linux-riscv, clang-built-linux, Khem Raj, Paul Walmsley, aou,
nathan, ndesaulniers
On Fri, 14 May 2021 13:56:43 PDT (-0700), Khem Raj wrote:
> lld does not implement the RISCV relaxation optimizations like GNU ld
> therefore disable it when building with LLVM=1, Also pass it to
> assembler when using external GNU assembler ( LLVM_IAS != 1 ), this
> ensures that relevant assembler option is also enabled along. if these
> options are not used then we see following relocations in objects
>
> 0000000000000000 R_RISCV_ALIGN *ABS*+0x0000000000000002
>
> These are then rejected by lld
> 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
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Paul Walmsley <paul.walmsley@sifive.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Albert Ou <aou@eecs.berkeley.edu>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> ---
> arch/riscv/Makefile | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 3eb9590a0775..519f133e0d53 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -38,6 +38,15 @@ else
> KBUILD_LDFLAGS += -melf32lriscv
> endif
>
> +ifeq ($(LLVM),1)
> + KBUILD_CFLAGS += -mno-relax
> + KBUILD_AFLAGS += -mno-relax
> +ifneq ($(LLVM_IAS),1)
> + KBUILD_CFLAGS += -Wa,-mno-relax
> + KBUILD_AFLAGS += -Wa,-mno-relax
> +endif
> +endif
> +
> # ISA string setting
> riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
> riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
Thanks, this is on fixes.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: Use -mno-relax when using lld linker
2021-05-29 18:40 ` Palmer Dabbelt
@ 2021-05-29 18:42 ` Palmer Dabbelt
0 siblings, 0 replies; 5+ messages in thread
From: Palmer Dabbelt @ 2021-05-29 18:42 UTC (permalink / raw)
To: Khem Raj
Cc: linux-riscv, clang-built-linux, Khem Raj, Paul Walmsley, aou,
nathan, ndesaulniers
On Sat, 29 May 2021 11:40:39 PDT (-0700), Palmer Dabbelt wrote:
> On Fri, 14 May 2021 13:56:43 PDT (-0700), Khem Raj wrote:
>> lld does not implement the RISCV relaxation optimizations like GNU ld
>> therefore disable it when building with LLVM=1, Also pass it to
>> assembler when using external GNU assembler ( LLVM_IAS != 1 ), this
>> ensures that relevant assembler option is also enabled along. if these
>> options are not used then we see following relocations in objects
>>
>> 0000000000000000 R_RISCV_ALIGN *ABS*+0x0000000000000002
>>
>> These are then rejected by lld
>> 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
>>
>> Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> Cc: Paul Walmsley <paul.walmsley@sifive.com>
>> Cc: Palmer Dabbelt <palmer@dabbelt.com>
>> Cc: Albert Ou <aou@eecs.berkeley.edu>
>> Cc: Nathan Chancellor <nathan@kernel.org>
>> Cc: Nick Desaulniers <ndesaulniers@google.com>
>> ---
>> arch/riscv/Makefile | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
>> index 3eb9590a0775..519f133e0d53 100644
>> --- a/arch/riscv/Makefile
>> +++ b/arch/riscv/Makefile
>> @@ -38,6 +38,15 @@ else
>> KBUILD_LDFLAGS += -melf32lriscv
>> endif
>>
>> +ifeq ($(LLVM),1)
>> + KBUILD_CFLAGS += -mno-relax
>> + KBUILD_AFLAGS += -mno-relax
>> +ifneq ($(LLVM_IAS),1)
>> + KBUILD_CFLAGS += -Wa,-mno-relax
>> + KBUILD_AFLAGS += -Wa,-mno-relax
>> +endif
>> +endif
>> +
>> # ISA string setting
>> riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
>> riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
>
> Thanks, this is on fixes.
Sorry, replied to the v1 but I merged the v2.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-29 18:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 20:56 [PATCH] riscv: Use -mno-relax when using lld linker Khem Raj
2021-05-14 21:14 ` Nathan Chancellor
2021-05-14 21:14 ` Fāng-ruì Sòng
2021-05-29 18:40 ` Palmer Dabbelt
2021-05-29 18:42 ` Palmer Dabbelt
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.