cross gcc

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.
GernotFrisch

cross gcc

Post by GernotFrisch »

Hello,

I've download cygwin and all the sources required and created ?? a cross compiler by doing what is said here:
http://www.osdev.org/osfaq2/index.php/GCC%20Cross-Compiler
Now, I've got a /usr/src/build-gcc dir with:
/gcc
Here I have a lot of .exe files that look like a gcc version for windows, but they all require cygwin1.dll.

/i586-elf
This is empty?

My main aim is to make a native win32 gcc that produces linux files. Can anyone pleas help me?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:cross gcc

Post by Pype.Clicker »

cygwin program require to be started through the cygwin shell, iirc ...

btw, can you locate some "ld.exe" ? and what does "ld --help" report as "supported targets" ?
GernotFrisch

Re:cross gcc

Post by GernotFrisch »

ld --help:
...
ld: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec symbolsrec tekhex binary ihex
ld: supported emulations: i386pe
ld: emulation specific options:
i386pe:
...

Is that good? Why do I need to start it from cygwin? Can't I remove the dependencies?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:cross gcc

Post by Solar »

Now, I've got a /usr/src/build-gcc dir with...
If you really followed the FAQ document (i.e., ran 'make install'), the executables and binaries should be in /usr/cross. At this point, you could delete /usr/src/build-*.
Why do I need to start it from cygwin?
You don't have to start it from Cygwin (or rather, the bash shell provided by Cygwin), but you need the Cygwin.dll in your system because the build process linked against it.

There is an option in Cygwin's GCC somewhere ("--no-cygwin"?) which allows linking against the Microsoft runtime instead, which in fact does create native Windows applications that no longer require the Cygwin.dll.

That's of interest for people who do not want to place whatever they compiled under terms of the GPL (since the Cygwin.dll is GPL, and thus everything that links to it) - but your cross-GCC is GPL, anyway.

The other interest is if you'd like to distribute binaries to people who don't have the Cygwin.dll... but then, you could just wrap up the Cygwin.dll alongside your GCC binaries. It's redistributable, you know?
Can't I remove the dependencies?
Not postscriptum, no. But you could try to build a GCC that is linked against the Windows runtime. I haven't tried that, though, and thus can't help you. I'd be interested in the results, though.
Every good solution is obvious once you've found it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:cross gcc

Post by Solar »

GernotFrisch wrote: ld --help:
You just tested your system ld. (The one that came with Cygwin.) You'd have to run /usr/src/build-gcc/gcc/.../ld.exe...
Every good solution is obvious once you've found it.
GernotFrisch

Re:cross gcc

Post by GernotFrisch »

My /usr/cross is quite empty:
\usr\cross\i586-elf
\usr\cross\lib
\usr\cross\i586-elf\sys-include
\usr\cross\i586-elf\sys-include\config.temp
\usr\cross\i586-elf\sys-include\COPIED
\usr\cross\i586-elf\sys-include\i586-elf
\usr\cross\lib\gcc-lib
\usr\cross\lib\gcc-lib\i586-elf
\usr\cross\lib\gcc-lib\i586-elf\3.3.1

(\ is /, I used the dos-dir to list it)

I don't have a ln.exe in my /usr/src/build-gcc/gcc directory. So, somehting must have gone wrong, huh? I think I will run the whole process in a bash file and put the output in a file. Maybe it's better for you to see the error then?
Thanks a very lot for at least talking to me about this topic. This is my 3rd attempt to do this. This time I have the feeling of beeing --><-- that close to it...
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:cross gcc

Post by Solar »

GernotFrisch wrote: My /usr/cross is quite empty...
Goofed up somewhere, most likely your 'make all-gcc install-gcc' failed while halfway through the installation part.
I think I will run the whole process in a bash file and put the output in a file. Maybe it's better for you to see the error then?
Sounds like a plan. But since I know GCC make generates a lot of output, feel free to mail it to [email protected] (my mail address), instead of putting it on the forum.
Thanks a very lot for at least talking to me about this topic.
Hey! I wrote the page, so I should be worrying if it doesn't help people, right? ;-)
Every good solution is obvious once you've found it.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:cross gcc

Post by Candy »

Since I was responsible for the amd64 part (the cross part) you could mail me a bz2 or gz of the output too.

Just wondering, did you make & install a 64-bit binutils already? GCC doesn't do much without it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:cross gcc

Post by Solar »

Candy, unless I'm mistaken, and judging from him having a directory "i586-elf", he's going for the generic part of the how-to only... 8)
Every good solution is obvious once you've found it.
GernotFrisch

Re:cross gcc

Post by GernotFrisch »

err... Doh, I hate questions I don't even understand. Well, what I want is:
Make a gcc compiler chain (that is from .cpp to executable program, I hope) that runs on win32 and outputs a linux binary for the 2.4 kernel, 32 bit.
Does that anser the question?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:cross gcc

Post by Solar »

In that case, our Wiki is the wrong place, I'm afraid, as it stops well short from actually building a full cross-compiler. A full cross-compiler has standard C library headers, and spits out ready-to-run executables; building such a thing takes multiple stages, including getting the target runtime (which basically requires having a functional Linux box at hand).

The cross-compiler mentioned in our Wiki only completes the first stage, which is enough to build kernel binaries, but does not suffice for executables.

Sorry, I overlooked the Linux part - or took it for a typo, as many people think that ELF <=> Linux files.

A quick search-of-the-web gave me http://www.xraylith.wisc.edu/~khan/soft ... -howto.txt - perhaps that will help you.
Every good solution is obvious once you've found it.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:cross gcc

Post by Candy »

GernotFrisch wrote: err... Doh, I hate questions I don't even understand. Well, what I want is:
Make a gcc compiler chain (that is from .cpp to executable program, I hope) that runs on win32 and outputs a linux binary for the 2.4 kernel, 32 bit.
Does that anser the question?
*retreats back into his cave... different type of cross*
GernotFrisch

Re:cross gcc

Post by GernotFrisch »

Oh. I thought it would be enough to have the binaries and use the actual header files/libraries from my linux distri?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:cross gcc

Post by Solar »

You need the headers (so the compiler knows what functions are available in the runtime), and some of the runtime files (like, startup / shutdown code - the stuff executed before int main() is actually called, and the cleanup stuff called after main() exits).

That's what that other page I linked above tells you how to do.

Our Wiki tells you how to set up a "naked" cross-compiler, one that doesn't have any "runtime" yet because we - as OS developers - have to build that ourselves.
Every good solution is obvious once you've found it.
GernotFrisch

Re:cross gcc

Post by GernotFrisch »

again - the compiler you create can compile:
int main(int, char**)
{
long n=130275;
return n;
}

Can it?
If so, I (hope I) only have to copy my .h and .a files from my running Linux distri into the compiler's include/lib directories and can use it to compile anything just as if it were running on a linux box, no? Does the compiler need to know the .a and .h files when it is about to be created? If so, why?
The link you gave me looks very promising. I will follow it although it means a few sleeples nights, I guess. :)
Post Reply