This repository contains some public infrastructure for Cornell's CS 3410. Currently, there is only one thing here: a Docker container for the RISC-V toolchain.
Thanks to Depot, we build a container on every push to this repository. Try this to get started:
docker run -i -t --rm ghcr.io/sampsyo/cs3410-infra bash
Here's an example showing compilation and execution of a C program:
$ docker run -i -t --rm ghcr.io/sampsyo/cs3410-infra bash
root@9d6d042c8aa2:~# printf '#include <stdio.h>\nint main() { printf("hi!\\n"); }\n' > hi.c
root@9d6d042c8aa2:~# gcc hi.c
root@9d6d042c8aa2:~# qemu-riscv64 a.out
hi!
A good way to use the container is to use volumes to let it operate on files on your computer.
The key is to use something like -v `pwd`:/root
to map the working directory on the host to the working directory within the container.
Try adding this alias to your .profile
or similar:
alias rv='docker run -it --rm -v `pwd`:/root ghcr.io/sampsyo/cs3410-infra'
Now you can run tools from the container by prefixing them with rv
.
For example, here's how to do the same thing as above but with using files from the host filesystem:
$ printf '#include <stdio.h>\nint main() { printf("hi!\\n"); }\n' > hi.c
$ rv gcc hi.c
$ file a.out
a.out: ELF 64-bit LSB executable, UCB RISC-V, double-float ABI, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-riscv64-ilp64d.so.1, for GNU/Linux 5.4.0, not stripped
$ rv qemu-riscv64 a.out
hi!
There is also a simple devcontainer configuration and c_cpp_properties.json
configuration file for Visual Studio Code.
Try opening this repository in VSCode and writing a simple C program to try it out.
The app should hopefully prompt you to "Reopen in Container," if you have the "Dev Containers" extension.