Last active
January 20, 2023 19:40
-
-
Save jtauber/8b2fa862d43ecedf7536 to your computer and use it in GitHub Desktop.
setting up OS X 10.9 for i386-elf cross-compilation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frustratingly, we need to have "real" gcc to build the i386-elf binutils/gcc | |
brew install gcc | |
# $PROJECT_HOME should be the parent directory under which you'll download | |
# everything and build the toolchain | |
cd $PROJECT_HOME | |
mkdir toolchain | |
# set up our environment variables | |
export PREFIX=$PROJECT_HOME/toolchain | |
export TARGET=i386-elf | |
export CC=/usr/local/bin/gcc-4.8 | |
export CXX=/usr/local/bin/g++-4.8 | |
export LD=/usr/local/bin/gcc-4.8 | |
export CFLAGS=-Wno-error=deprecated-declarations | |
# get binutils source | |
curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.gz | |
tar xvzf binutils-2.24.tar.gz | |
cd binutils-2.24 | |
# make binutils (for i386-elf) | |
./configure --prefix=$PREFIX --target=$TARGET --disable-nls | |
make | |
make install | |
cd .. | |
# get gcc source | |
curl -O http://ftp.gnu.org/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.gz | |
tar xvzf gcc-4.9.0.tar.gz | |
cd gcc-4.9.0 | |
# make gcc (for i386-elf) | |
./configure --prefix=$PREFIX --target=$TARGET --disable-nls --enable-languages=c --without-headers | |
make all-gcc | |
make install-gcc | |
export PATH=$PREFIX/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how to make a grub floppy image | |
dd if=/dev/zero of=grub.img bs=512 count=2880 | |
cat boot/grub/stage1 boot/grub/stage2 | dd of=grub.img conv=notrunc |
make -j8
works faster
For anyone who will need to link libgcc
, create a subdirectory eg. build in the gcc folder and run ../configure etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For anyone attempting this in the future and curious about runtime (this is just the compiling gcc part):
MacBook Pro (15-inch, Late 2008)
2.4 GHz Intel Core 2 Duo
8 GB 1067 MHz DDR3
256GB SSD
It took a little over 60 minutes (gcc 4.9.3).