<div dir="ltr">Right. Clang's logic for defining the ILP macros is very simple:<div><br></div><div><div>  if (TI.getPointerWidth(0) == 64 && TI.getLongWidth() == 64</div><div>      && TI.getIntWidth() == 32) {</div><div>    Builder.defineMacro("_LP64");</div><div>    Builder.defineMacro("__LP64__");</div><div>  }</div><div><br></div><div>  if (TI.getPointerWidth(0) == 32 && TI.getLongWidth() == 32</div><div>      && TI.getIntWidth() == 32) {</div><div>    Builder.defineMacro("_ILP32");</div><div>    Builder.defineMacro("__ILP32__");</div><div>  }</div><div><br></div></div><div>It happens on all platforms, not just x86. I think this is reasonable behavior and we should keep it, even if x86 gcc -m32 doesn't define this macro. As David said, don't use ILP32 to detect x32. You'll have a bad time on arm32.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 1, 2015 at 11:16 AM, Jeffrey Walton via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Dec 1, 2015 at 1:57 PM, Jeffrey Walton <<a href="mailto:noloader@gmail.com">noloader@gmail.com</a>> wrote:<br>
> On Tue, Dec 1, 2015 at 1:47 PM, David Chisnall<br>
> <<a href="mailto:David.Chisnall@cl.cam.ac.uk">David.Chisnall@cl.cam.ac.uk</a>> wrote:<br>
>> On 1 Dec 2015, at 18:36, Jeffrey Walton <<a href="mailto:noloader@gmail.com">noloader@gmail.com</a>> wrote:<br>
>>><br>
>>> When the i386 code is run on an x86_64 system (i.e., "arch i386<br>
>>> myprog.exe"), then we must interact with the stack using 64-bit values<br>
>>> and registers. Its an ABI requirement.<br>
>><br>
>> When i386 code is run on an x86-64 system, it is using a different system call layer, but is otherwise a normal 386 extended mode environment.  Without an explicit switch to long mode, it can not use any of the long mode registers.  There is most definitely not an ABI requirement that i386 code use non-i386 instructions.<br>
>><br>
> Thanks David.<br>
><br>
> I just checked a 64-bit Fedora system using the -m32 option (which I<br>
> believe is equivalent to -arch i386; corrections please). Neither GCC<br>
> nor Clang define ILP32 and friends. So this appears to be limited to<br>
> Apple systems.<br>
<br>
</span>My bad... I forgot the "-i" in my grep. It appears the issue is<br>
limited to Clang. GCC and Intel compilers do not define it:<br>
<br>
fedora-22 $ clang++ -x c++ -m32 -dM -E - < /dev/null | egrep -i "(ilp)"<br>
<span class="">#define _ILP32 1<br>
#define __ILP32__ 1<br>
<br>
</span>fedora-22 $ g++ -x c++ -m32 -dM -E - < /dev/null | egrep -i "(ilp)"<br>
$<br>
<br>
ubuntu-14 $ /opt/intel/bin/icpc -x c++ -m32 -dM -E - < /dev/null |<br>
egrep -i "(ilp)"<br>
$<br>
<br>
I'm not sure about Comeau's compiler because I do not have access to it.<br>
<div class="HOEnZb"><div class="h5"><br>
Jeff<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>