Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang ias: unsupported argument '-mimplicit-it=always' to option 'Wa,' #1270

Closed
arndb opened this issue Jan 27, 2021 · 6 comments
Closed

clang ias: unsupported argument '-mimplicit-it=always' to option 'Wa,' #1270

arndb opened this issue Jan 27, 2021 · 6 comments
Assignees
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list. [TOOL] integrated-as The issue is relevant to LLVM integrated assembler

Comments

@arndb
Copy link

arndb commented Jan 27, 2021

Kernel builds with CONFIG_THUMB2_KERNEL and integrated assembler fail for me with

clang: error: unsupported argument '-mimplicit-it=always' to option 'Wa,'

@arndb
Copy link
Author

arndb commented Jan 28, 2021

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.

@arndb
Copy link
Author

arndb commented Jan 28, 2021

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

thumb2-allmod.txt

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

@nickdesaulniers
Copy link
Member

/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.

@nickdesaulniers nickdesaulniers added [ARCH] arm32 This bug impacts ARCH=arm [TOOL] integrated-as The issue is relevant to LLVM integrated assembler labels Jan 30, 2021
@nickdesaulniers
Copy link
Member

nickdesaulniers commented Feb 3, 2021

https://llvm.org/pr49023

@nickdesaulniers nickdesaulniers added [BUG] llvm A bug that should be fixed in upstream LLVM Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list. labels Feb 3, 2021
@nickdesaulniers
Copy link
Member

@nickdesaulniers nickdesaulniers self-assigned this Feb 8, 2021
@nickdesaulniers nickdesaulniers added the [PATCH] Submitted A patch has been submitted for review label Feb 8, 2021
nickdesaulniers added a commit to llvm/llvm-project that referenced this issue Feb 11, 2021
Similiar to D95872, this flag can be set for the assembler directly.
Move validation code into a reusable helper function.

Link: https://bugs.llvm.org/show_bug.cgi?id=49023
Link: ClangBuiltLinux/linux#1270
Reported-by: Arnd Bergmann <[email protected]>
Signed-off-by: Nick Desaulniers <[email protected]>

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D96285
@nickdesaulniers
Copy link
Member

@nickdesaulniers nickdesaulniers added [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x and removed [PATCH] Submitted A patch has been submitted for review labels Feb 11, 2021
nickdesaulniers added a commit to ClangBuiltLinux/continuous-integration2 that referenced this issue Mar 30, 2021
llvm-13 will be the minimum for thumb2 LLVM_IAS=1 support.

We could also just remove these builds.

Link: ClangBuiltLinux/linux#1270
Signed-off-by: Nick Desaulniers <[email protected]>
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
Similiar to D95872, this flag can be set for the assembler directly.
Move validation code into a reusable helper function.

Link: https://bugs.llvm.org/show_bug.cgi?id=49023
Link: ClangBuiltLinux/linux#1270
Reported-by: Arnd Bergmann <[email protected]>
Signed-off-by: Nick Desaulniers <[email protected]>

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D96285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list. [TOOL] integrated-as The issue is relevant to LLVM integrated assembler
Projects
None yet
Development

No branches or pull requests

2 participants