Re: [PATCH] kbuild: make Clang build userprogs for target architecture
From: Masahiro Yamada
Date: Sun Jul 05 2020 - 11:30:24 EST
On Wed, Jul 1, 2020 at 4:13 AM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>
> On Tue, Jun 30, 2020 at 6:26 PM Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote:
> >
> > I can reproduce this in the following
> > simple test code:
> >
> >
> > ----------------->8----------------
> > #include <stdio.h>
> >
> > int main(void)
> > {
> > ssize_t x = 1;
> >
> > printf("%zd", x);
> >
> > return 0;
> > }
> > --------------->8-------------------
>
> That is the old implicit int rule. Try including sys/types.h or
> compiling with a standard like -std=c99 for instance.
>
> Cheers,
> Miguel
Hmm, adding '#include <sys/types.h>' did not make any difference.
If I add -std=c99, I get a different error.
$ clang -std=c99 --target=aarch64-linux-gnu test.c
test.c:5:10: error: unknown type name 'ssize_t'; did you mean 'size_t'?
ssize_t x = 1;
^~~~~~~
size_t
/home/masahiro/tools/clang-latest/lib/clang/11.0.0/include/stddef.h:46:23:
note: 'size_t' declared here
typedef __SIZE_TYPE__ size_t;
^
1 error generated.
In contrast, 'size_t' has no problem.
----------------->8----------------
#include <stdio.h>
int main(void)
{
size_t x = 1;
printf("%zu", x);
return 0;
}
--------------->8-------------------
$ clang --target=aarch64-linux-gnu test.c
[ No warning ]
--
Best Regards
Masahiro Yamada