Page 1 of 1

Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 3:44 am
by qw
Hi everybody,

I was building a cross compiler as described in the wiki. I downloaded the sources for gcc 4.2.4 and binutils 2.19 and then succesfully built it with TARGET=i586-elf.

Then I tried to build it again, this time with TARGET=i386-pe. Binutils were created just fine, but running "make all-gcc" failed because it could not find <stdio.h>:

Code: Select all

/usr/src/build-gcc/./gcc/xgcc -B/usr/src/build-gcc/./gcc/ -B/usr/local/cross/i386-pe/bin/ -B/usr/local/cross/i386-pe/lib/ -isystem /usr/local/cross/i386-pe/include -isystem /usr/local/cross/i386-pe/sys-include -O2 -I../../gcc-4.2.4/gcc/../winsup/w32api/include -O2 -g -O2  -DIN_GCC -DCROSS_COMPILE   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -g  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I. -I. -I../../gcc-4.2.4/gcc -I../../gcc-4.2.4/gcc/. -I../../gcc-4.2.4/gcc/../include -I../../gcc-4.2.4/gcc/../libcpp/include  -I../../gcc-4.2.4/gcc/../libdecnumber -I../libdecnumber -DL_muldi3 -c ../../gcc-4.2.4/gcc/libgcc2.c -o libgcc/./_muldi3.o
In file included from ./tm.h:10,
                 from ../../gcc-4.2.4/gcc/libgcc2.c:35:
../../gcc-4.2.4/gcc/config/i386/cygming.h:51:19: error: stdio.h: No such file or
 directory
My host compiler is: gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

Looking for a solution I only found this post that is quite mingw-specific. I know next to nothing about building gcc. Could someone point me to the right direction please?

Re: Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 3:52 am
by Combuster
did you supply "--without-headers" to configure?

Re: Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 4:01 am
by Solar
Any particular reason why you need both the "elf" and the "pe" target? (I admit I never tested the tutorial for non-ELF targets.)

Any particular reason why you're using gcc-3 instead of the standard GCC v4?

Re: Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 4:18 am
by qw
Combuster wrote:did you supply "--without-headers" to configure?
Yes I did. I did it exactly as in the wiki, except that I changed the target.
Solar wrote:Any particular reason why you need both the "elf" and the "pe" target? (I admit I never tested the tutorial for non-ELF targets.)
I intend to use ELF for my hobby OS and PE for another project involving the WDOSX DOS extender.
Solar wrote:Any particular reason why you're using gcc-3 instead of the standard GCC v4?
My computer is quite old (from 2003) and I didn't want to download that much. 4.2.4 is the highest version that does not need the additional packages GMP, MPFR and MPC.

EDIT: Oh wait, I got that question wrong. GCC 3 comes standard with Cygwin, should I try GCC 4?

Re: Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 5:31 am
by Solar
I don't really think it will make a difference, I was just trying to be clear about the requirements.

No idea about the PE support, whether it should work or anything. I am currently tied down at work, and pretty much shot when I get home, so I can't have a look at this anytime soon.

Re: Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 6:04 am
by qw
It must be something target-specific because i586-elf was built flawlessly.

Re: Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 6:14 am
by Solar
My guess is that the PE support drags in a dependency which in turn "requires" stdio.h.

My approach would be to redirect the output of the ELF build and that of the PE build to seperate logfiles, and by comparing them trying to figure out what went different in the PE build.

Then trying to figure out if it's a "real" dependency, or if the autoconfig / automake / configure files could be hack-patched to avoid the dependency.

Re: Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 6:56 am
by qw
Looking more closely, I don't think <stdio.h> is a real dependency. The error happens when creating "_muldi3.o" from "libgcc2.c" which includes "tm.h" which includes "config/i386/cygming.h" which includes <stdio.h>. I don't know how to fix this without breaking a dozen other dependencies.

Re: Fails to build i386-pe cross compiler

Posted: Tue Nov 16, 2010 8:28 am
by Owen
Build a native Windows hosted cross compiler (or an Interix hosted one), rather than a Cygwin hosted one, perhaps?