fixed: llvm dependencies in sdk

This commit is contained in:
Sven Vogel 2024-05-27 21:22:06 +02:00
parent 9e4b0a1000
commit 6197acf3b2
5 changed files with 27 additions and 14 deletions

View File

@ -74,6 +74,7 @@ add_custom_command(OUTPUT ${YACC_GENERATED_SOURCE_FILE}
# Setup Glib 2.0 #
# ------------------------------------------------ #
include(FindPkgConfig)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
@ -81,8 +82,18 @@ pkg_search_module(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
# LLVM backend #
# ------------------------------------------------ #
find_package(PkgConfig REQUIRED)
pkg_search_module(LLVM REQUIRED IMPORTED_TARGET llvm17)
# Fetch LLVM link configuration
execute_process(COMMAND llvm-config --libs all
OUTPUT_VARIABLE LLVM_LIBS)
# Strip whitespace from output
string(STRIP "${LLVM_LIBS}" LLVM_LIBS)
# Link all targets to LLVM
link_libraries(${LLVM_LIBS})
execute_process(COMMAND llvm-config --includedir
OUTPUT_VARIABLE LLVM_INCLUDE_DIR)
string(STRIP "${LLVM_INCLUDE_DIR}" LLVM_INCLUDE_DIR)
include_directories(${LLVM_INCLUDE_DIR})
# ------------------------------------------------ #
# Source #
@ -90,7 +101,6 @@ pkg_search_module(LLVM REQUIRED IMPORTED_TARGET llvm17)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(PRIVATE ${GLIB_INCLUDE_DIRS})
include_directories(PRIVATE ${LLVM_INCLUDE_DIRS})
file(GLOB_RECURSE SOURCE_FILES src/*.c)

View File

@ -47,7 +47,7 @@ echo "+--------------------------------------+"
echo "| RUNNING check test |"
echo "+--------------------------------------+"
docker run servostar/gemstone:devkit-"$SDK" sh run-check-test.sh
docker run --rm --name "devkit-$SDK-check-test"- servostar/gemstone:devkit-"$SDK" sh run-check-test.sh
if [ ! $? -eq 0 ]; then
echo "===> failed to run build or checks"
exit 1

View File

@ -5,7 +5,7 @@ LABEL description="base image for building the gemstone programming language com
LABEL website="https://github.com/Servostar/gemstone"
# install dependencies
RUN apk add build-base gcc make cmake bison flex git python3 graphviz glib glib-dev llvm17-dev
RUN apk add build-base gcc make cmake bison flex git python3 graphviz glib glib-dev llvm17-libs llvm17-dev
# create user for build
RUN adduser --disabled-password lorang

View File

@ -1,12 +1,12 @@
#include <assert.h>
#include <ast/ast.h>
#include <codegen/backend.h>
#include <llvm-c/Core.h>
#include <llvm-c/TargetMachine.h>
#include <sys/log.h>
#include <ast/ast.h>
#include <llvm/backend.h>
#include <llvm/parser.h>
#include <sys/log.h>
Target create_native_target() {
DEBUG("creating native target...");
@ -34,9 +34,7 @@ Target create_native_target() {
return target;
}
Target create_target_from_config() {
PANIC("NOT IMPLEMENTED");
}
Target create_target_from_config() { PANIC("NOT IMPLEMENTED"); }
static void delete_string(String string) {
DEBUG("deleting string...");
@ -59,9 +57,7 @@ void delete_target(Target target) {
delete_string(target.triple);
}
typedef enum LLVMBackendError_t {
UnresolvedImport
} LLVMBackendError;
typedef enum LLVMBackendError_t { UnresolvedImport } LLVMBackendError;
static BackendError llvm_backend_codegen(const Module* unit, void** output) {
return parse_module(unit, output);
@ -76,7 +72,9 @@ static BackendError llvm_backend_codegen_deinit(void) {
}
void llvm_backend_init() {
BackendError err = set_backend(&llvm_backend_codegen_init, &llvm_backend_codegen_deinit, &llvm_backend_codegen, "LLVM");
BackendError err =
set_backend(&llvm_backend_codegen_init, &llvm_backend_codegen_deinit,
&llvm_backend_codegen, "LLVM");
if (err.kind != Success) {
PANIC("unable to init llvm backend: %ld", err);

View File

@ -19,6 +19,11 @@ string(STRIP "${LLVM_LIBS}" LLVM_LIBS)
# Link all targets to LLVM
link_libraries(${LLVM_LIBS})
execute_process(COMMAND llvm-config --includedir
OUTPUT_VARIABLE LLVM_INCLUDE_DIR)
string(STRIP "${LLVM_INCLUDE_DIR}" LLVM_INCLUDE_DIR)
include_directories(${LLVM_INCLUDE_DIR})
# ------------------------------------------------------- #
# CTEST 1
# test llvm backend codegen for global variables