Bug 59217 - GCC fails to cross-build: conflicting declarations of 'basename', 'sbrk', etc.
Summary: GCC fails to cross-build: conflicting declarations of 'basename', 'sbrk', etc.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-20 17:57 UTC by Ludovic Courtès
Modified: 2013-11-23 15:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Courtès 2013-11-20 17:57:10 UTC
Cross-building GCC for GNU/Linux, with host & build glibc 2.18, fails while building genconstants, genhooks, & co:

#v+
In file included from ../../gcc-4.8.2/gcc/genenums.c:21:0:
../../gcc-4.8.2/gcc/system.h:444:23: error: declaration of C function 'void* sbrk(int)' conflicts with
 extern void *sbrk (int);
                       ^
In file included from ../../gcc-4.8.2/gcc/system.h:254:0,
                 from ../../gcc-4.8.2/gcc/genenums.c:21:
/nix/store/jwd1hc3i3pmnsxf2347r4k2c77nbr9vw-glibc-2.18/include/unistd.h:1065:14: error: previous declaration 'void* sbrk(intptr_t)' here
 extern void *sbrk (intptr_t __delta) __THROW;
[...]
In file included from ../../gcc-4.8.2/gcc/system.h:645:0,
                 from ../../gcc-4.8.2/gcc/genenums.c:21:
../../gcc-4.8.2/gcc/../include/libiberty.h:110:36: error: new declaration 'char* basename(const char*)'
 extern char *basename (const char *);
#v-

The configure flags are:

#v+
("CONFIG_SHELL=/nix/store/0r0r5wlg1mzf57haxfkalk62px93gch3-bash-4.2/bin/bash" "SHELL=/nix/store/0r0r5wlg1mzf57haxfkalk62px93gch3-bash-4.2/bin/bash" "--prefix=/nix/store/cjl2h4j31v03k13npnyb8v5q51qylp57-gcc-static-4.8.2" "--enable-fast-install" "--host=mips64el-linux-gnuabi64" "--disable-shared" "--disable-plugin" "--enable-languages=c" "--disable-libmudflap" "--disable-libatomic" "--disable-libsanitizer" "--disable-libitm" "--disable-libgomp" "--disable-libssp" "--disable-libquadmath" "--disable-decimal-float" "--disable-multilib" "--disable-libstdcxx-pch" "--with-local-prefix=/no-gcc-local-prefix" "--with-native-system-header-dir=/nix/store/jwd1hc3i3pmnsxf2347r4k2c77nbr9vw-glibc-2.18/include" "--with-abi=64" "CC_FOR_TARGET=mips64el-linux-gnuabi64-gcc" "CXX_FOR_TARGET=mips64el-linux-gnuabi64-g++" "LD_FOR_TARGET=mips64el-linux-gnuabi64-ld" "AR_FOR_TARGET=mips64el-linux-gnuabi64-ar" "NM_FOR_TARGET=mips64el-linux-gnuabi64-nm" "RANLIB_FOR_TARGET=mips64el-linux-gnuabi64-ranlib" "STRIP_FOR_TARGET=mips64el-linux-gnuabi64-strip")
#v-

(See <http://hydra.gnu.org/build/26604/nixlog/1/raw> for a complete log.)

One problem may be that all the configure tests are run with gcc (or mips*-gcc), whereas gen{enums,hooks,checksum}.c get built with g++.  G++ automatically defines _GNU_SOURCE.  That leads to <string.h> emitting a 'basename' declaration, for instance; likewise the sbrk declaration in <unistd.h> is conditioned by various __USE flags, which are prerequisites of __USE_GNU.

Suggestions?

Thanks,
Ludo'.
Comment 1 Ludovic Courtès 2013-11-23 15:12:09 UTC
After investigation I realized that the misdetections of missing 'basename' etc. declarations on the build machine was a side-effect of not having GMP/MPFR/MPC available for the build machine (presumably 'genconstants.c' & co. didn't include it in 4.7.)

So this bug can be closed.  Apologies for the noise!

Ludo'.

PS: For the record the corresponding fix in Guix is <http://git.savannah.gnu.org/cgit/guix.git/commit/?h=core-updates>.
Comment 2 Ludovic Courtès 2013-11-23 15:13:29 UTC
> PS: For the record the corresponding fix in Guix is
> <http://git.savannah.gnu.org/cgit/guix.git/commit/?h=core-updates>.

err, should read: <http://git.savannah.gnu.org/cgit/guix.git/commit/?h=core-updates&id=0ece70747028ee88c58dc90b1089b4f74f243015>.