MIT6.828 操作系统课程实验环境配置

操作系统:Ubuntu-18.04.5-64bit

虚拟机软件:VMware16

课程主页:MIT6.828(2018)

环境配置 参考

编译工具链

1.测试编译工具

$ objdump -i

image-20210727123132004

$ gcc -m32 -print-libgcc-file-name 		#测试gcc

上面这条命令是测试gcc的,一般系统是没有gcc的,需要安装

安装gcc , gdb, git, vim

$sudo apt-get install -y build-essential gdb git vim

安装32位的支持库

$sudo apt-get install gcc-multilib

2. 编译安装工具链

2.1下载以下工具包

第一个包可能下载不了,可以自己搜索,或是使用下面的链接

https://mirrors.sjtug.sjtu.edu.cn/gnu/gmp/gmp-5.0.2.tar.bz2

2.2 编译安装

为了方便,将以上6个压缩包放在一个文件夹下 ,~/download/mit6.828

文件夹结构

image-20210727131718755

以下的操作都是在 ~/download/mit6.828 目录下

  1. 安装gmp-5.0.2

    $tar xjf gmp-5.0.2.tar.bz2
    $cd gmp-5.0.2
    $./configure --prefix=/usr/local   # 可能的错误:No usable m4 in $PATH or /usr/5bin (see config.log for reasons).
    $make
    $sudo make install             
    $cd ..
    

    逐条执行命令,每执行一条后,输出无 error 就可往下执行,后面几个安装包也是一样的

    可能的错误是第3个命令,如果报错,执行以下命令,然后再次执行第3行命令

    $sudo apt install m4
    
  2. 安装mpfr-3.1.2

    $tar xjf mpfr-3.1.2.tar.bz2
    $cd mpfr-3.1.2
    $./configure --prefix=/usr/local
    $make
    $sudo make install           
    $cd ..
    
  3. 安装mpc-0.9

    $tar xzf mpc-0.9.tar.gz
    $cd mpc-0.9
    $./configure --prefix=/usr/local
    $make
    $sudo make install            
    $cd ..
    
  4. 安装binutils-2.21.1

    $tar xjf binutils-2.21.1.tar.bz2
    $cd binutils-2.21.1
    $./configure --prefix=/usr/local --target=i386-jos-elf --disable-werror
    $make
    $sudo make install             # This step may require privilege (sudo make install)
    $cd ..
    
    #测试
    $i386-jos-elf-objdump -i
    # 成功安装会输出类似下面的信息
    # BFD header file version (GNU Binutils) 2.21.1
    # elf32-i386
    #  (header little endian, data little endian)
    #   i386...
    
  5. 安装gcc-core-4.6.4

    $tar xjf gcc-core-4.6.4.tar.bz2
    $cd gcc-4.6.4
    $mkdir build           
    $cd build
    $../configure --prefix=/usr/local 
        --target=i386-jos-elf --disable-werror 
        --disable-libssp --disable-libmudflap --with-newlib 
        --without-headers --enable-languages=c MAKEINFO=missing
    $make all-gcc
    $sudo make install-gcc         
    $make all-target-libgcc		#可能会报错 [configure-target-libgcc] Error 1
    $sudo make install-target-libgcc   
    $cd ../..
    
    #测试
    $i386-jos-elf-gcc -v
    # 成功安装会输出类似下面的信息
    # Using built-in specs.
    # COLLECT_GCC=i386-jos-elf-gcc
    # COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-jos-elf/4.6.4/lto-wrapper
    # Target: i386-jos-elf
    

    执行11行命令可能会报错,如果报错,执行以下命令,然后再次执行第11行命令

    $export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib 
    
  6. 安装gdb-7.3.1

    $tar xjf gdb-7.3.1.tar.bz2
    $cd gdb-7.3.1
    $./configure --prefix=/usr/local --target=i386-jos-elf --program-prefix=i386-jos-elf- 
        --disable-werror
    $make all			#可能的错误 no termcap library found
    $sudo make install         
    $cd ..
    

    可能报错的命令第5个,如果出现错误,执行以下命令,然后再执行该命令

    $wget http://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz
    $tar -zxv -f termcap-1.3.1.tar.gz
    $cd termcap-1.3.1
    $ ./configure 
    $make
    $sudo make install
    

安装 QEMU

1. 安装工具包

$sudo apt install libsdl1.2-dev libtool-bin libglib2.0-dev  libz-dev  libpixman-1-dev
$sudo apt install python2

2. 下载qemu

qemu需要用6.828定制的

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

3. 编译安装

$./configure --disable-kvm --disable-werror --prefix=/usr/local  --target-list="i386-softmmu x86_64-softmmu" --python=python2
$make
$sudo make install

可能的错误:

  1. 缺少一个头文件,错误如下

    qga/commands-posix.c: In function ‘dev_major_minor’:
    qga/commands-posix.c:633:13: error: In the GNU C Library, "major" is defined
     by <sys/sysmacros.h>. For historical compatibility, it is
     currently defined by <sys/types.h> as well, but we plan to
     remove this soon. To use "major", include <sys/sysmacros.h>
     directly. If you did not intend to use a system-defined macro
     "major", you should undefine it after including <sys/types.h>. [-Werror]
             *devmajor = major(st.st_rdev);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~   
    

    解决:在 qga/commands-posix.c文件中的 #include <sys/types.h> 下面增加#include <sys/sysmacros.h>即可

4.测试

#下载实验源码
$git clone https://pdos.csail.mit.edu/6.828/2018/jos.git lab
$cd lab
$make
$make qemu-nox

测试成功

image-20210727171159202

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/kinvy/p/15074844.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!