Skip to content

Commit

Permalink
devel/llvm-cheriot: compiler for CHERIoT ISA
Browse files Browse the repository at this point in the history
Add a port of the CHERIoT compiler.  The CHERIoT ISA adds CHERI to
RV32e (a microcontroller RISC-V variant).  A number of products based
on CHERIoT are in the pipeline including the Sonata board from lowRISC's
Sunburst Project (https://www.sunburst-project.org).

Requested by:	emaste
  • Loading branch information
brooksdavis committed Nov 16, 2023
1 parent ead3707 commit bdbe535
Show file tree
Hide file tree
Showing 10 changed files with 2,943 additions and 1 deletion.
1 change: 1 addition & 0 deletions devel/Makefile
Expand Up @@ -1467,6 +1467,7 @@
SUBDIR += llnextgen
SUBDIR += llvm
SUBDIR += llvm-cheri
SUBDIR += llvm-cheriot
SUBDIR += llvm-devel
SUBDIR += llvm-morello
SUBDIR += llvm10
Expand Down
23 changes: 23 additions & 0 deletions devel/llvm-cheriot/Makefile
@@ -0,0 +1,23 @@
# llvm-cheriot

LLVM_SUFFIX= -cheriot

COMMENT= LLVM and Clang with support the CHERIoT microcontroller
WWW= https://www.microsoft.com/en-us/research/publication/cheriot-rethinking-security-for-low-cost-embedded-systems/

DISTINFO_FILE= ${.CURDIR}/distinfo
DESCR= ${.CURDIR}/pkg-descr
PLIST= ${.CURDIR}/pkg-plist

LLVM_TARGETS= RISCV
CMAKE_FLAGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=riscv32-unknown-unknown

.if exists(${.CURDIR}/files)
EXTRA_PATCHES= ${.CURDIR}/files
.endif

.include "${.CURDIR}/Makefile.snapshot"

MASTERDIR= ${.CURDIR}/../llvm-cheri

.include "${MASTERDIR}/Makefile"
6 changes: 6 additions & 0 deletions devel/llvm-cheriot/Makefile.COMMANDS
@@ -0,0 +1,6 @@
.include "${.CURDIR}/../llvm-cheri/Makefile.COMMANDS"

# Work around version skew with llvm-cheri
LLVM_COMMANDS:= ${LLVM_COMMANDS:Nllvm-debuginfod-find:Nllvm-tli-checker}
CLANG_COMMANDS:=${CLANG_COMMANDS:Nclang-linker-wrapper:Nclang-nvlink-wrapper:Nclang-repl}
LLD_COMMANDS+= ld64.lld.darwinnew ld64.lld.darwinold
4 changes: 4 additions & 0 deletions devel/llvm-cheriot/Makefile.MAN1SRCS
@@ -0,0 +1,4 @@
.include "${.PARSEDIR}/../llvm-cheri/Makefile.MAN1SRCS"

# Workaround for llvm-cheri/llvm-morello version skew
LLVM_MAN1SRCS:= ${LLVM_MAN1SRCS:Nllvm-tli-checker.1}
9 changes: 9 additions & 0 deletions devel/llvm-cheriot/Makefile.snapshot
@@ -0,0 +1,9 @@
# Generated file! Do not edit!
#
# Generated by: files/gen-Makefile.snapshot.sh.
#
LLVM_MAJOR= 13
LLVM_RELEASE= ${LLVM_MAJOR}.0.0
SNAPDATE= 20230706

LLVM_COMMIT= a6c9dc0a4232ed4a64acc6ba4fc7f2754de1ed45
3 changes: 3 additions & 0 deletions devel/llvm-cheriot/distinfo
@@ -0,0 +1,3 @@
TIMESTAMP = 1699044153
SHA256 (CTSRD-CHERI-llvm-project-13.0.d20230706-a6c9dc0a4232ed4a64acc6ba4fc7f2754de1ed45_GH0.tar.gz) = 955d8fb500a9512d1085caf3a6b250e3d297554d4905aa7e2b7b76fed8280c33
SIZE (CTSRD-CHERI-llvm-project-13.0.d20230706-a6c9dc0a4232ed4a64acc6ba4fc7f2754de1ed45_GH0.tar.gz) = 152251308
46 changes: 46 additions & 0 deletions devel/llvm-cheriot/files/gen-Makefile.snapshot.sh
@@ -0,0 +1,46 @@
#!/bin/sh
#
# Simple script to fetch the latest commits via the github API. Requires
# curl and jq. Uses unauthenticated access which is ratelimited to 60
# queries per hour.

REPOS_URL=https://api.github.com/repos/CTSRD-CHERI
MAX_DATE=1970101

tmpfile=`mktemp -t gen-Makefile.snapshot`

query_repo()
{
curl ${REPOS_URL}/$1/branches/cheriot > $tmpfile

# Accumulate the dates of the last commits to find the snapshot date
committime=`jq -r '.commit.commit.committer.date' $tmpfile`
committime=${committime%%T*}
year=${committime%%-*}
month=${committime%-*}
month=${month#*-}
day=${committime##*-}
dateint=${year}${month}${day}
if [ $dateint -gt $MAX_DATE ]; then
export MAX_DATE=$dateint
fi

SHA=`jq -r '.commit.sha' $tmpfile`
}

query_repo llvm-project
LLVM_COMMIT=$SHA

cat <<EOF > Makefile.snapshot
# Generated file! Do not edit!
#
# Generated by: files/gen-Makefile.snapshot.sh.
#
LLVM_MAJOR= 13
LLVM_RELEASE= \${LLVM_MAJOR}.0.0
SNAPDATE= ${MAX_DATE}
LLVM_COMMIT= ${LLVM_COMMIT}
EOF

rm -f $tmpfile
6 changes: 6 additions & 0 deletions devel/llvm-cheriot/pkg-descr
@@ -0,0 +1,6 @@
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. This version adds support for the Arm Morello
prototype architecture (CHERI ported to ARMv8-A).

This port includes Clang (a C/C++/Objective-C compiler), LLD (a linker),
and the LLVM infrastructure these are built on.

0 comments on commit bdbe535

Please sign in to comment.