MIT 6.828 笔记——环境配置

6.828 lab tools guide(官方环境配置文档)

基本环境

操作系统

首先需要一个Linux环境(物理机、虚拟机都可以),我的环境是Ubuntu20.10的物理机。

编译工具链

也就是GCC、GDB等一系列工具,以下安装命令都以Debian系为例:

sudo apt install build-essential gdb

32位支持库

sudo apt-get install gcc-multilib

获取JOS源码

使用Git将源码克隆到本地。

git clone https://pdos.csail.mit.edu/6.828/2018/jos.git lab

QEMU

QEMU是一款开源的模拟处理器,课程使用它来进行X86仿真。强烈建议使用MIT提供的魔改版。

git clone https://github.com/mit-pdos/6.828-qemu.git qemu

编译QEMU

代码可能比较老了,编译中会出现一些问题。

configure忽略所有Warning:

CFLAGS=-Wno-error ./configure --disable-kvm --target-list="i386-softmmu x86_64-softmmu" --python=python2.7

(如果没有python2.7要先安装一下)

中间可能会遇到各种报错,此处引用大佬的博客(提及的问题我大部分都遇到了):

  1. 问题1:
    1. 出现:ERROR: Python not found. Use --python=/path/to/python
    2. 解决:添加--python=python3,还是不行提示Note that Python 3 or later is not yet supported。安装python2.7,然后使用--python=python2.7选项。
  2. 问题2:
    1. 出现:ERROR: pkg-config binary 'pkg-config' not found
    2. 解决:执行apt-get install -y pkg-config
  3. 问题3:
    1. 出现:ERROR: zlib check failed. Make sure to have the zlib libs and headers installed.
    2. 解决:执行sudo apt-get install zlib1g-dev
  4. 问题4:
    1. 出现:ERROR: glib-2.12 gthread-2.0 is required to compile QEMU
    2. 解决:sudo apt-get install libglib2.0-dev
  5. 问题5:
    1. 出现:ERROR: pixman >= 0.21.8 not present.
    2. 解决:sudo apt-get install libpixman-1-dev
  6. 问题6:
    1. 出现:vl.c: In function ‘main’: vl.c:2778:5: error: ‘g_mem_set_vtable’ is deprecated [-Werror=deprecated-declarations] g_mem_set_vtable(&mem_trace); ^ In file included from /usr/include/glib-2.0/glib/glist.h:32:0, from /usr/include/glib-2.0/glib/ghash.h:33, from /usr/include/glib-2.0/glib.h:50, from vl.c:59: /usr/include/glib-2.0/glib/gmem.h:357:7: note: declared here void g_mem_set_vtable (GMemVTable *vtable); ^ cc1: all warnings being treated as errors rules.mak:57: recipe for target 'vl.o' fai·led make: *** [vl.o] Error 1
    2. 解决:QEMU源码根目录下的Makefile文件最后加上一行 QEMU_CFLAGS+=-w优化

如果遇到undefined reference to 'major',在报错的源文件中添加#include <sys/sysmacros.h>

没问题之后就可以编译了。

make && make install

编译源码

进入源码目录

make
make qume

至此,6.828课程的环境配置就完成了。

posted @ 2020-12-20 23:50  缪若尘  阅读(1113)  评论(0编辑  收藏  举报