Skip to content

Instantly share code, notes, and snippets.

@film42
Last active September 28, 2020 12:10
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save film42/be4bb4f82cf03a71ebe7 to your computer and use it in GitHub Desktop.
Save film42/be4bb4f82cf03a71ebe7 to your computer and use it in GitHub Desktop.
Get xv6 running with QEMU on OSX Yosemite
#! /usr/bin/env bash
# Get xv6 working with OSX Yosemite
# Most things were here: https://doesnotscale.com/compiling-xv6-on-os-x-10-9/
# You need homebrew installed to make this thing work
brew tap homebrew/versions && brew install gcc48
brew deps qemu | xargs brew install
export PATH=/usr/local/bin:$PATH
export CC=/usr/local/bin/gcc-4.8
brew install wget
mkdir -p /tmp/xv6-deps
cd /tmp/xv6-deps
wget http://ftpmirror.gnu.org/binutils/binutils-2.21.1.tar.bz2
wget http://www.mpfr.org/mpfr-3.1.0/mpfr-3.1.0.tar.bz2
wget ftp://ftp.gmplib.org/pub/gmp-5.0.4/gmp-5.0.4.tar.bz2
wget http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz
wget http://ftpmirror.gnu.org/gcc/gcc-4.5.1/gcc-core-4.5.1.tar.bz2
wget http://ftpmirror.gnu.org/gdb/gdb-6.8a.tar.gz
mkdir /usr/local/xv6
tar -xzf binutils-2.21.1.tar.bz2 && cd binutils-2.21.1
CFLAGS=-Wno-error=deprecated-declarations ./configure --target=i386-jos-elf --disable-nls --prefix=/usr/local/xv6 && make && make install
cd .. && mkdir install
tar -xzf gmp-5.0.4.tar.bz2 && mkdir gmp-build; cd gmp-build
../gmp-5.0.4/configure --prefix=$(cd ../install && pwd) && make && make install
cd .. && tar -xzf mpfr-3.1.0.tar.bz2 && mkdir mpfr-build; cd mpfr-build
../mpfr-3.1.0/configure --prefix=$(cd ../install && pwd) --with-gmp=$(cd ../install && pwd) && make && make install
cd .. && tar -xzf mpc-0.8.2.tar.gz && mkdir mpc-build; cd mpc-build
../mpc-0.8.2/configure --prefix=$(cd ../install && pwd) --with-gmp=$(cd ../install && pwd) --with-mpfr=$(cd ../install && pwd) && make && make install
cd .. && tar -xzf gcc-core-4.5.1.tar.bz2 && mkdir gcc-build; cd gcc-build
../gcc-4.5.1/configure --target=i386-jos-elf --disable-nls --without-headers --with-newlib --disable-threads --disable-shared --disable-libmudflap --disable-libssp --with-gmp=$(cd ../install && pwd) --with-mpfr=$(cd ../install && pwd) --with-mpc=$(cd ../install && pwd) --prefix=/usr/local/xv6 && make && make install
export PATH=/usr/local/xv6/bin:$PATH
cd .. && tar -xzf gdb-6.8a.tar.gz && mkdir gdb-build; cd gdb-build
../gdb-6.8/configure --target=i386-jos-elf --program-prefix=i386-jos-elf- --disable-werror --prefix=/usr/local/xv6 && make && make install
# Best way to do this
brew install qemu
# Get the code
cd /tmp
git clone git://pdos.csail.mit.edu/xv6/xv6.git && cd xv6
# Run it
QEMU=qemu-system-i386 clean && make qemu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment