fixed: llvm dependencies in sdk
This commit is contained in:
parent
9e4b0a1000
commit
6197acf3b2
|
@ -74,6 +74,7 @@ add_custom_command(OUTPUT ${YACC_GENERATED_SOURCE_FILE}
|
||||||
# Setup Glib 2.0 #
|
# Setup Glib 2.0 #
|
||||||
# ------------------------------------------------ #
|
# ------------------------------------------------ #
|
||||||
|
|
||||||
|
include(FindPkgConfig)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_search_module(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
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 #
|
# LLVM backend #
|
||||||
# ------------------------------------------------ #
|
# ------------------------------------------------ #
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
# Fetch LLVM link configuration
|
||||||
pkg_search_module(LLVM REQUIRED IMPORTED_TARGET llvm17)
|
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 #
|
# Source #
|
||||||
|
@ -90,7 +101,6 @@ pkg_search_module(LLVM REQUIRED IMPORTED_TARGET llvm17)
|
||||||
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
include_directories(${PROJECT_SOURCE_DIR}/src)
|
||||||
include_directories(PRIVATE ${GLIB_INCLUDE_DIRS})
|
include_directories(PRIVATE ${GLIB_INCLUDE_DIRS})
|
||||||
include_directories(PRIVATE ${LLVM_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCE_FILES src/*.c)
|
file(GLOB_RECURSE SOURCE_FILES src/*.c)
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ echo "+--------------------------------------+"
|
||||||
echo "| RUNNING check test |"
|
echo "| RUNNING check test |"
|
||||||
echo "+--------------------------------------+"
|
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
|
if [ ! $? -eq 0 ]; then
|
||||||
echo "===> failed to run build or checks"
|
echo "===> failed to run build or checks"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -5,7 +5,7 @@ LABEL description="base image for building the gemstone programming language com
|
||||||
LABEL website="https://github.com/Servostar/gemstone"
|
LABEL website="https://github.com/Servostar/gemstone"
|
||||||
|
|
||||||
# install dependencies
|
# 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
|
# create user for build
|
||||||
RUN adduser --disabled-password lorang
|
RUN adduser --disabled-password lorang
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <ast/ast.h>
|
||||||
#include <codegen/backend.h>
|
#include <codegen/backend.h>
|
||||||
#include <llvm-c/Core.h>
|
#include <llvm-c/Core.h>
|
||||||
#include <llvm-c/TargetMachine.h>
|
#include <llvm-c/TargetMachine.h>
|
||||||
#include <sys/log.h>
|
|
||||||
#include <ast/ast.h>
|
|
||||||
#include <llvm/backend.h>
|
#include <llvm/backend.h>
|
||||||
#include <llvm/parser.h>
|
#include <llvm/parser.h>
|
||||||
|
#include <sys/log.h>
|
||||||
|
|
||||||
Target create_native_target() {
|
Target create_native_target() {
|
||||||
DEBUG("creating native target...");
|
DEBUG("creating native target...");
|
||||||
|
@ -34,9 +34,7 @@ Target create_native_target() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
Target create_target_from_config() {
|
Target create_target_from_config() { PANIC("NOT IMPLEMENTED"); }
|
||||||
PANIC("NOT IMPLEMENTED");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void delete_string(String string) {
|
static void delete_string(String string) {
|
||||||
DEBUG("deleting string...");
|
DEBUG("deleting string...");
|
||||||
|
@ -59,9 +57,7 @@ void delete_target(Target target) {
|
||||||
delete_string(target.triple);
|
delete_string(target.triple);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum LLVMBackendError_t {
|
typedef enum LLVMBackendError_t { UnresolvedImport } LLVMBackendError;
|
||||||
UnresolvedImport
|
|
||||||
} LLVMBackendError;
|
|
||||||
|
|
||||||
static BackendError llvm_backend_codegen(const Module* unit, void** output) {
|
static BackendError llvm_backend_codegen(const Module* unit, void** output) {
|
||||||
return parse_module(unit, output);
|
return parse_module(unit, output);
|
||||||
|
@ -76,7 +72,9 @@ static BackendError llvm_backend_codegen_deinit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void llvm_backend_init() {
|
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) {
|
if (err.kind != Success) {
|
||||||
PANIC("unable to init llvm backend: %ld", err);
|
PANIC("unable to init llvm backend: %ld", err);
|
||||||
|
|
|
@ -19,6 +19,11 @@ string(STRIP "${LLVM_LIBS}" LLVM_LIBS)
|
||||||
# Link all targets to LLVM
|
# Link all targets to LLVM
|
||||||
link_libraries(${LLVM_LIBS})
|
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
|
# CTEST 1
|
||||||
# test llvm backend codegen for global variables
|
# test llvm backend codegen for global variables
|
||||||
|
|
Loading…
Reference in New Issue