<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hello,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">This is likely down to the default triple and CPU that clang uses.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">On a relatively recent build of clang, but I think this goes back some way:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">clang --target=arm-linux-gnueabihf -mthumb -march=armv7-a -dM -E - < /dev/null | grep thumb<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">#define __thumb2__ 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">#define __thumb__ 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Can you give that a try?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Peter<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> cfe-dev <cfe-dev-bounces@lists.llvm.org>
<b>On Behalf Of </b>Mikhail R. Gadelha via cfe-dev<br>
<b>Sent:</b> 10 December 2021 15:32<br>
<b>To:</b> clang mailing-list <cfe-dev@lists.llvm.org><br>
<b>Subject:</b> [cfe-dev] Question about thumb2 define in clang for ARMv8<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">(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).<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Hi everyone,<br>
<br>
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?<br>
<br>
~<br>
<br>
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.<br>
<br>
However, it turns out the JIT was always disabled because of a CMake script that checks if the compiler defines either thumb2 or __thumb2__:<br>
<br>
<a href="https://github.com/WebKit/WebKit/blob/363701084a50c009bec41164cdb843df66d769d1/Source/cmake/OptionsCommon.cmake#L31">https://github.com/WebKit/WebKit/blob/363701084a50c009bec41164cdb843df66d769d1/Source/cmake/OptionsCommon.cmake#L31</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
I've tested with some other versions of clang but none seem to define it: <a href="https://godbolt.org/z/WjGh3eTzv">
https://godbolt.org/z/WjGh3eTzv</a><br>
<br>
While __thumb2__ is defined in GCC:<br>
<br>
$ gcc -dM -E main.c | grep thumb<br>
#define __thumb2__ 1<br>
#define __thumb__ 1<br>
<br>
clang doesn't define __thumb__ nor __thumb2__.<br>
<br>
I managed to get clang with __thumb2__ defined by:<br>
1. Changing the triplet: I eventually got a lot of compilation errors and gave up.<br>
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.<br>
<br>
Anyway, I guess my questions are:<br>
1. Is there a reason why __thumb2__ isn't defined in clang? Do we want it to be defined in clang?<br>
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).<br>
<br>
Thanks in advance.<br>
Mikhail.<br>
<br>
[0] <a href="https://github.com/llvm/llvm-project/blob/8ee55ab6c06ec9f769f1086e3761c92286d56339/clang/lib/Basic/Targets/ARM.cpp#L709">
https://github.com/llvm/llvm-project/blob/8ee55ab6c06ec9f769f1086e3761c92286d56339/clang/lib/Basic/Targets/ARM.cpp#L709</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Mikhail R. Gadelha.<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>