The OSFAQ for this topic is confusing.
How do we use Cygwin to build a cross compiler for x64 systems on a 32-bit Cygwin system, and on a 64-bit Linux system?
There's a patch that needs to be applied to GCC 4.1.1, but it doesn't explain how to apply it. Binutils 2.17 doesn't need the patch apparently. What's this about preparation, with the note that there's more coming? So we should wait before attempting to build a clean x86_64-pc-elf cross compiler? ??? ???
And what of newlib? Why is this necessary? Is it only for running the compiler on the host system?
I've downloaded gcc-4.1.1 and binutils-2.17. Now I need to unpack and run configure within the build directories, and apply the patch to gcc-4.1.1 to get the target=x86_64-pc-elf:
mkdir /usr/cross
export PREFIX=/usr/cross
export TARGET=x86_64-pc-elf
cd /usr/src
mkdir build-binutils build-gcc
And for binutils:
cd /usr/src/build-binutils
../binutils-x.xx/configure --target=$TARGET --prefix=$PREFIX --enable-64-bit-bfd
make all install
And for GCC with the x86_64-pc-elf patches:
cd /usr/src/build-gcc
export PATH=$PATH:$PREFIX/bin
../gcc-x.x.x/configure --target=$TARGET --prefix=$PREFIX \
--disable-nls --enable-languages=c,c++ --with-newlib --without-headers
make all-gcc install-gcc
Is that all that's necessary? Is the bootstrap process necessary? And now how to use the new toolchain, just make sure that /usr/cross is in the $PATH first, so:
PATH=/usr/cross:$PATH
Like that?
Thanks for your help...
How to build a GCC and binutils for x64-pc-elf?
Re:How to build a GCC and binutils for x64-pc-elf?
Using 'patch', or doing it manually... I just gave you a quick rundown on how to read the patch format via PM as you requested.kernel64 wrote: There's a patch that needs to be applied to GCC 4.1.1, but it doesn't explain how to apply it.
"Preparation" is a chapter header. Preparation - binutils - gcc, the three steps you take to get your cross-compiler.about preparation, with the note that there's more coming? So we should wait before attempting to build a clean x86_64-pc-elf cross compiler? ??? ???
--with-newlib is a workaround for a bug in GCC <= 3.3.x, as explained in the general (32bit) tutorial. I'm not sure why Candy used it for the 64bit tutorial, so I didn't touch it.And what of newlib? Why is this necessary?
Apply the patches before you run configure.I've downloaded gcc-4.1.1 and binutils-2.17. Now I need to unpack and run configure within the build directories, and apply the patch to gcc-4.1.1 to get the target=x86_64-pc-elf...
Yep.Is that all that's necessary?
Not sure what you mean with "bootstrap". Bootstrapping a compiler usually means compiling it to run on the target system the first time - you'll need a functional C library first.Is the bootstrap process necessary?
Check the "Usage" section of the tutorial. (The x86_64 part is an extension to the 32bit part, make sure you've read the whole tutorial so you understand what's going on.)And now how to use the new toolchain...
Every good solution is obvious once you've found it.
Re:How to build a GCC and binutils for x64-pc-elf?
Thanks Solar.
So here's the summary for the process of getting a clean x64 toolchain (assuming gcc 4.1.1 and binutils 2.17):
Unpack. Apply patch to gcc. (It changes a filename it seems... is that a problem? i.e. gcc/clean to dirty or somesuch)
configure binutils
make binutils and install
configure gcc
make gcc and install
Any gotchas? ;D
So here's the summary for the process of getting a clean x64 toolchain (assuming gcc 4.1.1 and binutils 2.17):
Unpack. Apply patch to gcc. (It changes a filename it seems... is that a problem? i.e. gcc/clean to dirty or somesuch)
configure binutils
make binutils and install
configure gcc
make gcc and install
Any gotchas? ;D
Re:How to build a GCC and binutils for x64-pc-elf?
Nononono... understand how a patchfile is created: You take the release code, hack around in it until it works, then you run a 'diff' between the release ("clean") code and your hacked ("dirty") version. The diff header lists which two files were compared, hence the path. The file actually changed is gcc/config.gcc, no "clean" or "dirty".kernel64 wrote: Unpack. Apply patch to gcc. (It changes a filename it seems... is that a problem? i.e. gcc/clean to dirty or somesuch)
Looks good to me. Remember to extend the path after you installed binutils, so the GCC make will find them.Any gotchas? ;D
Every good solution is obvious once you've found it.
Re:How to build a GCC and binutils for x64-pc-elf?
Got it! Thanks Solar.
Just did the cross and everything compiled without a hitch. Couple of warnings but incomprehensible to me and probably nothing that I'll need to worry about.
Strangely enough there is a crtbegin and crtend. Don't know what they're for, but presumably I don't use them by specifying -nostdlib and -nostdinc, as well as -fstandalone.
Cheers! ;D
Just did the cross and everything compiled without a hitch. Couple of warnings but incomprehensible to me and probably nothing that I'll need to worry about.
Strangely enough there is a crtbegin and crtend. Don't know what they're for, but presumably I don't use them by specifying -nostdlib and -nostdinc, as well as -fstandalone.
Cheers! ;D
Re:How to build a GCC and binutils for x64-pc-elf?
Ok, I guess I should rewrite that tomorrow when I'm clear in my head.kernel64 wrote: The OSFAQ for this topic is confusing.
How do we use Cygwin to build a cross compiler for x64 systems on a 32-bit Cygwin system, and on a 64-bit Linux system?
There's a patch that needs to be applied to GCC 4.1.1, but it doesn't explain how to apply it. Binutils 2.17 doesn't need the patch apparently. What's this about preparation, with the note that there's more coming? So we should wait before attempting to build a clean x86_64-pc-elf cross compiler?
And what of newlib? Why is this necessary? Is it only for running the compiler on the host system?
Newlib is pointless on 3.4.* and newer. That was the 3.3.* fix that it would fail not using includes.
The patches are really all there is to fixing it. The "more coming" in that mail (on the gcc mailing list) was about the binutils patch, but the binutils guys integrated it sooner so the new binutils doesn't need the patch (sent out later) separately anymore. The newest gcc doesn't have the patch so it still needs it.
The crosscompiler segment isn't that hard to understand actually. You create a binutils, then a gcc, and you configure them with the target you wish to target. When that target is cleanly supported, they're 100% equal in whether or not you're making a real cross compiler. The explanation is mainly because of the patches that weren't around when I tried to make a cross compiler, to know how you could still make a working compiler for that target.