[cfe-dev] Question about thumb2 define in clang for ARMv8

Mikhail R. Gadelha via cfe-dev cfe-dev at lists.llvm.org
Fri Dec 10 11:05:53 PST 2021


Hi,

Em sex., 10 de dez. de 2021 às 12:37, Peter Smith <Peter.Smith at arm.com>
escreveu:

> Hello,
>
>
>
> My turn for the double post, my mail client stripped off the list on
> reply-all and I’d assumed it was llvm-dev. My apologies, resending back on
> cfe-dev
>
>
>
> This is likely down to the default triple and CPU that clang uses.
>
>
>
> An arm-linux-gnueabihf-gcc defaults to Thumb architecture v7-A which
> supports Thumb2. Whereas clang defaults to Arm state and architecture v4t
> which does not support Thumb2.
>
>
>
> On a relatively recent build of clang, but I think this goes back some way:
>
> clang --target=arm-linux-gnueabihf -mthumb -march=armv7-a -dM -E - <
> /dev/null | grep thumb
>
> #define __thumb2__ 1
>
> #define __thumb__ 1
>
>
>
> Can you give that a try?
>
>
Nice, it now defines them:

$ clang --target=arm-linux-gnueabihf -mthumb -march=armv7-a -dM -E - <
/dev/null | grep thumb
#define __thumb2__ 1
#define __thumb__ 1

but does it mean that if I don't pass these arguments clang won't thumb2
code? Despite __ARM_ARCH_ISA_THUMB being set to 2?

Thank you


>
>
> Peter
>
>
>
>
>
> *From:* cfe-dev <cfe-dev-bounces at lists.llvm.org> *On Behalf Of *Mikhail
> R. Gadelha via cfe-dev
> *Sent:* 10 December 2021 15:32
> *To:* clang mailing-list <cfe-dev at lists.llvm.org>
> *Subject:* [cfe-dev] Question about thumb2 define in clang for ARMv8
>
>
>
> (Sorry if this is a double post, I sent this email a few days ago from an
> e-mail that's not subscribed to the mailing list and it seems to be stuck
> in moderation).
>
>
>
> Hi everyone,
>
> tl;dr: GCC defines __thumb2__ in ARMv8 and clang doesn't. Is that a bug?
> Is there a better way to check if thumb2 is supported? Maybe
> __ARM_ARCH_ISA_THUMB?
>
> ~
>
> I recently started to work with Webkit in ARMv8 and decided to give clang
> a try building the javascript engine (called JSC) used by WebKit.
>
> However, it turns out the JIT was always disabled because of a CMake
> script that checks if the compiler defines either thumb2 or __thumb2__:
>
>
> https://github.com/WebKit/WebKit/blob/363701084a50c009bec41164cdb843df66d769d1/Source/cmake/OptionsCommon.cmake#L31
>
>
> I've tested with some other versions of clang but none seem to define it:
> https://godbolt.org/z/WjGh3eTzv
>
> While __thumb2__ is defined in GCC:
>
> $ gcc -dM -E  main.c  | grep thumb
> #define __thumb2__ 1
> #define __thumb__ 1
>
> clang doesn't define __thumb__ nor __thumb2__.
>
> I managed to get clang with __thumb2__ defined by:
> 1. Changing the triplet: I eventually got a lot of compilation errors and
> gave up.
> 2. Added "-D__thumb__=1" to CMAKE_CXX_FLAGS :P and managed to fully build
> JSC. There were some regressions in a place I was investigating a bug but
> nothing major.
>
> Anyway, I guess my questions are:
> 1. Is there a reason why __thumb2__ isn't defined in clang? Do we want it
> to be defined in clang?
> 2. Should we change WebKit to check if "__ARM_ARCH_ISA_THUMB" is 2 as per
> [0], instead of __thumb2__? (both GCC and clang seem to define it to 2 in
> the hardware I'm testing).
>
> Thanks in advance.
> Mikhail.
>
> [0]
> https://github.com/llvm/llvm-project/blob/8ee55ab6c06ec9f769f1086e3761c92286d56339/clang/lib/Basic/Targets/ARM.cpp#L709
>
>
>
> --
>
>
>
> Mikhail R. Gadelha.
>


-- 

Mikhail Ramalho.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20211210/8bc4bade/attachment.html>


More information about the cfe-dev mailing list