Message ID | 1386105892-2379-2-git-send-email-apinski@cavium.com |
---|---|
State | New |
Headers | show |
On 3 December 2013 21:24, Andrew Pinski <pinskia@gmail.com> wrote: > > While compiling some programs, GCC and glibc (and newlib)'s definitions of size_t > were not agreeing and causing format warnings to happen. The simple testcase for this is: > #include <stdio.h> > #include <stdint.h> > > int main(void) > { > ssize_t t = 0x1; > printf("%zd\n", t); > return 0; > } Hi Andrew, The PCS IHI0056C defines SIZE_TYPE as 'unsigned long' for both ILP32 and LP64 and PTRDIFF_TYPE as "signed long" for both ILP32 and LP64. This seems like a sane choice to me. Trying to recreate the failure with the test fragment above doesn't given a warning: $ aarch64-none-elf-gcc -Wall -mabi=ilp32 test-size_t.c -specs=rdimon.specs $ aarch64-none-linux-gnu-gcc -Wall -mabi=ilp32 test-size_t.c -c $ ..what am I doing differently to your test run? Cheers /Marcus
On Tue, Dec 10, 2013 at 3:23 AM, Marcus Shawcroft <marcus.shawcroft@gmail.com> wrote: > On 3 December 2013 21:24, Andrew Pinski <pinskia@gmail.com> wrote: >> >> While compiling some programs, GCC and glibc (and newlib)'s definitions of size_t >> were not agreeing and causing format warnings to happen. The simple testcase for this is: >> #include <stdio.h> >> #include <stdint.h> >> >> int main(void) >> { >> ssize_t t = 0x1; >> printf("%zd\n", t); >> return 0; >> } > > Hi Andrew, > > The PCS IHI0056C defines SIZE_TYPE as 'unsigned long' for both ILP32 > and LP64 and PTRDIFF_TYPE as "signed long" for both ILP32 and LP64. > This seems like a sane choice to me. > > Trying to recreate the failure with the test fragment above doesn't > given a warning: > > $ aarch64-none-elf-gcc -Wall -mabi=ilp32 test-size_t.c -specs=rdimon.specs > $ aarch64-none-linux-gnu-gcc -Wall -mabi=ilp32 test-size_t.c -c > $ > > ..what am I doing differently to your test run? I found out it was a bug in glibc where it defines __SSIZE_T_TYPE to __SWORD_TYPE (int for ilp32 and long for lp64) rather than __SLONGWORD_TYPE (long always). I have fix for when I submit the glibc patches. Thanks, Andrew Pinski > > Cheers > /Marcus
--- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -144,9 +144,9 @@ /* Using long long breaks -ansi and -std=c90, so these will need to be made conditional for an LLP64 ABI. */ -#define SIZE_TYPE "long unsigned int" +#define SIZE_TYPE (TARGET_ILP32 ? "unsigned int" : "long unsigned int") -#define PTRDIFF_TYPE "long int" +#define PTRDIFF_TYPE (TARGET_ILP32 ? "int" : "long int") #define PCC_BITFIELD_TYPE_MATTERS 1