diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4095c2a..b6109ba 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,12 +40,6 @@ jobs: sudo apt-get update sudo apt-get install lld clang cargo - - name: Install Pulp Toolchain - run: | - mkdir ${{github.workspace}}/pulp-toolchain - wget -qO- https://github.com/pulp-platform/llvm-project/releases/download/0.12.0/riscv32-pulp-llvm-ubuntu2004-0.12.0.tar.gz \ - | tar --strip-components=1 -xzv -C ${{github.workspace}}/pulp-toolchain - - name: Install Quidditch Toolchain run: | mkdir ./toolchain @@ -60,7 +54,6 @@ jobs: -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DPULP_CLANG_PATH=${{github.workspace}}/pulp-toolchain/bin/clang \ -DQUIDDITCH_TOOLCHAIN_FILE=${{github.workspace}}/toolchain/ToolchainFile.cmake \ -DOVERRIDE_VENV=ON \ -S ${{github.workspace}} diff --git a/.gitmodules b/.gitmodules index 0b60867..a711236 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,3 @@ [submodule "xdsl"] path = xdsl url = https://github.com/xdslproject/xdsl -[submodule "bender"] - path = bender - url = https://github.com/pulp-platform/bender diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c8b018..873d700 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.21) project(Quidditch C CXX) set(QUIDDITCH_TOOLCHAIN_FILE "" CACHE STRING "Path to the quidditch toolchain's toolchain file") -set(PULP_CLANG_PATH "" CACHE STRING "Path to clang within the pulp toolchain") set(OVERRIDE_VENV OFF CACHE BOOL "") +cmake_path(REMOVE_FILENAME QUIDDITCH_TOOLCHAIN_FILE OUTPUT_VARIABLE QUIDDITCH_TOOLCHAIN_ROOT) if (NOT DEFINED ENV{VIRTUAL_ENV} AND NOT ${OVERRIDE_VENV}) message(FATAL_ERROR [[ @@ -39,7 +39,7 @@ append_if_defined(host_cmake_args CMAKE_CXX_COMPILER_LAUNCHER) ExternalProject_Add(codegen CMAKE_ARGS -DIREE_ENABLE_LLD=ON - -DPULP_CLANG_PATH=${PULP_CLANG_PATH} + -DQUIDDITCH_TOOLCHAIN_ROOT=${QUIDDITCH_TOOLCHAIN_ROOT} ${host_cmake_args} SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/codegen BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/codegen @@ -53,21 +53,6 @@ ExternalProject_Add(codegen USES_TERMINAL_TEST ON ) -ExternalProject_Add(bender - SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/bender - CONFIGURE_COMMAND "" - BUILD_COMMAND - ${CARGO_PATH} build - --release - --target-dir=${CMAKE_CURRENT_BINARY_DIR}/bender - --manifest-path=${CMAKE_CURRENT_LIST_DIR}/bender/Cargo.toml - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bender - INSTALL_COMMAND "" - USES_TERMINAL_CONFIGURE ON - USES_TERMINAL_BUILD ON - USES_TERMINAL_TEST ON -) - set(runtime_cmake_args) append_if_defined(runtime_cmake_args CMAKE_BUILD_TYPE) append_if_defined(runtime_cmake_args CMAKE_C_COMPILER_LAUNCHER) @@ -75,9 +60,7 @@ append_if_defined(runtime_cmake_args CMAKE_CXX_COMPILER_LAUNCHER) ExternalProject_Add(runtime CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${QUIDDITCH_TOOLCHAIN_FILE} - -DPULP_CLANG_PATH=${PULP_CLANG_PATH} -DQUIDDITCH_CODEGEN_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}/codegen - -DBENDER_PATH=${CMAKE_CURRENT_BINARY_DIR}/bender/release/bender ${runtime_cmake_args} SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/runtime BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/runtime @@ -87,7 +70,7 @@ ExternalProject_Add(runtime USES_TERMINAL_BUILD ON USES_TERMINAL_TEST ON ) -add_dependencies(runtime codegen bender) +add_dependencies(runtime codegen) enable_testing() include(ProcessorCount) diff --git a/README.md b/README.md index e4d0bce..83ea0c9 100644 --- a/README.md +++ b/README.md @@ -7,32 +7,24 @@ Only linux is currently supported as a build environment Building Quidditch requires the following tools to be installed: * CMake 3.21 or newer * A C++17 compiler -* Cargo * Python 3 * Ninja (ideally) -* the Quidditch toolchain -* the Pulp toolchain +* Docker to install the Quidditch toolchain. See [the toolchain directory for more details](runtime/toolchain/README.md) `docker` is required to install the Quidditch toolchain using: ```shell -docker run --rm ghcr.io/opencompl/Quidditch/toolchain:main tar -cC /opt/quidditch-toolchain .\ - | tar -xC $INSTALL_DIR/quidditch-toolchain -``` -See [the toolchain directory for more details](runtime/toolchain/README.md). -To get the pulp toolchain, you can run: -```shell -mkdir $INSTALL_DIR/pulp-toolchain -wget -qO- https://github.com/pulp-platform/llvm-project/releases/download/0.12.0/riscv32-pulp-llvm-ubuntu2004-0.12.0.tar.gz \ -| tar --strip-components=1 -xzv -C $INSTALL_DIR/pulp-toolchain ``` -or similar if your system is binary compatible with Ubuntu 22.04. +See [the toolchain directory for more details](runtime/toolchain/README.md). Afterward, you can perform a mega build using: ```shell git clone --recursive https://github.com/opencompl/quidditch cd quidditch +docker run --rm ghcr.io/opencompl/Quidditch/toolchain:main tar -cC /opt/quidditch-toolchain .\ + | tar -xC ./toolchain + python -m venv venv source ./venv/bin/activate @@ -44,9 +36,8 @@ cmake .. -GNinja \ # Optional for improved caching, requires ccache to be installed. # -DCMAKE_C_COMPILER_LAUNCHER=ccache \ # -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DPULP_CLANG_PATH=$INSTALL_DIR/pulp-toolchain/bin/clang \ - -DQUIDDITCH_TOOLCHAIN_FILE=$INSTALL_DIR/quidditch-toolchain/ToolchainFile.cmake - + -DQUIDDITCH_TOOLCHAIN_FILE=../toolchain/ToolchainFile.cmake + # Build and Test everything. cmake --build . --target test ``` diff --git a/bender b/bender deleted file mode 160000 index 818a779..0000000 --- a/bender +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 818a779933f3f735f99f4868feadcbfad886bc4b diff --git a/codegen/CMakeLists.txt b/codegen/CMakeLists.txt index b6e64f3..aa78eb9 100644 --- a/codegen/CMakeLists.txt +++ b/codegen/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.21) project(QuidditchCompiler LANGUAGES CXX C) set(IREE_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../iree" CACHE STRING "IREE source code path") +set(QUIDDITCH_TOOLCHAIN_ROOT "" CACHE STRING "Path to the Quidditch toolchain") add_subdirectory(iree-configuration) diff --git a/codegen/compiler/src/Quidditch/QuidditchTarget.cpp b/codegen/compiler/src/Quidditch/QuidditchTarget.cpp index 2819596..0cb633e 100644 --- a/codegen/compiler/src/Quidditch/QuidditchTarget.cpp +++ b/codegen/compiler/src/Quidditch/QuidditchTarget.cpp @@ -60,7 +60,7 @@ class QuidditchTargetDevice final : public IREE::HAL::TargetDevice { struct QuidditchTargetOptions { std::string staticLibraryOutputPath; std::string xDSLOptPath; - std::string pulpClangPath; + std::string toolChainRoot; void bindOptions(OptionsBinder &binder) { LLVMInitializeRISCVTarget(); @@ -83,10 +83,9 @@ struct QuidditchTargetOptions { llvm::cl::desc("Path to the 'xdsl-opt' executable " "to use for kernel compilation.")); binder.opt( - "iree-quidditch-pulp-clang-path", pulpClangPath, - llvm::cl::cat(category), - llvm::cl::desc("Path to the 'clang' executable " - "that is part of the pulp toolchain.")); + "iree-quidditch-toolchain-root", toolChainRoot, llvm::cl::cat(category), + llvm::cl::desc("Path to the root directory of the Quidditch toolchain " + "(containing the toolchain file)")); } }; @@ -179,11 +178,11 @@ class QuidditchTargetBackend final : public IREE::HAL::TargetBackend { auto &objectFile = objectFiles.emplace_back( IREE::HAL::Artifact::createTemporary("xdsl-out", "o")); - ret = llvm::sys::ExecuteAndWait(targetOptions.pulpClangPath, - {targetOptions.pulpClangPath, "-c", - stdoutFile.str(), "-o", objectFile.path, - "-menable-experimental-extensions", - "-mcpu=snitch", "-mabi=ilp32d"}); + ret = llvm::sys::ExecuteAndWait( + targetOptions.toolChainRoot + "/bin/pulp-as", + {targetOptions.toolChainRoot + "/bin/pulp-as", "--filetype=obj", + "--target-abi=ilp32d", stdoutFile.str(), "-o", objectFile.path, + "--mcpu=snitch", "-g"}); if (ret != 0) return failure(); @@ -375,8 +374,7 @@ class QuidditchTargetBackend final : public IREE::HAL::TargetBackend { objectFiles.push_back(std::move(*objectFileOrFailure)); - SmallVector arguments = { - targetOptions.pulpClangPath, "-fuse-ld=lld", "-nostartfiles", "-Wl,-r"}; + SmallVector arguments = {"ld.lld", "-r"}; llvm::append_range( arguments, llvm::map_range(objectFiles, @@ -389,7 +387,8 @@ class QuidditchTargetBackend final : public IREE::HAL::TargetBackend { auto linkedObject = IREE::HAL::Artifact::createTemporary(libraryName, "o"); arguments.push_back("-o"); arguments.push_back(linkedObject.path); - int ret = llvm::sys::ExecuteAndWait(targetOptions.pulpClangPath, arguments); + int ret = llvm::sys::ExecuteAndWait( + targetOptions.toolChainRoot + "/bin/ld.lld", arguments); if (ret != 0) return failure(); diff --git a/codegen/tests/lit.cfg.py b/codegen/tests/lit.cfg.py index e42f6de..a47bef8 100644 --- a/codegen/tests/lit.cfg.py +++ b/codegen/tests/lit.cfg.py @@ -20,7 +20,7 @@ config.substitutions.append(("%PATH%", config.environment["PATH"])) config.substitutions.append(("%xdsl-opt", config.xdsl_opt)) -config.substitutions.append(("%pulp-clang", config.pulp_clang)) +config.substitutions.append(("%quidditch-toolchain-root", config.quidditch_toolchain_root)) # FileCheck -enable-var-scope is enabled by default in MLIR test # This option avoids to accidentally reuse variable across -LABEL match, diff --git a/codegen/tests/lit.site.cfg.py.in b/codegen/tests/lit.site.cfg.py.in index 3c6d420..9895a01 100644 --- a/codegen/tests/lit.site.cfg.py.in +++ b/codegen/tests/lit.site.cfg.py.in @@ -12,7 +12,7 @@ config.python_executable = "@Python3_EXECUTABLE@" config.native_target = "@LLVM_NATIVE_ARCH@" config.llvm_host_triple = '@LLVM_HOST_TRIPLE@' config.binary_dir = "@CMAKE_BINARY_DIR@" -config.pulp_clang = "@PULP_CLANG_PATH@" +config.quidditch_toolchain_root = "@QUIDDITCH_TOOLCHAIN_ROOT@" config.xdsl_opt = "@XDSL_OPT_PATH@" # Support substitution of the tools_dir with user parameters. This is diff --git a/codegen/tests/smoketest.mlir b/codegen/tests/smoketest.mlir index f89c670..2332bed 100644 --- a/codegen/tests/smoketest.mlir +++ b/codegen/tests/smoketest.mlir @@ -1,7 +1,7 @@ // RUN: iree-compile %s --iree-hal-target-backends=quidditch --iree-opt-demote-f64-to-f32=0 \ // RUN: --iree-quidditch-static-library-output-path=%t.o \ // RUN: --iree-quidditch-xdsl-opt-path=%xdsl-opt \ -// RUN: --iree-quidditch-pulp-clang-path=%pulp-clang \ +// RUN: --iree-quidditch-toolchain-root=%quidditch-toolchain-root \ // RUN: --output-format=vm-c \ // RUN: --iree-vm-target-index-bits=32 \ // RUN: -o /dev/null diff --git a/runtime/cmake/quidditch_module.cmake b/runtime/cmake/quidditch_module.cmake index fa80494..1d8048d 100644 --- a/runtime/cmake/quidditch_module.cmake +++ b/runtime/cmake/quidditch_module.cmake @@ -75,7 +75,7 @@ function(quidditch_module) list(APPEND _COMPILER_ARGS "--iree-hal-target-backends=quidditch") list(APPEND _COMPILER_ARGS "--iree-quidditch-static-library-output-path=${_O_FILE_NAME}") list(APPEND _COMPILER_ARGS "--iree-quidditch-xdsl-opt-path=${XDSL_OPT_PATH}") - list(APPEND _COMPILER_ARGS "--iree-quidditch-pulp-clang-path=${PULP_CLANG_PATH}") + list(APPEND _COMPILER_ARGS "--iree-quidditch-toolchain-root=${QUIDDITCH_TOOLCHAIN_ROOT}") endif () list(APPEND _COMPILER_ARGS "--output-format=vm-c")