[LLVMdev] error: instruction requires: thumb2

1,010 views
Skip to first unread message

Lei Zhao

unread,
Aug 16, 2012, 3:55:54 PM8/16/12
to llv...@cs.uiuc.edu
Hi Everybody,

I recently did a cross-compiling using clang (built with host=x86, target=arm) with the following command:

> clang -march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-none-linux-gnueabi -integrated-as main.c -o main.o -c

and get error message:

-------------------------------------------------------
main.c:9:9: error: instruction requires: thumb2
"ldrex %[oldValue], [%[ptr], #0]\n" // oldValue = *ptr
^
<inline asm>:1:2: note: instantiated into assembly here
ldrex r6, [r4, #0]
^
main.c:11:3: error: instruction requires: thumb2
"strexeq %[failed], %[newValue], [%[ptr], #0]\n"
^
<inline asm>:3:1: note: instantiated into assembly here
strexeq r5, lr, [r4, #0]
^
2 errors generated.
-------------------------------------------------------

In the main.c, some ARM assembly are embedded which contains instructions ldrex, strexeq. I don't know what the message suggests since the cpu specified does support thumb2. Could someone help? Thanks.

- Lei



_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Eli Friedman

unread,
Aug 16, 2012, 4:00:57 PM8/16/12
to Lei Zhao, llv...@cs.uiuc.edu
On Thu, Aug 16, 2012 at 12:55 PM, Lei Zhao <leizh...@gmail.com> wrote:
> Hi Everybody,
>
> I recently did a cross-compiling using clang (built with host=x86, target=arm) with the following command:
>
> > clang -march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-none-linux-gnueabi -integrated-as main.c -o main.o -c
>
> and get error message:
>
> -------------------------------------------------------
> main.c:9:9: error: instruction requires: thumb2
> "ldrex %[oldValue], [%[ptr], #0]\n" // oldValue = *ptr
> ^
> <inline asm>:1:2: note: instantiated into assembly here
> ldrex r6, [r4, #0]
> ^
> main.c:11:3: error: instruction requires: thumb2
> "strexeq %[failed], %[newValue], [%[ptr], #0]\n"
> ^
> <inline asm>:3:1: note: instantiated into assembly here
> strexeq r5, lr, [r4, #0]
> ^
> 2 errors generated.
> -------------------------------------------------------
>
> In the main.c, some ARM assembly are embedded which contains instructions ldrex, strexeq. I don't know what the message suggests since the cpu specified does support thumb2. Could someone help? Thanks.

Try "-mthumb".

-Eli

Lei Zhao

unread,
Aug 16, 2012, 4:12:43 PM8/16/12
to Eli Friedman, llv...@cs.uiuc.edu
It works. Thanks.

- Lei

Lei Zhao

unread,
Aug 16, 2012, 5:36:39 PM8/16/12
to Eli Friedman, llv...@cs.uiuc.edu
It works. But a follow-up question: why do I have to compile it to thumb mode in order to pass the compilation? Is there a way to make it compile to regular arm mode? Thanks.

- Lei

On Aug 16, 2012, at 4:00 PM, Eli Friedman wrote:

Jim Grosbach

unread,
Aug 16, 2012, 6:02:09 PM8/16/12
to Lei Zhao, llv...@cs.uiuc.edu
Sure. Use legal ARM mode syntax for the instruction.

Specifically, there is no offset immediate for the ARM mode LDREX instruction. It's illegal syntax to supply one, even if it's zero.

-Jim

Lei Zhao

unread,
Aug 16, 2012, 6:09:19 PM8/16/12
to Jim Grosbach, llv...@cs.uiuc.edu
Aha, thanks.

- Lei
Reply all
Reply to author
Forward
0 new messages