add scripts for building llvm (for inclusion in addon root)

This commit is contained in:
Lily Tsuru 2023-07-16 21:10:59 -04:00
parent 732ff5fef8
commit 8d7e8c3a11
4 changed files with 68 additions and 8 deletions

8
.gitignore vendored
View File

@ -4,3 +4,11 @@ native/projects/riscv/ref
.cache/ .cache/
.vscode/ .vscode/
# temporary
llvm_src/
llvm_build/
# pre-'mv' filenames
llvm-project-*/

42
build_llvm.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
# this script builds llvm components
LLVM_VERSION=16.0.0
LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/llvm-project-$LLVM_VERSION.src.tar.xz"
LLVM_FILENAME="llvm-project-$LLVM_VERSION.src.tar.xz"
# download/extract LLVM (if need be)
[[ ! -d 'llvm_src' ]] && {
curl -LO $LLVM_URL
tar xf $LLVM_FILENAME
mv llvm-project-$LLVM_VERSION.src llvm_src/
rm $LLVM_FILENAME
};
# 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.
# -DLLVM_ENABLE_LTO=Thin
cmake -GNinja -S llvm_src/llvm -B llvm_build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX="$PWD/lua/bin/llvm" \
-DLLVM_USE_LINKER=lld \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DLLVM_TARGETS_TO_BUILD="RISCV" \
-DLLVM_DEFAULT_TARGET_TRIPLE="riscv32-none-gnu"
# TODO: Configure and build compiler-rt with our toolchain.
#cmake -GNinja -S llvm_src/compiler-rt \
# -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
# -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
# -DCOMPILER_RT_BUILD_PROFILE=OFF \
# -DCOMPILER_RT_BUILD_MEMPROF=OFF \
# -DCOMPILER_RT_BUILD_ORC=OFF \
# -DCOMPILER_RT_BAREMETAL_BUILD=ON
# Build it
cmake --build llvm_build -j $(($(nproc) + 1))

View File

@ -8,6 +8,7 @@ This is basically the working ideas for the LCPU project.
- RISC-V rv32ima core - RISC-V rv32ima core
- Would supporting more than one CPU core type be worthwhile? If so, the project is relatively setup for such workflow... - Would supporting more than one CPU core type be worthwhile? If so, the project is relatively setup for such workflow...
- Controllable paramaters (RAM size, ...) - Controllable paramaters (RAM size, ...)
- Our own frambuffer screen SENT (since wiremod decided to go stupid mode and saw off the gpu)
## Code upload/project workflow ## Code upload/project workflow
@ -17,11 +18,15 @@ This is basically the working ideas for the LCPU project.
### Integrated simple project workflow ### Integrated simple project workflow
### LLVM integration
- LLVM assembler (llvm-mc) is used
- clang for C code? (if it's not prohibitively expensive)
- In all cases (as/clang), the tools will all be firewalled to the given project data directory.
In the case of clang, an addional path will be allowed (clang freestanding headers), but that's the only exception.
- LLVM tools integrated into server library? Or installed in lua/bin?
- Write assembly/maybe C code using a tiny project system (data for them would go in server data folder ?) - Write assembly/maybe C code using a tiny project system (data for them would go in server data folder ?)
- LLVM assembler is used
- Integrated clang for C code? (if it's not prohibitively expensive)
- In all cases (as/clang), the tools will all be firewalled to the given project data directory.
In the case of clang, an addional path will be allowed (clang freestanding headers), but that's the only exception.
- Text editor used to edit project source files - Text editor used to edit project source files
@ -33,9 +38,9 @@ This is basically the working ideas for the LCPU project.
- possibly override for "respectful" users and admins (admins probably wouldn't even count)? - possibly override for "respectful" users and admins (admins probably wouldn't even count)?
- Admin controlled per-user max LCPU entity count (default 8) - Admin controlled per-user max LCPU entity count (default 8)
- admins can override/do not count? - Admins don't count
- Admin controled global (affects all placed LCPUs) scheduler timeslice. - 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) - 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 `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...)
- Project compilations however will definitely end up in a different thread though. Running them in the engine thread would undoubtably cause issues. - Project compilations however will definitely end up in a different thread though. Running them in the engine thread would undoubtably cause issues.
@ -45,4 +50,3 @@ This is basically the working ideas for the LCPU project.
- Wiremod interopability - Wiremod interopability
- Wiremod GPIO (which uses normal wire stuff) - Wiremod GPIO (which uses normal wire stuff)
- Console Screen - Console Screen
- Wire GPU (if it's not painful to do so)?

View File

@ -2,3 +2,9 @@
-- this will contain files later on in life. -- this will contain files later on in life.
print("hello world?") print("hello world?")
-- detect if wiremod is installed
if not istable(WireLib) then
print("[LCPU] we need wiremod..")
return
end