diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 62cfdd945..68db5d1cf 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -40,6 +40,56 @@ jobs: echo "DOCKER_CI_IMAGE $DOCKER_CI_IMAGE" echo "docker-image=$DOCKER_CI_IMAGE" >> "$GITHUB_OUTPUT" + lint: + needs: build-image + timeout-minutes: 120 + strategy: + fail-fast: false + name: Lint (clang-tidy) + runs-on: ubuntu-latest + container: + image: ${{ needs.build-image.outputs.docker-image }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT" + echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT" + echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT" + + - name: Git safe dir + run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }} + + - name: Configure CMake + shell: bash + run: | + source env/activate + cmake -G Ninja \ + -B ${{ steps.strings.outputs.build-output-dir }} \ + -DCMAKE_CXX_COMPILER=clang++-17 \ + -DCMAKE_C_COMPILER=clang-17 \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.install-output-dir }} \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DTTMLIR_ENABLE_RUNTIME=ON \ + -DTTMLIR_ENABLE_RUNTIME_TESTS=ON \ + -DTTMLIR_ENABLE_STABLEHLO=ON \ + -DTTMLIR_ENABLE_OP_MODEL=ON \ + -S ${{ steps.strings.outputs.work-dir }} + + - name: Lint + id: lint + shell: bash + run: | + source env/activate + cmake --build ${{ steps.strings.outputs.build-output-dir }} -- clang-tidy + build-ttmlir: needs: build-image timeout-minutes: 120 @@ -119,14 +169,6 @@ jobs: cmake --build ${{ steps.strings.outputs.build-output-dir }} cmake --install ${{ steps.strings.outputs.build-output-dir }} --component Test - - name: Lint - id: lint - shell: bash - if: matrix.build.enable_perf == 'OFF' - run: | - source env/activate - cmake --build ${{ steps.strings.outputs.build-output-dir }} -- clang-tidy - - name: Unique-ify clang-tidy fixes shell: bash if: failure() && steps.lint.outcome == 'failure' diff --git a/cmake/modules/LintTools.cmake b/cmake/modules/LintTools.cmake index 28b4b2809..7e5604011 100644 --- a/cmake/modules/LintTools.cmake +++ b/cmake/modules/LintTools.cmake @@ -1,4 +1,12 @@ # clang-tidy setup add_custom_target(clang-tidy-filter-out-external-srcs COMMAND python3 ${TTMLIR_SOURCE_DIR}/tools/scripts/filter-compile-commands.py ${TTMLIR_BINARY_DIR}/compile_commands.json "${TTMLIR_SOURCE_DIR}") -add_custom_target(clang-tidy COMMAND run-clang-tidy.py -p ${PROJECT_BINARY_DIR} -export-fixes clang-tidy-fixes.yaml -warnings-as-errors '*' -extra-arg-before=-DDISABLE_STATIC_ASSERT_TESTS -extra-arg-before=-D__cpp_structured_bindings=202400 DEPENDS clang-tidy-filter-out-external-srcs) +add_custom_target(clang-tidy COMMAND run-clang-tidy.py -p ${PROJECT_BINARY_DIR} -export-fixes clang-tidy-fixes.yaml -warnings-as-errors '*' -extra-arg-before=-DDISABLE_STATIC_ASSERT_TESTS -extra-arg-before=-D__cpp_structured_bindings=202400 + DEPENDS + clang-tidy-filter-out-external-srcs + mlir-headers + mlir-generic-headers + tt-metal-download + tt-metal-configure + FBS_GENERATION +) add_custom_target(clang-format COMMAND git-clang-format) diff --git a/include/ttmlir/Conversion/CMakeLists.txt b/include/ttmlir/Conversion/CMakeLists.txt index 891fa5608..ba6b26783 100644 --- a/include/ttmlir/Conversion/CMakeLists.txt +++ b/include/ttmlir/Conversion/CMakeLists.txt @@ -5,7 +5,9 @@ include_directories(${TTMLIR_SOURCE_DIR}/include) set(LLVM_TARGET_DEFINITIONS Passes.td) if (TTMLIR_ENABLE_STABLEHLO) mlir_tablegen(Passes.h.inc -gen-pass-decls -name TTMLIRConversion -DTTMLIR_ENABLE_STABLEHLO) +add_dependencies(mlir-headers PassesIncGen) else() mlir_tablegen(Passes.h.inc -gen-pass-decls -name TTMLIRConversion) endif() add_public_tablegen_target(TTMLIRConversionPassIncGen) +add_dependencies(mlir-headers TTMLIRConversionPassIncGen) diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index e4c17bae4..8d66b6869 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -71,6 +71,10 @@ ExternalProject_Add( BUILD_BYPRODUCTS ${TTNN_LIBRARY_PATH} ${TTMETAL_LIBRARY_PATH} ${TRACY_LIBRARY_PATH} ${DEVICE_LIBRARY_PATH} ) +ExternalProject_Add_StepTargets(tt-metal download configure) +set_target_properties(tt-metal-download PROPERTIES EXCLUDE_FROM_ALL TRUE) +set_target_properties(tt-metal-configure PROPERTIES EXCLUDE_FROM_ALL TRUE) + set_target_properties(tt-metal PROPERTIES EXCLUDE_FROM_ALL TRUE) list(APPEND library_names TTNN_LIBRARY TTMETAL_LIBRARY DEVICE_LIBRARY)