Thread (8 messages) 8 messages, 4 authors, 2021-08-05

Re: [PATCH 1/3] RISC-V: build: Pass `-mattr` to `lld`

From: twd2 <hidden>
Date: 2021-08-05 20:13:31

Sure. I'll send a v2 after the LLVM issue is resolved.

Thanks!
Wende


On 2021/8/5 4:59, Palmer Dabbelt wrote:
On Mon, 19 Jul 2021 14:14:59 PDT (-0700), ndesaulniers@google.com wrote:
quoted
On Mon, Jul 19, 2021 at 1:53 PM Wende Tan [off-list ref] wrote:
quoted
Pass `-mattr` to `lld` so that it can generate proper machine code.
By the way, it seems that `-march` does not work well now.

Signed-off-by: Wende Tan <redacted>
---
 arch/riscv/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index bc74afdbf31e..bbc186a3ab45 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -52,9 +52,16 @@ riscv-march-$(CONFIG_ARCH_RV32I)     := rv32ima
 riscv-march-$(CONFIG_ARCH_RV64I)       := rv64ima
 riscv-march-$(CONFIG_FPU)              := $(riscv-march-y)fd
 riscv-march-$(CONFIG_RISCV_ISA_C)      := $(riscv-march-y)c
+riscv-mattr-y                          := +m,+a
+riscv-mattr-$(CONFIG_FPU)              := $(riscv-mattr-y),+f,+d
+riscv-mattr-$(CONFIG_RISCV_ISA_C)      := $(riscv-mattr-y),+c
 KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
 KBUILD_AFLAGS += -march=$(riscv-march-y)

+ifeq ($(CONFIG_LD_IS_LLD),y)
+       KBUILD_LDFLAGS += -mllvm -mattr=$(riscv-mattr-y)
We should prevent the proliferation of the compiler internal `-mllvm`
flags from Kbuild Makefiles; these are indicative of LLVM IR specific
issues with regards to LTO.  Can you please file a bug against LLVM
that `-mattr` should be encoded in the IR for LTO's sake?
Works for me.  I'll hold off on taking this until the LLVM bug gets sorted out and expect a v2 (ideally with the other textual changes Nick suggested).

Thanks!
quoted
See also:
commit 0236526d76b8 ("Makefile: lto: Pass -warn-stack-size only on LLD
< 13.0.0")
commit 2398ce80152a ("x86, lto: Pass -stack-alignment only on LLD < 13.0.0")
quoted
+endif
+
 KBUILD_CFLAGS += -mno-save-restore
 KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)

-- 
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help