Fails to build i386-pe cross compiler

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Fails to build i386-pe cross compiler

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Fails to build i386-pe cross compiler

Post by Combuster »

did you supply "--without-headers" to configure?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Fails to build i386-pe cross compiler

Post 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?
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Fails to build i386-pe cross compiler

Post 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?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Fails to build i386-pe cross compiler

Post 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.
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Fails to build i386-pe cross compiler

Post by qw »

It must be something target-specific because i586-elf was built flawlessly.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Fails to build i386-pe cross compiler

Post 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.
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Fails to build i386-pe cross compiler

Post 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.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Fails to build i386-pe cross compiler

Post by Owen »

Build a native Windows hosted cross compiler (or an Interix hosted one), rather than a Cygwin hosted one, perhaps?
Post Reply