diff --git a/Containerfile.llvm b/Containerfile.llvm deleted file mode 100644 index a4ca865..0000000 --- a/Containerfile.llvm +++ /dev/null @@ -1,31 +0,0 @@ -# global arguments -ARG LLVM_SOURCE_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/llvm-project-16.0.0.src.tar.xz" -ARG LLVM_VERSION="16" - -# the base layer. -FROM debian:oldstable AS base -ENV DEBIAN_FRONTEND="noninteractive" -RUN apt-get update - -# base layer for building anything -FROM base AS build-base -WORKDIR /build -ARG BUILD_DEPS="curl ca-certificates build-essential python3 cmake ninja-build pkg-config git zlib1g-dev" -RUN apt-get install -y --no-install-recommends $BUILD_DEPS - -# This layer extracts the LLVM source code extracted to /build/llvm -FROM build-base as llvm-base -ARG LLVM_SOURCE_URL -RUN mkdir llvm && \ - cd llvm && \ - curl -L $LLVM_SOURCE_URL | tar --strip-components=1 -xJf - - - -# This will launch the builder script. -# /build/llvm-bin is expected to be mounted to a host directory. -FROM llvm-base as llvm-build -COPY scripts/build_llvm.sh . -ARG LLVM_VERSION -ENV LLVM_VERSION=$LLVM_VERSION -ENTRYPOINT [ "/bin/bash" ] -CMD [ "/build/build_llvm.sh" ] diff --git a/README.md b/README.md index 6d22371..736e494 100644 --- a/README.md +++ b/README.md @@ -4,25 +4,14 @@ LCPU is an alternative CPU core addon for GMod/Wiremod. It provides: -- A standard RISC-V architechure (rv32ima) CPU core -- Extensive interoperation with the Wiremod addon -- A text editor and assembler suite based on LLVM (for writing bare-metal LCPU programs in assembly) +- A standard RISC-V architechure (rv32ima) CPU core, implemented in native code + - No wiremod native code embargos here! +- Interoperation with the Wiremod addon (and addons which implement Wiremod integration) # Building Native Module TODO: Steps to build the LCPU native module on Windows and Linux - -LLVM is built using a podman container (see Containerfile). The steps for building follow (this should only need to be done once): - -``` -mkdir llvm_build -podman build -t llvm-build -f Containerfile.llvm -podman run --rm --mount type=bind,source=$PWD/llvm_build,destination=/build/llvm-build localhost/llvm-build -cp -rv llvm_build/install lua/bin/llvm -``` - - # Installation This repository is set up in the exact directory structure to be a Legacy Addon; therefore once you have built the native module (TODO), adding it to a server should work fine. diff --git a/ideas.md b/ideas.md index 22abb19..757f462 100644 --- a/ideas.md +++ b/ideas.md @@ -8,28 +8,39 @@ This is basically the working ideas for the LCPU project. - RISC-V rv32ima core - Would supporting more than one CPU core type be worthwhile? If so, the project is relatively setup for such workflow... - Controllable paramaters (RAM size, ...) -- Our own frambuffer screen SENT (since wiremod decided to go stupid mode and saw off the gpu) +- Our own framebuffer screen SENT (since wiremod decided to go stupid mode and saw off the gpu) -## Code upload/project workflow +## Code upload -- Upload a raw binary to execute, generated from any user tooling +- Upload a raw binary to execute, generated from any user tooling (goes into server data folder) - Yes, this means you can run Linux in GMod. No, I'm not sorry. - Or even an ELF? Would require less linker hell? -### Integrated simple project workflow +## Integrated simple project workflow (WIP) -### LLVM integration +- Uses official RISC-V GCC toolchain + - Server operator can control root path of where they have installed it. -- Use LLVM tools (clang as both assembler driver and C/C++ driver) for compilation. - - Prebuilt toolchain with compiler-rt can be built. (only needed since compiler-rt isn't usually built with most system clang installations.) +- Write assembly/C/C++ code using a tiny project system (source for them would go in server data folder ?) + - At the root of a project, a `project.json` file exists, with something like: + ```json + { + "project": { + "cCompileFlags": "-O2", + "cppCompileFlags": "-O2 -fno-exceptions -fno-rtti", -- Write assembly/maybe C/C++ code using a tiny project system (data for them would go in server data folder ?) + "sources": [ + "startup.S", + "main.cpp" + ] + + } + } + ``` - No conditional compilation - All files in a project are built by that project -- Diagnostic integration (by either using libclang) - - Text editor used to edit project source files - Some example projects? @@ -44,7 +55,7 @@ This is basically the working ideas for the LCPU project. - Admin controled global (affects all placed LCPUs) scheduler cycle rate. - Couldn't be faster than tickrate though or we might block source (and.. well, i dont think i have to explain) - - I decided not to go with the cpu thread stuff just because its annoying, and would require more state tracking. just ticking in lua using `ENTITY:Think` should be more than good enough (even if theres a risk of hitching source, but I don't think it's that big of a problem...) + - I decided not to go with the cpu thread stuff just because its annoying, and would require more state tracking. just ticking in lua using `ENT:Think` should be more than good enough (even if theres a risk of hitching source, but I don't think it's that big of a problem...) - Project compilations however will definitely end up in a different thread though. Running them in the engine thread would undoubtably cause issues. ## Addon interopability diff --git a/scripts/build_llvm.sh b/scripts/build_llvm.sh deleted file mode 100755 index 12761c7..0000000 --- a/scripts/build_llvm.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# This script builds the llvm components used by the LCPU addon. -# This is run in a debian container to try and keep everything ABI stable. - -# Act like make, sort of, and fail the whole script if some part fails -set -e - -JOBS=$(nproc) - -# Configure LLVM. THis is a mouthful, but it's only a mouthful because we specialize things we don't -# want in our minimal build of the LLVM project/clang. -cmake -Wno-dev -GNinja -S /build/llvm/llvm -B /build/llvm-build/build \ - -DCMAKE_BUILD_TYPE=MinSizeRel \ - -DCMAKE_INSTALL_PREFIX="/build/llvm-build/install" \ - -DLLVM_INCLUDE_TESTS=OFF \ - -DLLVM_ENABLE_PROJECTS="clang;lld" \ - -DLLVM_ENABLE_RUNTIMES="compiler-rt" \ - -DCOMPILER_RT_BAREMETAL_BUILD=ON \ - -DLLVM_TARGETS_TO_BUILD="RISCV" \ - -DLLVM_DEFAULT_TARGET_TRIPLE="riscv32-unknown-gnu" - -ninja -C /build/llvm-build/build -j $JOBS -ninja -C /build/llvm-build/build install