β

运行Pintos

Danny Suen's Blog 145 阅读
 

引言

运行Pintos最好在Ubuntu Linux环境下,至少我在Mac下没有运行成功。此外Pintos需要用 GCC 4.1.2版本的编译器编译源码。种种的因素给运行Pintos带来了障碍。

解决步骤

一. 安装GCC 4.1.2版本

获取GCC 4.1.2版本源码

$ wget http://www.netgull.com/gcc/releases/gcc-4.1.2/gcc-4.1.2.tar.bz2
$ tar xvjf gcc-4.1.2.tar.bz2

对头文件和库做符号链接

$ cd /usr/include
$ sudo ln -s i386-linux-gnu/bits bits
$ sudo ln -s i386-linux-gnu/gnu gnu
$ sudo ln -s i386-linux-gnu/sys sys
$ sudo ln -s i386-linux-gnu/asm asm
$ cd /usr/lib
$ sudo ln -s i386-linux-gnu/crt1.o crt1.o
$ sudo ln -s i386-linux-gnu/crti.o crti.o
$ sudo ln -s i386-linux-gnu/crtn.o crtn.o

构建gcc

$ cd ~/gcc-4.1.2/
$ mkdir objdir
$ cd objdir
$ ../configure --prefix=/usr/local --program-prefix=sse- --libexecdir=/usr/local/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --enable-languages=c,c++
$ make bootstrap

安装gcc

$ sudo make install
$ ls -l /usr/local/bin
i686-pc-linux-gnu-gcc-4.1.2  i686-pc-linux-gnu-sse-gcc  sse-g++     sse-gcov
i686-pc-linux-gnu-sse-c++    sse-c++                    sse-gcc
i686-pc-linux-gnu-sse-g++    sse-cpp                    sse-gccbug

二、安装QEMU

$ sudo apt-get install qemu-system
$ cd /usr/bin
$ sudo ln -s qemu-system-i386 qemu

三、运行Pintos

获取Pintos源码

$ zcat pintos.tar.gz | tar x

配置用gcc 4.1.2构建Pintos

...
# Binary utilities.
# If the host appears to be x86, use the normal tools.
# If it's x86-64, use the compiler and linker in 32-bit mode.
# Otherwise assume cross-tools are installed as i386-elf-*.
X86 = i.86\|pentium.*\|[pk][56]\|nexgen\|viac3\|6x86\|athlon.*\|i86pc
X86_64 = x86_64

# Pintos doesn't compile/run properly using gcc 4.3+. Force 4.1 for now.
CCPROG = /usr/danny/cs140/x86_64/bin/i586-elf-gcc
ifeq ($(strip $(shell command -v $(CCPROG) 2> /dev/null)),)
  CCPROG = sse-gcc
endif
...
 
作者:Danny Suen's Blog
原文地址:运行Pintos, 感谢原作者分享。

发表评论