diff mbox

fix cross building a native compiler

Message ID 51B827DF.4030903@ubuntu.com
State New
Headers show

Commit Message

Matthias Klose June 12, 2013, 7:48 a.m. UTC
Trying to cross build a native compiler for arm-linux on x86_64 linux currently
fails to build, if the libgmp development files are not available for the build
system. This works with 4.7, but fails with 4.8.

The build fails with:

TARGET_CPU_DEFAULT="" \
        HEADERS="auto-build.h ansidecl.h" DEFINES="" \
        /bin/bash ../../src/gcc/mkconfig.sh bconfig.h
g++ -c   -g -O2 -DIN_GCC   -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual
-Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings   -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild
-I../../src/gcc -I../../src/gcc/build -I../../src/gcc/../include
-I../../src/gcc/../libcpp/include  -I../../src/gcc/../libdecnumber
-I../../src/gcc/../libdecnumber/dpd -I../libdecnumber
-I../../src/gcc/../libbacktrace -DCLOOG_INT_GMP    \
                -o build/genconstants.o ../../src/gcc/genconstants.c
In file included from /usr/include/x86_64-linux-gnu/sys/resource.h:25:0,
                 from ../../src/gcc/system.h:395,
                 from ../../src/gcc/genconstants.c:28:
/usr/include/x86_64-linux-gnu/bits/resource.h:131:18: error: declaration does
not declare anything [-fpermissive]
In file included from ../../src/gcc/genconstants.c:28:0:
../../src/gcc/system.h:444:23: error: declaration of C function 'void*
sbrk(int)' conflicts with


Searching the archive and ML this is supposed to work according to
PR 35051, as described in http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00041.html

When building the auto-build.h, all the configure tests including the system.h
header fail to build with

configure:10361: gcc -c   -I../../../src/gcc -I../../../src/gcc/../include
conftest.c >&5
In file included from ../../../src/gcc/system.h:641:0,
                 from conftest.c:116:
/usr/include/gmp.h:69:24: fatal error: gmp-x86_64.h: No such file or directory
compilation terminated.

And at least all the HAVE_DECL_* defines are set to 0 instead of 1.

[side note: can we keep the temporary directory for this? it's a bit
 strange that this directory is removed during the build, and can't
 be looked at. The build continues after the configure, and then
 fails later]

I checked that defining GENERATOR_FILE for this configure step to build the
auto-build.h lets me to cross build the native compiler, and the resulting build
seems to work on the target platform.  However I can't find any other
documentation for GENERATOR_FILE, so I'm unsure if that's the right thing to do.
 Richard did introduce the conditional include of gmp.h based on GENERATOR_FILE
back in 2008, and Steven did define this for some object files built for the
host, but not the build in 2012:

2012-07-08  Steven Bosscher  <steven@gcc.gnu.org>

        * Makefile.in (gengtype-lex.o, gengtype-parse.o, gengtype-state.o,
        gengtype.o): Add -DGENERATOR_FILE manually for host gengtype objects.


Is just setting _DGENERATOR_FILE for the auto-build.h build the right thing to
do? If yes, ok for the 4.8 branch and the trunk? I didn't yet figure out why
this works with 4.7.

  Matthias

Comments

Matthias Klose July 15, 2013, 12:39 p.m. UTC | #1
ping

Am 12.06.2013 09:48, schrieb Matthias Klose:
> Trying to cross build a native compiler for arm-linux on x86_64 linux currently
> fails to build, if the libgmp development files are not available for the build
> system. This works with 4.7, but fails with 4.8.
> 
> The build fails with:
> 
> TARGET_CPU_DEFAULT="" \
>         HEADERS="auto-build.h ansidecl.h" DEFINES="" \
>         /bin/bash ../../src/gcc/mkconfig.sh bconfig.h
> g++ -c   -g -O2 -DIN_GCC   -fno-exceptions -fno-rtti
> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual
> -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros
> -Wno-overlength-strings   -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild
> -I../../src/gcc -I../../src/gcc/build -I../../src/gcc/../include
> -I../../src/gcc/../libcpp/include  -I../../src/gcc/../libdecnumber
> -I../../src/gcc/../libdecnumber/dpd -I../libdecnumber
> -I../../src/gcc/../libbacktrace -DCLOOG_INT_GMP    \
>                 -o build/genconstants.o ../../src/gcc/genconstants.c
> In file included from /usr/include/x86_64-linux-gnu/sys/resource.h:25:0,
>                  from ../../src/gcc/system.h:395,
>                  from ../../src/gcc/genconstants.c:28:
> /usr/include/x86_64-linux-gnu/bits/resource.h:131:18: error: declaration does
> not declare anything [-fpermissive]
> In file included from ../../src/gcc/genconstants.c:28:0:
> ../../src/gcc/system.h:444:23: error: declaration of C function 'void*
> sbrk(int)' conflicts with
> 
> 
> Searching the archive and ML this is supposed to work according to
> PR 35051, as described in http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00041.html
> 
> When building the auto-build.h, all the configure tests including the system.h
> header fail to build with
> 
> configure:10361: gcc -c   -I../../../src/gcc -I../../../src/gcc/../include
> conftest.c >&5
> In file included from ../../../src/gcc/system.h:641:0,
>                  from conftest.c:116:
> /usr/include/gmp.h:69:24: fatal error: gmp-x86_64.h: No such file or directory
> compilation terminated.
> 
> And at least all the HAVE_DECL_* defines are set to 0 instead of 1.
> 
> [side note: can we keep the temporary directory for this? it's a bit
>  strange that this directory is removed during the build, and can't
>  be looked at. The build continues after the configure, and then
>  fails later]
> 
> I checked that defining GENERATOR_FILE for this configure step to build the
> auto-build.h lets me to cross build the native compiler, and the resulting build
> seems to work on the target platform.  However I can't find any other
> documentation for GENERATOR_FILE, so I'm unsure if that's the right thing to do.
>  Richard did introduce the conditional include of gmp.h based on GENERATOR_FILE
> back in 2008, and Steven did define this for some object files built for the
> host, but not the build in 2012:
> 
> 2012-07-08  Steven Bosscher  <steven@gcc.gnu.org>
> 
>         * Makefile.in (gengtype-lex.o, gengtype-parse.o, gengtype-state.o,
>         gengtype.o): Add -DGENERATOR_FILE manually for host gengtype objects.
> 
> 
> Is just setting _DGENERATOR_FILE for the auto-build.h build the right thing to
> do? If yes, ok for the 4.8 branch and the trunk? I didn't yet figure out why
> this works with 4.7.
> 
>   Matthias
>
diff mbox

Patch

--- gcc/configure.ac~	2013-06-11 18:34:36.757067080 +0200
+++ gcc/configure.ac	2013-06-11 22:51:47.340892778 +0200
@@ -1519,7 +1519,7 @@ 
 	*) realsrcdir=../${srcdir};;
 	esac
 	saved_CFLAGS="${CFLAGS}"
-	CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
+	CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
 	LDFLAGS="${LDFLAGS_FOR_BUILD}" \
 	${realsrcdir}/configure \
 		--enable-languages=${enable_languages-all} \