Skip to content →

i386-jos-elf toolchain on OS X Lion

Yesterday friend and I decided to follow the MIT Operating System Engineering course together in order to get a deep understanding of OS’s. And today I started setting up the cross compling environment for the labs. At first I wanted to get the toolchain from macports, but unluckily it didn’t successfully build binutils on my Mac. As a result, I started building the toolchain from the source code, following the instructions at http://pdos.csail.mit.edu/6.828/2011/tools.html.

The programs you need for the toolchain include binutils, gcc, and gdb. For compiling gcc you also need GMP, MPFR, and MPC. The source codes are available at:

Unzip them in a directory and build binutils, gcc, and gdb one by one.

In order to build gcc, GMP, MPFR and MPC needs to be built first.

Note that it’s essential to build gcc in a directory different from the source code directory to avoid compiling errors.

Then make gdb:

QEMU is available in macports:

Published in OS

15 Comments

  1. Anonymous

    Thanks for your post. really helped me a lot!

  2. Anonymous

    Thanks for your post. really helped me a lot!

  3. Thank you! It worked like a charm! Now debugging with qemu and DDD. 🙂

  4. Thank you! It worked like a charm! Now debugging with qemu and DDD. 🙂

  5. Bianca

    Maybe it’s a problem with kernel compilation without parameter – g, but I don’t know how to solve it.

  6. Bianca

    Maybe it’s a problem with kernel compilation without parameter – g, but I don’t know how to solve it.

  7. Bianca

    Hi! Thank you for the reply. Now it’s working, but I still am having some problems with symbol table, this is the error message I received when I launch gdb:
    “+ symbol-file obj/kern/kernel
    .gdbinit:30: Error in sourced command file:
    “/Users/username/jos/lab/obj/kern/kernel”: can’t read symbols: File format not recognized.”

    Could you maybe help me?

    Thanks a lot!

    • Hi Bianca, I’m not sure what causes the problem, so I’m afraid I’m not able to help, sorry…

  8. Bianca

    Hi! Thank you for the reply. Now it’s working, but I still am having some problems with symbol table, this is the error message I received when I launch gdb:
    “+ symbol-file obj/kern/kernel
    .gdbinit:30: Error in sourced command file:
    “/Users/username/jos/lab/obj/kern/kernel”: can’t read symbols: File format not recognized.”

    Could you maybe help me?

    Thanks a lot!

  9. Hi, sorry for my late reply. I think i386-elf-gcc is available on macports, maybe you can try sudo port install i386-elf-gcc?

  10. Hi, sorry for my late reply. I think i386-elf-gcc is available on macports, maybe you can try sudo port install i386-elf-gcc?

  11. Bianca

    Hi!!
    I have to follow the Mit Operating System Course and I am using a MacBook Air. I followed your precious advices but I am not able to compile binutils because I receive this error: make[1]: Nothing to be done for `all-target’.

    Could you please help me?

  12. Bianca

    Hi!!
    I have to follow the Mit Operating System Course and I am using a MacBook Air. I followed your precious advices but I am not able to compile binutils because I receive this error: make[1]: Nothing to be done for `all-target’.

    Could you please help me?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.