-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 77b24ba
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.DS_Store | ||
|
||
*.code-workspace | ||
|
||
*.ignore | ||
|
||
*.local | ||
|
||
*.log | ||
|
||
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM ubuntu:latest | ||
|
||
RUN apt update -y | ||
RUN apt upgrade -y | ||
RUN apt install -y build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# `gcc-riscv-docker`: a container image for compiling RISC-V 64 | ||
|
||
This repository contains a `Dockerfile` which builds a container image based on `ubuntu:latest` and installs the gcc-crosscompiler for RISC-V 64. | ||
|
||
## Usage | ||
|
||
The script is built with `podman` in mind, but should work just as well with `Docker`. To change this, adjust the comments in the files. | ||
|
||
|
||
```bash | ||
# make scripts executable | ||
chmod u+x build.sh | ||
chmod u+x compile.sh | ||
|
||
# build the container | ||
./build.sh | ||
|
||
# compile the file | ||
./compile.sh main.c -o main.o | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/zsh | ||
# Author: Nic Cantieni | ||
# Date: 18.08.2022 | ||
|
||
# Builds a container image from the Dockerfile. | ||
|
||
# podman | ||
podman build -t gcc-riscv-docker:latest . | ||
|
||
# docker | ||
# docker build -t gcc-riscv-docker:latest . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/zsh | ||
# Author: Nic Cantieni | ||
# Date: 18.08.2022 | ||
|
||
# Runs a temporary (--rm) container of the image gccriscv:latest, and mounts the current working directory into /builddir in the container, sets that as the working directory, invoces riscv64-linux-gnu-gcc and passes all arguments to this script through to riscv64-linux-gnu-gcc. | ||
|
||
podman run --rm --entrypoint riscv64-linux-gnu-gcc --volume $PWD:/builddir --workdir /builddir --name gcc-riscv-docker gcc-riscv-docker:latest "$@" | ||
|
||
# docker run --rm --entrypoint riscv64-linux-gnu-gcc --volume $PWD:/builddir --workdir /builddir --name gcc-riscv-docker gcc-riscv-docker:latest "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#define ERROR 1 | ||
#define INPUT 70 | ||
|
||
int check (int number) { | ||
|
||
if (number % 2) { | ||
return -ERROR; | ||
} else { | ||
return 42; | ||
} | ||
} | ||
|
||
int main () { | ||
|
||
if (check(INPUT) < 0) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} |