From 811da4d62593132d9f559eb92076000922aa4ee6 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Fri, 2 Feb 2024 09:59:19 +0200 Subject: [PATCH] Update github actions --- .github/workflows/build.yml | 6 ++++-- CMakeLists.txt | 1 - src/shell/CMakeLists.txt | 31 +++++++++++++++---------------- src/shell/Shell.cpp | 11 ++++++++++- src/shell/main.cpp | 3 +-- 5 files changed, 30 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf92f68..d3bfc31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: build: runs-on: ${{ matrix.os }} - name: "${{ matrix.cpp_compiler }}-${{ matrix.os }}-${{ matrix.build_type }}" + name: "${{ matrix.os }}(${{ matrix.build_type }}, LLVM: ${{ matrix.llvm_backend }})" strategy: # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. @@ -29,8 +29,9 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest] + os: ubuntu-latest build_type: [RelWithDebInfo] + llvm_backend: [ON,OFF] steps: - uses: actions/checkout@v3 @@ -90,6 +91,7 @@ jobs: -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_C_COMPILER=clang-18 -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DENDO_USE_LLVM=${{ matrix.llvm_backend }} -GNinja -S ${{ github.workspace }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fe4535..9b5e01c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - option(ENDO_USE_LLVM "Use llvm as a backend for the shell" ON) if(NOT DEFINED ENDO_TRACE_VM) diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index 40eebc5..7c25b0c 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -15,7 +15,6 @@ target_sources(Shell ASTPrinter.cpp IRGenerator.cpp Parser.cpp - llvm_executor.cpp ) find_package(Threads REQUIRED) @@ -35,24 +34,24 @@ set(shell_libs if(ENDO_USE_LLVM) - find_package(LLVM) - if(LLVM_FOUND) + find_package(LLVM REQUIRED) + message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") + message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") + include("${LLVM_DIR}/AddLLVM.cmake") - message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") - message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") - include("${LLVM_DIR}/AddLLVM.cmake") - - include_directories(${LLVM_INCLUDE_DIRS}) - add_definitions(${LLVM_DEFINITIONS}) - llvm_map_components_to_libnames(llvm_libs analysis core executionengine instcombine object orcjit runtimedyld scalaropts support native) + include_directories(${LLVM_INCLUDE_DIRS}) + add_definitions(${LLVM_DEFINITIONS}) + llvm_map_components_to_libnames(llvm_libs analysis core executionengine instcombine object orcjit runtimedyld scalaropts support native) # Link against LLVM libraries - set(shell_libs - ${shell_libs} - ${llvm_libs}) + set(shell_libs + ${shell_libs} + ${llvm_libs}) - target_compile_definitions(Shell PUBLIC ENDO_USE_LLVM) - endif() -else() + target_sources(Shell + PUBLIC + FILE_SET CXX_MODULES FILES + llvm_executor.cpp) + target_compile_definitions(Shell PUBLIC ENDO_USE_LLVM) endif() diff --git a/src/shell/Shell.cpp b/src/shell/Shell.cpp index d71fbd9..628ff89 100644 --- a/src/shell/Shell.cpp +++ b/src/shell/Shell.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 module; #include + #include #include @@ -21,7 +22,9 @@ import IRGenerator; import Parser; import CoreVM; +#if defined(ENDO_USE_LLVM) import LLVMBackend; +#endif export module Shell; @@ -171,7 +174,13 @@ export class SystemEnvironment: public Environment export class Shell final: public CoreVM::Runtime { public: - Shell(): Shell(RealTTY::instance(), SystemEnvironment::instance()) {} + Shell(): Shell(RealTTY::instance(), SystemEnvironment::instance()) + { + +#if defined(ENDO_USE_LLVM) + LLVMBackend::init(); +#endif + } Shell(TTY& tty, Environment& env): _env { env }, _tty { tty } { diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 545a3d8..2b8eba5 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -4,7 +4,7 @@ using namespace std::string_literals; import Shell; -import LLVMBackend; + std::string_view getEnvironment(std::string_view name, std::string_view defaultValue) { @@ -18,7 +18,6 @@ int main(int argc, char const* argv[]) setsid(); - LLVMBackend::init(); if (argc == 2) // This here only exists for early-development debugging purposes.