Subject: can't build external gcc

From: Tim Komarov <[email-masked]>
Date: Tue, 05 May 2020 04:35:31 +0300

Many projects (Buildroot, coreboot, Yocto) require building a toolchain.

Every time it tries to build it (I've checked Buildroot and coreboot) it fails with the following errors:

In file included from ./bconfig.h:3:0,
                 from ../../gcc/gengtype-lex.c:4:
./auto-host.h:2396:16: error: declaration does not declare anything [-fpermissive]
 #define rlim_t long
                ^
In file included from /d/gcc-8.4.0/gcc-8.4.0/gcc/gengtype-lex.l:30:0:
../../gcc/system.h:488:14: error: conflicting declaration of C function ‘void* sbrk(int)’
 extern void *sbrk (int);

In file included from /d/gcc-8.4.0/gcc-8.4.0/gcc/gengtype-lex.l:30:0:
../../gcc/system.h:496:14: error: ambiguating new declaration of ‘char* strstr(const char*, const char*)’
 extern char *strstr (const char *, const char *);

In file included from /d/gcc-8.4.0/gcc-8.4.0/gcc/gengtype-lex.l:30:0:
../../gcc/system.h:540:20: error: conflicting declaration of C function ‘const char* strsignal(int)’
 extern const char *strsignal (int);

In file included from ../../gcc/system.h:691:0,
                 from /d/gcc-8.4.0/gcc-8.4.0/gcc/gengtype-lex.l:30:
../../gcc/../include/libiberty.h:112:14: error: ambiguating new declaration of ‘char* basename(const char*)’
 extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);

Switching gcc versions doesn't help.

One can find a simple way to reproduce in buildroot.txt, build-gcc.log provides a complete log.

Looking forward for your help. Thanks!

-- 
Best Regards,
Timofey Komarov