Page 1 of 1
GCC Cross-compiler
Posted: Tue Apr 28, 2009 10:19 am
by Tomaka17
Hello,
In page
http://wiki.osdev.org/GCC_Cross-Compiler
You can add a 'Yes' to GCC 4.4.0 with binutils 2.17
I also wanted to ask: when building binutils, gcc and newlib... why not remove the --prefix=$PREFIX things?
If you don't precise any prefix the compiler will automatically be installed in /usr/local, which is already in $PATH
Binaries, include files, etc. won't conflict with each other (if building multiple cross compilers) or with an existing gcc because they are installed in /usr/local/(target)/, /usr/local/bin/(target)-gcc/, /usr/local/lib/gcc/(target)/, etc.
I think it would be much simplier to do so, and I think that's the way it should be normally done
Re: GCC Cross-compiler
Posted: Tue Apr 28, 2009 4:02 pm
by pcmattman
The prefix is useful in certain situations.
In my case, I have cross-compilers which require support libraries & headers (that I provide), and without the PREFIX it'd be difficult to do that.
If you're just looking for a stock cross-compiler, you don't need the prefix (but it is nice, as you can delete the one directory if you want to remove the compiler rather than navigating a tree of folders).
Re: GCC Cross-compiler
Posted: Wed Apr 29, 2009 5:32 am
by Solar
I admit that, originally, I was afraid to go with the default, as it was very poorly documented just what that default would be - I was unwilling to jeopardize my installation.
And after that, I left the --prefix in the tutorial, because it gives a hint what could be done if you aren't root on the machine, is explicit (I always prefer explicitness over implicit functionality), and is easy to delete-and-redo.
Re: GCC Cross-compiler
Posted: Wed Apr 29, 2009 6:17 am
by AJ
Oooh - I missed the release of 4.4! [rebuilds cross compiler]
And another "vote" here for leaving --prefix in for the ease of deletion and rebuilding.
Cheers,
Adam
Re: GCC Cross-compiler
Posted: Wed Apr 29, 2009 8:42 am
by Tomaka17
I understand the "ease of deletion" argument (thought I don't know why you would delete it
)
But like Solar the first time I wanted to create a cross-compiler I thought that without that --prefix argument my newly-compiled GCC would overwrite the one already installed
That seems ridiculous but I was so afraid of this that I was checking several times if I had spelled '--prefix' correctly
Why not a single paragraph saying "The --prefix parameter is optional but we recommand using it" ?
Re: GCC Cross-compiler
Posted: Tue May 05, 2009 6:15 am
by Combuster
I don't know why you would delete it
To replace it with a newer version? Update cygwin?
Re: GCC Cross-compiler
Posted: Tue May 05, 2009 10:25 am
by Firestryke31
Or if you realize you misconfigured it.
"D'oh! I forgot to add that one flag that does the thing to the stuff so I can do this to that! Well, there goes 7 hours of work."
Re: GCC Cross-compiler
Posted: Tue May 05, 2009 6:04 pm
by kubeos
I was wondering why no one has posted a tutorial yet for a native build of gcc and binutils.. It's remarkably easy as
long as you have a good libgloss with your newlib. I think I had to add about 15 new functions to my libgloss to get a
native compiler. And the configure command is pretty straight forward too -> I had to do a bit of research on the net to find out --host was not the computer you were building everything on.
Hope the info below helps someone. I had problems with the gcc that came default with cygwin, so I built a new version for it before I did a native build for my OS.
$BUILD refers to the machine you are currently compiling on.
For binutils:
../binutils-x-x-x/configure --prefix=$PREFIX --target=$TARGET --host=$TARGET --build=$BUILD --disable-nls
For gcc:
../gcc-x-x-x/configure --prefix=$PREFIX --target=$TARGET --host=$TARGET --build=$BUILD --disable-nls --enable-languages=c
While building, binutils and gcc would error out with undefined references. I just added these to my libgloss till it finally finished and installed. Voila, native toolchain
Pretty straight forward, but I'm not volunteering to make a tutorial. Maybe someone could fix this up(and any mistakes) and post it on the wiki. But hopefully this post will help someone out who doesn't know what to do about a native toolchain.
Re: GCC Cross-compiler
Posted: Wed May 06, 2009 1:35 am
by Solar
kubeos wrote:I was wondering why no one has posted a tutorial yet for a native build of gcc and binutils.. It's remarkably easy as long as you have a good libgloss with your newlib.
Well yes... if you go for Newlib.
Porting Newlib would be the Step 2 mentioned in the
GCC Cross-Compiler tutorial. Then would come Step 3 (complete cross-compiler),
then would come Step 4 (native build).
Adding a C library is a point at which the tutorial "forks". Newlib is probably the "easiest" way to go currently, but some might not agree with Newlib because of its licensing, or its OS interface, or its scope, or whatever, and might want to use a different C library...