Page 1 of 1

i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Sun Jul 20, 2003 1:42 am
by Solar
This is driving me nuts.

For four days (!) now, I've been trying to build a gcc 3 cross-compiler toolchain that would allow me to build ELF binaries under Cygwin.

I'm asking, has anybody of the people here done this already, or knows someone who has?

Please don't point me to the countless tutorials and mailing lists explaining how to build cross-compilers in general, I feel like I've seen them all. Has someon eactually built a Cygwin-to-ELF gcc >= 3.2 cross-compiler?

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Sun Jul 20, 2003 3:06 am
by df
first, its not a cross compiler.
all you need to do is rebuild binutils from source

search this forum fsor cygwin + elf.

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Mon Jul 21, 2003 1:10 am
by Solar
df wrote: search this forum fsor cygwin + elf.
That's good advice but gives me three posts: Yours above, and two of my own... :-/

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Mon Jul 21, 2003 11:32 am
by df

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Tue Jul 22, 2003 12:38 am
by Solar
Thanks, I'll give it a try.

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Thu Jul 24, 2003 1:17 am
by Solar
http://www.pro-pos.org/index.php/HowToCrossCompile.

Tested to work with gcc-3.2.3 and gcc-3.3 (both binutils-2.14).

Thanks for the help!

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Thu Jul 24, 2003 11:10 am
by df
i'm running 3.2.3 and didnt have to do those patches you wrote of.. very strange...

secondly, its not a cross compiler, its just rebuilding binutils.

crosscompiling is when your on say x86 and you have compiled gcc to output PPC or ALPHA etc.

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Thu Jul 24, 2003 11:56 am
by DevL
df wrote: crosscompiling is when your on say x86 and you have compiled gcc to output PPC or ALPHA etc.
Not quite. Crosscompiling is the fine art of compiling for another platform than the host platform. I.e. you can (theoretically) crosscompile a Linux x86 app on a Windows (x86) machine.

From http://www-public.tu-bs.de:8080/~y00185 ... node5.html

Cross compiling is the procedure for building a program for a platform different from the one on which the cross compiler runs. "Platform" does not only mean the hardware architecture but also software platforms, e.g. the process for building the GNU/Hurd operating system from sources on a running Linux for the same hardware architecture is also a (sic!) cross compiling.

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Thu Jul 24, 2003 12:33 pm
by Solar
df wrote: i'm running 3.2.3 and didnt have to do those patches you wrote of.. very strange...

secondly, its not a cross compiler, its just rebuilding binutils.
Of course, if you aren't building more than binutils, you don't have to patch gcc sources... ;-)
crosscompiling is when your on say x86 and you have compiled gcc to output PPC or ALPHA etc.
Crosscompile is when --host (i686-pc-cygwin) != --target (i586-pc-elf).

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Thu Jul 24, 2003 1:00 pm
by bkilgore
This isn't really a cross-compile is it? More of a "cross-link"? Because all you're doing is linking existing object code into a different form of executable. You're not compiling for a different target machine, i.e. with new headers, not machine code, etc. Just linking a little differently into an elf instead of a pe...

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Thu Jul 24, 2003 2:27 pm
by DevL
bkilgore wrote: This isn't really a cross-compile is it? More of a "cross-link"? Because all you're doing is linking existing object code into a different form of executable. You're not compiling for a different target machine, i.e. with new headers, not machine code, etc. Just linking a little differently into an elf instead of a pe...
Let me reiterate.

Crosscompiling = compiling a source X on a different platform Y than the intended target platform Z.

A platform is not the same thing as the target CPU. Examples of platforms follows below.

1. Windows on x86
2. Linux on x86
3. Linux on PPC
4. NetBSD on MIPS
5. FreeBSD on x86

Do note that x86 is listed three times and Linux twice. I'll even throw in a sixth platform to get the ball rolling around here; Java.

Now, you might argue that Solar's compiler isn't a cross-compiler since it is hosted on Windows/x86 and targets...just x86 since there's no OS in place yet, but I wouldn't as I'd consider plain, vanilla x86 with or without a BIOS a platform.

As always, it all boils down to a few definitions.

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Thu Jul 24, 2003 2:40 pm
by bkilgore
DevL wrote: Let me reiterate.

Crosscompiling = compiling a source X on a different platform Y than the intended target platform Z.
You made my point exactly...you said it's compiling for a different platform. My point is that changing the target of a link does not in any way influence the compilation of machine code.

Now, if you were going to build an ELF that would actually run on linux, instead of a PE that would run on windows, this would definitely be a cross-compile, even if they're both x86, because this would involve a different compilation, with different header files, different code, etc.

But to link the same object code into a different executable format is not cross-compiling.

Since there really is no intended target "platform" (as we're builing our own platform), you can't say linking to an elf in this case is compiling it for linux any more than linking it to pe was compiling it to run on windows. Either way the "target platform" is our own operating system. And since neither the target platform, nor the target machine architecture, is different, you can't consider it a cross-compile even under those definitions.

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Fri Jul 25, 2003 12:48 am
by Solar
The problem is that I'm working with C++. And if I compile C++ with a compiler that targets PE, I get different output than with a compiler that targets ELF.

(Hint: Exception handling, templates, all the juicy stuff.)

Of course I could fix the linker scripts to correctly turn PE object files into ELF binaries... I think.

But those linker scripts would no longer be compatible to someone trying to compile the same stuff under Linux... unless that dude first builds a compiler targeting PE, and *that* would be sick, wouldn't it?

/usr/bin/g++ produces different code than /usr/cross/bin/g++, and in my book, that's a cross-compiler.

But does it make sense picking on words? It works. :D

Re:i686-pc-cygwin to i386-pc-elf cross-compiler...

Posted: Fri Jul 25, 2003 10:02 am
by DevL
Solar wrote: But does it make sense picking on words? It works. :D
And that's all that counts. Guess it's mw having a thing for semantics. ;)

@bkilgore

Interesting and valid points. We're not 100% in agreement, but I do see your point.