https://bugs.llvm.org/show_bug.cgi?id=40415

            Bug ID: 40415
           Summary: __WORDSIZE defined as 32 for aarch64-linux-gnu
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Headers
          Assignee: unassignedclangb...@nondot.org
          Reporter: ndesaulni...@google.com
                CC: craig.top...@gmail.com, kristof.be...@arm.com,
                    llvm-bugs@lists.llvm.org, peter.sm...@linaro.org,
                    pir...@google.com, richard-l...@metafoo.co.uk,
                    srhi...@google.com

Created attachment 21365
  --> https://bugs.llvm.org/attachment.cgi?id=21365&action=edit
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to