I’ve just configured an enviroment for developing an x86 kernel on MacosX. My enviroment is quite simple at the moment, just a cross compiler and an x86 emulator, in the case Bochs. In this post I’ll cover the process of configuring and building the cross compiler.
As the compiler I’ll be using Gcc, which will be used to target x86 architecture i686, I compile gcc as bootstrap only, as I don’t need to be able to compile any glibc source, kernels are not linked against glibc.
Requirements:
Binutils and gcc are needed, these are the versions I use:
binutils-2.15.92.0.2
gcc-3.4.3
Compiling
First of all I create the directory structure for the cross compiler. I put all the stuff in /home/crossdev/ .
I create /home/crossdev/src/ where I uncompress binutils and gcc. /home/crossdev/i686/ will hold all the binaries.
Untar binutils in /home/crossdev/src/, and enter the new binutils source directory. Create a build-i686 directory and execute the following script:
echo “Configure Binutils for i686 from MacosX”
CROSS_CHOST=”i686-pc-linux-gnu”
MY_CHOST=”powerpc-unknown-linux-gnu”
MY_CFLAGS=”-mcpu=powerpc -mtune=powerpc”
CROSS_INSTALL=”/home/crossdev/i686/”
CFLAGS=”$MY_CFLAGS”
../configure \
–target=$CROSS_CHOST \
–host=$MY_CHOST \
–prefix=$CROSS_INSTALL \
–enable-shared \
–enable-64-bit-bfd \
echo “Compile Binutils”
make
echo “Install”
make install
Now do the same with gcc but execute the following script:
echo “Configure GCC for i686 from MacosX”
CROSS_CHOST=”i686-pc-linux-gnu”
MY_CHOST=”powerpc-unknown-linux-gnu”
MY_CFLAGS=”-mcpu=powerpc -mtune=powerpc”
CROSS_INSTALL=”/home/crossdev/i686/”
export PATH=”$PATH:/home/crossdev/i686/bin/”
CFLAGS=”$MY_CFLAGS”
../configure \
–prefix=$CROSS_INSTALL \
–host=$MY_CHOST \
–target=$CROSS_CHOST \
–with-newlib \
–disable-shared \
–disable-threads \
–enable-languages=”c” \
–disable-multilib \
–disable-nls \
–enable-symvers=gnu \
–enable-__cxa_atexit \
–with-headers=/home/crossdev/i686/include \
–enable-static
echo “Compile Gcc”
make
echo “Install”
make install
Now we have a kernel cross compiler, we can compile x86-i686 kernel on MacosX. If we add /home/crossdev/i686/bin to our path, it will be easier to use it as to cross compile we just need to call i686-pc-linux-gnu-*** where *** is gcc, ld or any other of the usual gnu tools.
you should try
http://billgatliff.com/~bgat/twiki/bin/view/Crossgcc/CrossTool
for building a toolchain
i tried your scripts but i had several problems with them
i cant copy and paste them because they’re in a funny encoding so i had to type them up
i tried running your gcc.sh on my osx 10.3 but it fails to find include files
i am guessing something is fishy about copying includes/using –with-headers
i wasn’t able to fix it
i tried to reproduce your bash scripts but had several problems
first, copying and pasting into a text file didn’t work because it seems like the website has a funny encoding
i had to type up the scripts to execute them
second, the gcc script complained about not finding headers
currently i am using the crosstool ( http://billgatliff.com/~bgat/twiki/bin/view/Crossgcc/WebHome )
after slight adjustments (A patch to the linux kernel makefile) it started working like a charm
i couldnt find your email on this blog
i would like to get in touch with you thoug in order to explore the subject of building an x86 os on an osx platform
does this comment thing even work?
The comments are under moderation, I received quite a lot of Spam and I have not had time to install any protection.
It would be cool to get in touch by E-mail, I’ll just send you one now.
Is Blogengine acquiring an enormous improve shortly? I listen to that they had been doing so to fight off wordpress 3.0 – just curious if you happen had hearken to something at all?