diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a10eb03..d93ed97 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -127,8 +127,7 @@ jobs: run: | cmake -GNinja -Bquidditch-runtime-build \ -DQUIDDITCH_CODEGEN_BUILD_DIR=${{github.workspace}}/quidditch-compiler-build \ - -DQUIDDITCH_TOOLCHAIN_ROOT=${{github.workspace}}/toolchain \ - -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/runtime/ToolchainFile.cmake + -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/toolchain/ToolchainFile.cmake -S ${{github.workspace}}/runtime - name: Build diff --git a/.github/workflows/toolchain.yaml b/.github/workflows/toolchain.yaml index 652f48f..5da6a01 100644 --- a/.github/workflows/toolchain.yaml +++ b/.github/workflows/toolchain.yaml @@ -1,5 +1,6 @@ name: Build Docker toolchain image on: + pull_request: push: paths: - runtime/toolchain/** @@ -41,4 +42,4 @@ jobs: context: ${{github.workspace}}/runtime/toolchain/ file: ${{github.workspace}}/runtime/toolchain/Dockerfile push: true - tags: ghcr.io/opencompl/quidditch/toolchain:${{ github.ref_name }} + tags: ghcr.io/opencompl/quidditch/toolchain:${{ github.head_ref || github.ref_name }} diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index aa4884e..db5d042 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 3.21) -set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/ToolchainFile.cmake") - project(QuidditchRuntime LANGUAGES C ASM) set(IREE_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../iree" CACHE STRING "IREE source code path") diff --git a/runtime/ToolchainFile.cmake b/runtime/ToolchainFile.cmake deleted file mode 100644 index b32745c..0000000 --- a/runtime/ToolchainFile.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Many IDEs set this for configuring the toolchain. If present, use it as the -# default value inferred for the pulp toolchain. -set(normal_var "${CMAKE_C_COMPILER}") -cmake_path(GET normal_var PARENT_PATH quidditch_toolchain_root_default) -cmake_path(GET quidditch_toolchain_root_default PARENT_PATH quidditch_toolchain_root_default) - -set(QUIDDITCH_TOOLCHAIN_ROOT ${quidditch_toolchain_root_default} CACHE PATH "") - -# Without that flag CMake is not able to pass test compilation check -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE INTERNAL "") - -set(CMAKE_SYSTEM_NAME Generic CACHE INTERNAL "") -set(CMAKE_SYSTEM_PROCESSOR riscv32 CACHE INTERNAL "") - -set(CMAKE_AR ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-ar${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") -set(CMAKE_ASM_COMPILER ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/clang${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") -set(CMAKE_C_COMPILER ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/clang${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") -set(CMAKE_CXX_COMPILER ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") -set(CMAKE_OBJCOPY ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") -set(CMAKE_RANLIB ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") -set(CMAKE_SIZE ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-size${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") -set(CMAKE_STRIP ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-strip${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") -set(CMAKE_CROSSCOMPILING_EMULATOR ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/snitch_cluster.vlt CACHE INTERNAL "") - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/runtime/toolchain/Dockerfile b/runtime/toolchain/Dockerfile index a2e332a..3c5c3bd 100644 --- a/runtime/toolchain/Dockerfile +++ b/runtime/toolchain/Dockerfile @@ -105,14 +105,10 @@ RUN cd ./snitch_cluster/target/snitch_cluster && \ RUN mkdir -p $INSTALL_DIR/quidditch-toolchain/bin/ RUN cp ./snitch_cluster/target/snitch_cluster/bin/snitch_cluster.vlt $INSTALL_DIR/quidditch-toolchain/bin/ RUN strip $INSTALL_DIR/quidditch-toolchain/bin/snitch_cluster.vlt -RUN rm -rf ./snitch_cluster/target/snitch_cluster/bin \ - ./snitch_cluster/target/snitch_cluster/generated \ - ./snitch_cluster/target/snitch_cluster/work-vlt \ - /ccache FROM alpine:3.18 ARG INSTALL_DIR COPY --from=toolchain-build $INSTALL_DIR/quidditch-toolchain $INSTALL_DIR/quidditch-toolchain -COPY --from=verilator-build $INSTALL_DIR/quidditch-toolchain/bin/snitch_cluster.vlt $INSTALL_DIR/quidditch-toolchain +COPY --from=verilator-build $INSTALL_DIR/quidditch-toolchain/bin/snitch_cluster.vlt $INSTALL_DIR/quidditch-toolchain/bin diff --git a/runtime/toolchain/phase1.cmake b/runtime/toolchain/phase1.cmake index 442271b..f1be9ed 100644 --- a/runtime/toolchain/phase1.cmake +++ b/runtime/toolchain/phase1.cmake @@ -24,7 +24,7 @@ set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin) file(WRITE ${CMAKE_INSTALL_PREFIX}/bin/riscv32-unknown-unknown-elf.cfg [=[ --march=rv32imafd +-march=rv32imafdzfh -mabi=ilp32d -mcmodel=medany -static @@ -46,3 +46,31 @@ file(WRITE ${CMAKE_INSTALL_PREFIX}/bin/clang++.cfg [=[ -lc++ -lc++abi ]=]) +file(WRITE ${CMAKE_INSTALL_PREFIX}/bin/clang++.cfg [=[ +-nostdlib++ +-lc++ +-lc++abi +]=]) +file(WRITE ${CMAKE_INSTALL_PREFIX}/ToolchainFile.cmake [=[ +set(QUIDDITCH_TOOLCHAIN_ROOT ${CMAKE_CURRENT_LIST_DIR}) + +# Without that flag CMake is not able to pass test compilation check +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE INTERNAL "") + +set(CMAKE_SYSTEM_NAME Generic CACHE INTERNAL "") +set(CMAKE_SYSTEM_PROCESSOR riscv32 CACHE INTERNAL "") + +set(CMAKE_AR ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-ar${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_ASM_COMPILER ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/clang${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_C_COMPILER ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/clang${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_CXX_COMPILER ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_OBJCOPY ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_RANLIB ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_SIZE ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-size${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_STRIP ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/llvm-strip${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_CROSSCOMPILING_EMULATOR ${QUIDDITCH_TOOLCHAIN_ROOT}/bin/snitch_cluster.vlt CACHE INTERNAL "") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +]=])