Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
FROM ubuntu:noble

# Install sudo
RUN apt update \
&& apt install -y sudo \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

# Add ubuntu user to the sudoers file
RUN echo ubuntu ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/ubuntu \
&& chmod 0440 /etc/sudoers.d/ubuntu

# Install dependencies for riscv-gnu-toolchain
RUN apt update \
&& apt install -y \
autoconf \
automake \
autotools-dev \
bc \
bison \
build-essential \
cmake \
curl \
flex \
gawk \
git \
gperf \
libexpat-dev \
libglib2.0-dev \
libgmp-dev \
libmpc-dev \
libmpfr-dev \
libslirp-dev \
libtool \
ninja-build \
patchutils \
python3 \
python3-pip \
python3-tomli \
texinfo \
zlib1g-dev \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

# Install riscv-gnu-toolchain from source
RUN git clone https://github.com/riscv/riscv-gnu-toolchain \
&& cd riscv-gnu-toolchain \
&& ./configure --prefix=/opt/riscv --with-arch=rv32im --with-abi=ilp32 --enable-llvm --disable-linux \
&& make -j$(nproc) all \
&& cd .. \
&& rm -rf riscv-gnu-toolchain

# Install dependencies for Lavinium
RUN apt update \
&& apt install -y \
binutils \
bzip2 \
coreutils \
findutils \
grep \
gzip \
libboost-all-dev \
libbz2-dev \
liblpsolve55-dev \
libssl-dev \
libxml2-dev \
lp-solve \
make \
sed \
sharutils \
tar \
unzip \
xz-utils \
zip \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

# Link the lpsolve library to make it available for compilation
RUN ln -sf /usr/lib/lp_solve/liblpsolve55.so /usr/lib/liblpsolve55.so

# Install pandas to make Lavinium test.py and test_mt.py work
RUN apt update \
&& apt install -y \
python3-pandas \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

# Install dependencies for llvm installer

RUN apt update \
&& apt install -y \
gnupg \
lsb-release \
software-properties-common \
wget \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

# Install llvm
RUN wget https://apt.llvm.org/llvm.sh \
&& chmod +x llvm.sh \
&& ./llvm.sh all \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

# Add llvm to PATH
ENV PATH="/usr/lib/llvm-20/bin:$PATH"

USER ubuntu
36 changes: 36 additions & 0 deletions .devcontainer/build-lavinium.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -euo pipefail

# Define build and install directories
llvm_root=$(pwd)
build_dir=$llvm_root/build
install_dir=$build_dir/install

mkdir -p "$build_dir"
mkdir -p "$install_dir"

# Configure CMake to build LLVM + Clang (and all LLVM tools like opt)
cmake -G Ninja -S "$llvm_root/llvm" -B "$build_dir" \
-DCMAKE_INSTALL_PREFIX="$install_dir" \
-DCMAKE_BUILD_TYPE=Debug \
\
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_ASM_COMPILER=clang \
-DCMAKE_LINKER=lld \
\
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DLLVM_TARGETS_TO_BUILD="ARM;RISCV" \
-DLLVM_DEFAULT_TARGET_TRIPLE="riscv32-unknown-elf" \
-DLLVM_ENABLE_EH=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_USE_SPLIT_DWARF=ON \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_PARALLEL_LINK_JOBS=4 \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_BUILD_TESTS=OFF

# Build and install
ninja -C "$build_dir" install
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "lavinium-dev",
"build": { "dockerfile": "Dockerfile" },
"runArgs": [
"--name",
"lavinium-dev"
]
}