Skip to content

Commit

Permalink
Merge pull request #1 from Icohedron/master
Browse files Browse the repository at this point in the history
Update LLVM, ANTLR. Add runtime.
  • Loading branch information
kuzi117 authored Aug 14, 2020
2 parents 42d0684 + 2fe6be4 commit c51c1fb
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ find_package(Java COMPONENTS Runtime REQUIRED) # Need java to run ANTLR, but onl
include("${CMAKE_SOURCE_DIR}/cmake/get_llvm.cmake")

# Set C++ standards.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Add CXX flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
Expand Down
6 changes: 3 additions & 3 deletions cmake/get_llvm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

# Ensure we found our own specified version at 6.0.0. We don't want Ohaton's 3.x.x or another local
# Ensure we found our own specified version at 10.0.0. We don't want Ohaton's 3.x.x or another local
# build we don't know.
if(NOT ("${LLVM_VERSION_MAJOR}" EQUAL 6 AND
if(NOT ("${LLVM_VERSION_MAJOR}" EQUAL 10 AND
"${LLVM_VERSION_MINOR}" EQUAL 0 AND
"${LLVM_VERSION_PATCH}" EQUAL 1))
"${LLVM_VERSION_PATCH}" EQUAL 0))
message(FATAL_ERROR "LLVM version incompatible.")
endif()

Expand Down
9 changes: 9 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.0)
project(VCalcRuntime)

# Set a variable for the runtime include directory.
set(RUNTIME_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include")

# Build the actual runtime.
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src")

12 changes: 12 additions & 0 deletions runtime/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Gather our source files in this directory.
set(
vcalc_rt_files
"${CMAKE_CURRENT_SOURCE_DIR}/placeholder.c"
)

# Build our executable from the source files.
add_library(vcalcrt SHARED ${vcalc_rt_files})
target_include_directories(vcalcrt PUBLIC ${RUNTIME_INCLUDE})

# Symbolic link our library to the base directory so we don't have to go searching for it.
symlink_to_bin("vcalcrt")
6 changes: 6 additions & 0 deletions runtime/src/placeholder.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

// Add function named dummyPrint with signature void(int) to llvm to have this linked in.
void dummyPrint(int i) {
printf("I'm a function! %d\n", i);
}
4 changes: 2 additions & 2 deletions scripts/configureLLVM.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# hanging, linking is probably the issue).
# LLVM_ENABLE_DOXYGEN:
# Enables local docs building. Requires doxygen?
LLVM_OPTIONS="-DLLVM_BUILD_TOOLS=OFF -DLLVM_BUILD_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_OPTIMIZED_TABLEGEN=ON"
LLVM_OPTIONS="-DLLVM_BUILD_TOOLS=ON -DLLVM_BUILD_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_OPTIMIZED_TABLEGEN=ON"

# -------------------------
# STEP 1: CHOOSE PATHS.
Expand Down Expand Up @@ -102,4 +102,4 @@ if [[ "$unamestr" == 'Linux' ]]; then
USE_GOLD="-DLLVM_USE_LINKER=gold"
fi

cmake "$SRC_DIR" -DCMAKE_BUILD_TYPE="$BUILD" -DLLVM_TARGETS_TO_BUILD=X86 $USE_GOLD $USE_INSTALL "$LLVM_OPTIONS"
cmake "$SRC_DIR" -DCMAKE_BUILD_TYPE="$BUILD" -DLLVM_TARGETS_TO_BUILD=X86 $USE_GOLD $USE_INSTALL $LLVM_OPTIONS
8 changes: 6 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ target_include_directories(vcalc PUBLIC ${ANTLR_GEN_DIR})
# Ensure that the antlr4-runtime is available.
add_dependencies(vcalc antlr)

# Add the antlr runtime and parser as libraries to link.
target_link_libraries(vcalc parser antlr4-runtime)
# Find the libraries that correspond to the LLVM components
# that we wish to use
llvm_map_components_to_libnames(llvm_libs core)

# Add the LLVM, antlr runtime and parser as libraries to link.
target_link_libraries(vcalc parser antlr4-runtime ${llvm_libs})

# Symbolic link our executable to the base directory so we don't have to go searching for it.
symlink_to_bin("vcalc")
7 changes: 6 additions & 1 deletion tests/VCalcConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"testedExecutablePaths": {
"<team id>": "<path_to_vcalc_exe>"
},
"runtimes": {
"<team id>": "<path_to_libvcalcrt.so>"
},
"toolchains": {
"vcalc": [
{
Expand All @@ -21,7 +24,9 @@
"arguments": [
"$INPUT"
],
"output": "-"
"output": "-",
"usesRuntime": true,
"usesInStr": true
}
]
}
Expand Down

0 comments on commit c51c1fb

Please sign in to comment.