-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Chuck Benedict
committed
Jul 30, 2024
1 parent
fa7aba4
commit c0360bf
Showing
5 changed files
with
127 additions
and
10 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,86 @@ | ||
name: CI | ||
|
||
env: | ||
LLVM_RELEASE_VERSION_WINDOWS: 18 | ||
LLVM_RELEASE_VERSION_MAC: 18 | ||
LLVM_RELEASE_VERSION_LINUX: 18 | ||
LLVM_DEV_VERSION: 20 | ||
jobs: | ||
|
||
build-linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
# Don't abort runners if a single one fails | ||
fail-fast: false | ||
matrix: | ||
build_type: [Release] | ||
llvm_version: [18] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install common deps | ||
run: | | ||
sudo apt-get install zlib1g zlib1g-dev python3 ninja-build curl | ||
- name: Install Clang ${{matrix.llvm_version}} | ||
run: | | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | ||
if [[ "${{matrix.llvm_version}}" < 18 ]]; then | ||
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{matrix.llvm_version}} main" | ||
sudo apt-get update | ||
sudo apt-get install -y -t llvm-toolchain-focal-${{matrix.llvm_version}} libpolly-${{matrix.llvm_version}}-dev \ | ||
clang-${{matrix.llvm_version}} llvm-${{matrix.llvm_version}} llvm-${{matrix.llvm_version}}-dev \ | ||
lld-${{matrix.llvm_version}} liblld-${{matrix.llvm_version}}-dev libmlir-${{matrix.llvm_version}} \ | ||
libmlir-${{matrix.llvm_version}}-dev mlir-${{matrix.llvm_version}}-tools | ||
else | ||
if [[ "${{matrix.llvm_version}}" < "${{env.LLVM_DEV_VERSION}}" ]]; then | ||
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{matrix.llvm_version}} main" | ||
sudo apt-get update | ||
sudo apt-get install -y -t llvm-toolchain-focal-${{matrix.llvm_version}} libpolly-${{matrix.llvm_version}}-dev \ | ||
clang-${{matrix.llvm_version}} llvm-${{matrix.llvm_version}} llvm-${{matrix.llvm_version}}-dev \ | ||
lld-${{matrix.llvm_version}} liblld-${{matrix.llvm_version}}-dev | ||
else | ||
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" | ||
sudo apt-get install -y -t llvm-toolchain-focal libpolly-${{matrix.llvm_version}}-dev \ | ||
clang-${{matrix.llvm_version}} llvm-${{matrix.llvm_version}} llvm-${{matrix.llvm_version}}-dev \ | ||
lld-${{matrix.llvm_version}} liblld-${{matrix.llvm_version}}-dev | ||
fi | ||
fi | ||
- name: CMake | ||
if: matrix.llvm_version < 18 || matrix.llvm_version == env.LLVM_DEV_VERSION | ||
run: | | ||
cmake -B build \ | ||
-G Ninja \ | ||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ | ||
-DCMAKE_C_COMPILER=clang-${{matrix.llvm_version}} \ | ||
-DCMAKE_CXX_COMPILER=clang++-${{matrix.llvm_version}} \ | ||
-DCMAKE_LINKER=lld-link-${{matrix.llvm_version}} \ | ||
-DCMAKE_OBJCOPY=llvm-objcopy-${{matrix.llvm_version}} \ | ||
-DCMAKE_STRIP=llvm-strip-${{matrix.llvm_version}} \ | ||
-DCMAKE_DLLTOOL=llvm-dlltool-${{matrix.llvm_version}} \ | ||
-DC3_LLVM_VERSION=${{matrix.llvm_version}} | ||
cmake --build build | ||
- name: CMake18 | ||
if: matrix.llvm_version >= 18 && matrix.llvm_version != env.LLVM_DEV_VERSION | ||
run: | | ||
cmake -B build \ | ||
-G Ninja \ | ||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ | ||
-DCMAKE_C_COMPILER=clang-${{matrix.llvm_version}} \ | ||
-DCMAKE_CXX_COMPILER=clang++-${{matrix.llvm_version}} \ | ||
-DCMAKE_LINKER=lld-link-${{matrix.llvm_version}} \ | ||
-DCMAKE_OBJCOPY=llvm-objcopy-${{matrix.llvm_version}} \ | ||
-DCMAKE_STRIP=llvm-strip-${{matrix.llvm_version}} \ | ||
-DCMAKE_DLLTOOL=llvm-dlltool-${{matrix.llvm_version}} \ | ||
-DC3_LLVM_VERSION=${{matrix.llvm_version}}.1 | ||
cmake --build build | ||
- name: Install QEMU and Risc-V toolchain | ||
run: | | ||
sudo apt-get install qemu gcc-riscv64-linux-gnu | ||
- name: Compile and run Risc-V Example | ||
run: | | ||
cd resources/examples/embedded/riscv-qemu | ||
make C3C_PATH=../../../../build/ run | ||
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
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import uart; | ||
import semihost; | ||
|
||
const UART0_BASE = 0x10000000; | ||
|
||
fn void main() @export("main") { | ||
Uart* uart0 = (Uart*)UART0_BASE; // Create pointer to UART 0 | ||
uart0.fcr = uart::UARTFCR_FFENA; // Enable FIFO | ||
uart0.puts("Hello World!\n"); // Write the string to the UART | ||
while (1); // Loop forever to prevent program from ending | ||
semihost::exit(0); // Semihosting call to exit host | ||
} |
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 @@ | ||
module semihost; | ||
|
||
// See: https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst#sys-exit-extended-0x20 | ||
|
||
extern fn int sys_semihost(int operation, SemihostParameters* parms); | ||
|
||
struct SemihostParameters { | ||
int field1; | ||
int field2; | ||
} | ||
|
||
const int SYS_EXIT_EXTENDED = 0x20; | ||
const int ADP_STOPPED_APPLICATIONEXIT = 0x20026; | ||
|
||
fn void exit(int status) { | ||
SemihostParameters parms; | ||
parms.field1 = ADP_STOPPED_APPLICATIONEXIT; | ||
parms.field2 = status; | ||
sys_semihost(SYS_EXIT_EXTENDED, &parms); | ||
} |
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