Subject: Re: [powerpc:next-test 54/220] arch/powerpc/kernel/vdso32/vgettimeofday.c:13:5: warning: no previous prototype for function '__c_kernel_clock_gettime64'

From: Segher Boessenkool <[email-masked]>
Date: Mon, 7 Dec 2020 12:20:58 -0600

On Mon, Dec 07, 2020 at 09:56:56AM -0800, Nick Desaulniers wrote:
> On Mon, Dec 7, 2020 at 4:23 AM Michael Ellerman <[email-masked]> wrote:
> > So is clang defining __powerpc64__ even for 32-bit code?
> >
> > And the answer appears to be yes:
> >
> >   $ clang --version
> >   Ubuntu clang version 11.0.0-2
> >   Target: powerpc64le-unknown-linux-gnu
> >
> >   $ clang -m32 -dM -E - < /dev/null | grep powerpc
> >   #define __powerpc64__ 1
> >   #define __powerpc__ 1
> >
> > Compare to gcc:
> >
> >   $ gcc --version
> >   gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0
> >
> >   $ gcc -m32 -dM -E - < /dev/null | grep powerpc
> >   #define __powerpc__ 1
> >   #define powerpc 1
> >   #define __powerpc 1
> >
> >
> > Which is fairly problematic, because we use the presence/absence of
> > __powerpc64__ to determine if we're building 64-bit/32-bit code in
> > several places.
> >
> > Not sure what the best approach for fixing that is.
> 
> Thanks for the triage; we should fix our preprocessor:
> https://bugs.llvm.org/show_bug.cgi?id=48427

Not only is that a compatibility problem (as the bug report says): it is
a straight up violation of the ABI!  (For ELFv2, which you have here;
older ABIs did not mention the preprocessor predefines, but this was
exactly the same on all compilers afaik.)

Segher