Skip to content

Commit

Permalink
remove redundant command, add toolchain file to the toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
zero9178 committed May 9, 2024
1 parent 344e292 commit 8f73a77
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/toolchain.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Build Docker toolchain image
on:
pull_request:
push:
paths:
- runtime/toolchain/**
Expand Down Expand Up @@ -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 }}
2 changes: 0 additions & 2 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
27 changes: 0 additions & 27 deletions runtime/ToolchainFile.cmake

This file was deleted.

6 changes: 1 addition & 5 deletions runtime/toolchain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 29 additions & 1 deletion runtime/toolchain/phase1.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
]=])

0 comments on commit 8f73a77

Please sign in to comment.