LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

How To Compile The 3 Items Needed To Begin MIT’s Free Xv6 Online Operating System Course!

Brian Kernighan holding Lions Commentary at Dennis Ritchie's tribute in 2012

In a previous post I invited folks to join me in auditing MIT’s Free Online Operating System Course. This post outlines what I have done to get ready to run MIT’s teaching operating system, Xv6, on my antique server, Darkstar.

The current version of Xv6 runs on the RISC-V instruction set. Thus, many people who, like me, have Intel architecture machines, need the Qemu emulator to run Xv6. The RISC-V GNU toolchain also is required because Xv6 needs a few seconds of recompiling whenever we students make changes in the code.

Qemu and the RISC-V GNU toolchain easily can be installed using the package system of many Linux distributions. But I enjoy compiling stuff myself. Also, Darkstar runs Slackware64-current. The Slackware default install comes with tons of stuff, but Qemu and the RISC-V GNU toolchain are not included.

Qemu

Darkstar had the compiled bleeding edge Qemu source already installed because Qemu was being used to run Virtual Machines. But, if we needed to clone and build bleeding edge Qemu, the steps are, as given at Qemu.org:

git clone https://gitlab.com/qemu-project/qemu.git
cd qemu
git submodule init
git submodule update --recursive
./configure
make

After we finish compiling Qemu, it needs to be installed with something like:

make install

Sudo or root access is required to build and install Qemu.

RISC-V GNU toolchain

Installing the toolchain also requires root or sudo privileges. Compiling the toolchain requires significant disk space for the sources. Subsequent to the build, Darkstar had used:

root@darkstar:/usr/local/src# du -sh riscv-gnu-toolchain/
11G riscv-gnu-toolchain/
root@darkstar:/usr/local/src#

Step by step instructions for both package system installing and for compiling of the RISC-V GNU toolchain are available from MIT and from the toolchain’s Github Readme.

Here are the steps I used on Darkstar:

507 cd /usr
508 ls
509 ls -l local-revert.tgz
510 history | grep local-revert
511 tar cvzf local-revert.tgz local ## Maybe I can revert if needed. :)
512 ls -lh *rev*
513 cd local/src
514 ls
515 git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
516 cd riscv-gnu-toolchain/
517 ls
518 less README.md
519 ./configure --prefix=/usr/local
520 make -j 16
521 make install ## This step is not needed.

Here is a screenshot of top(1) during the toolchain build process. Darkstar is cooking along with all 16 cores at work:

Screenshot while compiling toolchain

Something I haven’t figured out yet is why an install step isn’t required:

root@darkstar:/local/src/riscv-gnu-toolchain# make install
make: Nothing to be done for 'install'.
root@darkstar:/usr/local/src/riscv-gnu-toolchain#

Here’s some of the output from the make command. As you can see /usr/bin/ginstall is being called during make:

/usr/bin/ginstall -c -m 644 ../.././riscv-gcc/gcc/wide-int.h /usr/local/lib/gcc/riscv64-unknown-elf/11.1.0/plugin/include/wide-int.h
/usr/bin/ginstall -c -m 644 ../.././riscv-gcc/gcc/xcoff.h /usr/local/lib/gcc/riscv64-unknown-elf/11.1.0/plugin/include/xcoff.h
/usr/bin/ginstall -c -m 644 ../.././riscv-gcc/gcc/xcoffout.h /usr/local/lib/gcc/riscv64-unknown-elf/11.1.0/plugin/include/xcoffout.h
/usr/bin/ginstall -c -m 644 b-header-vars /usr/local/lib/gcc/riscv64-unknown-elf/11.1.0/plugin/include/b-header-vars
make[3]: Leaving directory '/usr/local/src/riscv-gnu-toolchain/build-gcc-newlib-stage2/gcc'
make[2]: Leaving directory '/usr/local/src/riscv-gnu-toolchain/build-gcc-newlib-stage2'
make[1]: Leaving directory '/usr/local/src/riscv-gnu-toolchain/build-gcc-newlib-stage2'
mkdir -p stamps/ && touch stamps/build-gcc-newlib-stage2

It might seem obvious that the process could have been designed not to require an install step. But why?

I am guessing that maybe there are some dynamic libraries created. The newly created libraries perhaps can’t even be tested without being installed in the expected locations programmed into the binaries which use the libraries.

Please give me a clue if you know about the reasons why the usual install step is missing here.

Xv6 Operating System

Here’s our setup for running Xv6 as an unprivileged user in our home directory:

495 git clone git://github.com/mit-pdos/xv6-riscv.git
496 cd xv6-riscv/
497 ls
498 cat README
499 make qemu

Here’s Xv6 booted and ready to go! :)

Xv6 ready to go!

No Comments

    Leave a Reply

    Some notes on commenting on LowEndBox:

    • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
    • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
    • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

    Your email address will not be published.