GCC to my OS
GCC to my OS
Hi!
I just decided to build a native compiler to my OS.
I run through the Wiki article (http://www.osdev.org/wiki/GCC_Cross-Compiler) but it didn't answer all of my questions, so i'm going to ask the rest here.
The first two steps are clear for me and well detailed. The confusing part for me just starts at Step #3.
As i see Step 3 don't explain what files should i write, where should i place them to complete this Step. Could you describe it a bit more?
In Step 4 something i don't understand: when i compile the native GCC i'll specify my own C library headers with --with-headers=/my/C/header/dir. That's okey. But where do i specify that which C library i want to link the native GCC with? As i have my own C library headers i also have my own C library that relies on my own kernel's calls.
Thanks for the help!
c0x
I just decided to build a native compiler to my OS.
I run through the Wiki article (http://www.osdev.org/wiki/GCC_Cross-Compiler) but it didn't answer all of my questions, so i'm going to ask the rest here.
The first two steps are clear for me and well detailed. The confusing part for me just starts at Step #3.
As i see Step 3 don't explain what files should i write, where should i place them to complete this Step. Could you describe it a bit more?
In Step 4 something i don't understand: when i compile the native GCC i'll specify my own C library headers with --with-headers=/my/C/header/dir. That's okey. But where do i specify that which C library i want to link the native GCC with? As i have my own C library headers i also have my own C library that relies on my own kernel's calls.
Thanks for the help!
c0x
- Combuster
- 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:
There's OS_Specific_Toolchain that should get you further.
OS Specific Toolchain will help you make a toolchain (including c library) that targets your os but is hosted on another (e.g. cygwin/linux). You do not have to specify which c library to use when compiling with this gcc. Any application (including gcc) that you compile with it will use your os's c library by default. Therefore, once you have run through the tutorial you should have a gcc which you can use to compile a native gcc that will oth run on and target your os (of course you will also need to compile some dependencies that gcc requires).
Regards,
John.
Regards,
John.
Sorry for the long delay, unfortunately i didn't have time to work on this 'project'.
Thanks for your reply, jnc100.
There's a little difference between the OS specific toolchain wiki article and my situation. That tutorial assumes that i'm using newlib as a C library to build the native GCC and i have my own C library.
Don't know if i'm right or not, but i think buildin and installing newlib as the mentioned tutorial says will install header files and the compiled library somewhere to the native source tree so GCC can use that to build the native toolchain. Because i've my own C library i should do the same, but i don't know where to place the headers and the compiled library. I tried to build newlib without modifications on a linux system, but unfortunately it failed
c0x
Thanks for your reply, jnc100.
There's a little difference between the OS specific toolchain wiki article and my situation. That tutorial assumes that i'm using newlib as a C library to build the native GCC and i have my own C library.
Don't know if i'm right or not, but i think buildin and installing newlib as the mentioned tutorial says will install header files and the compiled library somewhere to the native source tree so GCC can use that to build the native toolchain. Because i've my own C library i should do the same, but i don't know where to place the headers and the compiled library. I tried to build newlib without modifications on a linux system, but unfortunately it failed
c0x
Thanks for the information, jnc100.
Sorry for not responding for a long time, but i was away for bug hunting and i didn't have time to work on this process
Now i have a cross compiler that can produce executables and these executables run on my OS.
I created a crt0.o and now the following command works: i586-pc-myOS-gcc -O2 -Wall test.c -o test
After this i tried to compile binutils to run on my OS. The configure parameters i used were the following: --host=i586-pc-myOS --target=i586-pc-myOS --prefix=... --disable-nls.
Configure went fine, i got no errors. Then i typed 'make' and it went smootly without errors too but as i saw it used 'gcc' instead of 'i586-pc-myOS-gcc' to create binutils executables.
What did i wrong? Why did it use my "linux gcc" instead of the cross compiler GCC to my OS?
c0x
Sorry for not responding for a long time, but i was away for bug hunting and i didn't have time to work on this process
Now i have a cross compiler that can produce executables and these executables run on my OS.
I created a crt0.o and now the following command works: i586-pc-myOS-gcc -O2 -Wall test.c -o test
After this i tried to compile binutils to run on my OS. The configure parameters i used were the following: --host=i586-pc-myOS --target=i586-pc-myOS --prefix=... --disable-nls.
Configure went fine, i got no errors. Then i typed 'make' and it went smootly without errors too but as i saw it used 'gcc' instead of 'i586-pc-myOS-gcc' to create binutils executables.
What did i wrong? Why did it use my "linux gcc" instead of the cross compiler GCC to my OS?
c0x
For all the executables? A lot of build scripts will use the native compiler to create certain tools which are then used to create the final output (e.g. I would expect the binutils compile in this case to use your linux gcc to compile libtool).c0X wrote:it used 'gcc' instead of 'i586-pc-myOS-gcc' to create binutils executables.
If indeed it did use the linux gcc to compile things like as and ld then I'm afraid I can't help you much more. I would expect it to do the right thing given the configure options you're providing, but then I have never got that far myself as to compile a binutils that would run on my os and doubt I ever will because I'm currently following a very different line in my os design.
Please let us know and update the wiki if you do manage to succeed. Sorry again that I can't be much help.
Regards,
John.
This is from the help part of binutils' configure script:pcmattman wrote:You forgot to specify --build
Code: Select all
--build=BUILD configure for building on BUILD [BUILD=HOST]
I'm going to try adding --build as well and hope it'll work
c0x