<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - __WORDSIZE defined as 32 for aarch64-linux-gnu"
href="https://bugs.llvm.org/show_bug.cgi?id=40415">40415</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>__WORDSIZE defined as 32 for aarch64-linux-gnu
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Headers
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ndesaulniers@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, kristof.beyls@arm.com, llvm-bugs@lists.llvm.org, peter.smith@linaro.org, pirama@google.com, richard-llvm@metafoo.co.uk, srhines@google.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21365" name="attach_21365" title="wordsize.c">attachment 21365</a> <a href="attachment.cgi?id=21365&action=edit" title="wordsize.c">[details]</a></span>
wordsize.c
glibc's stdint.h for aarch64-linux-gnu uses the preprocessor symbol __WORDSIZE
to set the typedef of uint64_t. GCC sets this to symbol to 64, while Clang
sets it to 32 (I think Clang is in the wrong).
ex:
$ cat wordsize.c
#include <stdint.h>
int foo() {
return __WORDSIZE;
}
$ clang -target aarch64-linux-gnu -c wordsize.c
$ llvm-objdump -d wordsize.o
wordsize.o: file format ELF64-aarch64-little
Disassembly of section .text:
0000000000000000 foo:
0: e0 03 1b 32 orr w0, wzr, #0x20 ; 0x20 == 32
4: c0 03 5f d6 ret
$ aarch64-linux-gnu-gcc -c wordsize.c
$ llvm-objdump -d wordsize.o
wordsize.o: file format ELF64-aarch64-little
Disassembly of section .text:
0000000000000000 foo:
0: 00 08 80 52 mov w0, #64
4: c0 03 5f d6 ret
Relevant section from /usr/aarch64-linux-gnu/include/stdint.h:
#if __WORDSIZE == 64
typedef unsigned long int uint64_t;
#else
__extension__
typedef unsigned long long int uint64_t;
#endif</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>