Closed arndb closed 3 years ago
I tried removing the option, but ran into the old problem that implicit-it is absolutely required for the kernel sources. I had tried converting the sources to explicit IT instructions in the past, but eventually given up on that because there was too much to change.
I assume that clang does implement implicit-it, because otherwise it would also break on a lot of user space code with inline assembly, but I could not find the correct replacement command line option.
I found that replacing "-Wa,-mimplicit-it=always" with "-mllvm --arm-implicit-it=always" gets it to mostly build:
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -124,7 +124,11 @@ endif
AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W)
ifeq ($(CONFIG_THUMB2_KERNEL),y)
+ifeq ($(LLVM_IAS),1)
+CFLAGS_ISA :=-mthumb -mllvm --arm-implicit-it=always $(AFLAGS_NOWARN)
+else
CFLAGS_ISA :=-mthumb -Wa,-mimplicit-it=always $(AFLAGS_NOWARN)
+endif
AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb
else
CFLAGS_ISA :=$(call cc-option,-marm,) $(AFLAGS_NOWARN)
but this runs into a number of new issues. Attaching a log from an allmodconfig build with CONFIG_ARCH_MULTI_V6=n and CONFIG_THUMB2_KERNEL=y
Some of the interesting ones:
<instantiation>:22:7: error: operand must be a register in range [r0, r14]
movs pc, lr @ return & move spsr_svc into cpsr
/git/arm-soc/arch/arm/kernel/entry-common.S:73:2: note: while in macro instantiation
restore_user_regs fast = 1, offset = 8
<instantiation>:1:23: error: too many operands for instruction
9999: ldr.w r3, [r1], #4; .pushsection __ex_table,"a"; .align 3; .long 9999b,20f; .popsection
^
/git/arm-soc/arch/arm/lib/copy_template.S:131:3: note: while in macro instantiation
ldr1w r1, r3, abort=20f
/git/arm-soc/arch/arm/lib/memmove.S:87:3: error: invalid instruction
ldr.w r3, [r1, #-4]!
/git/arm-soc/arch/arm/probes/kprobes/test-thumb.c:444:2: error: invalid operand for instruction
TEST_RX("tbh [pc, r",7, (9f-(1f+4))>>1,"]",
^
/git/arm-soc/arch/arm/probes/kprobes/test-core.h:387:2: note: expanded from macro 'TEST_RX'
TEST_INSTRUCTION(code1 __stringify(reg) code2) \
^
/git/arm-soc/arch/arm/probes/kprobes/test-core.h:155:17: note: expanded from macro 'TEST_INSTRUCTION'
"50: nop \n\t" \
^
<inline asm>:20:9: note: instantiated into assembly here
1: tbh [pc, r7]
arch/arm/crypto/curve25519-core.S:1933:2: error: instruction requires: NEON
I fixed the curve25519 crypto code using
--- a/arch/arm/crypto/curve25519-core.S
+++ b/arch/arm/crypto/curve25519-core.S
@@ -10,8 +10,8 @@
#include <linux/linkage.h>
.text
-.fpu neon
.arch armv7-a
+.fpu neon
.align 4
ENTRY(curve25519_neon)
but I don't know what to do about the others
/git/arm-soc/arch/arm/probes/kprobes/test-thumb.c:444:2: error: invalid operand for instruction
Is #1271 .
For the .w
suffixes, I ran into that as well in the patch for #1271 in thumb mode; though those look like inline asm.
:22:7: error: operand must be a register in range [r0, r14]
also looks like #1271 / https://reviews.llvm.org/D95586.
Kernel builds with CONFIG_THUMB2_KERNEL and integrated assembler fail for me with
clang: error: unsupported argument '-mimplicit-it=always' to option 'Wa,'