Skip to content

Commit

Permalink
build toolchain from CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksKnezevic committed Jan 24, 2025
1 parent ca6dee2 commit b789056
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
25 changes: 16 additions & 9 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@

set(TT_MLIR_VERSION "4d28d1522647c51da4bd026fdf3e9f9cdde07f32")

if (TOOLCHAIN STREQUAL "ON")
if (BUILD_TOOLCHAIN)
cmake_minimum_required(VERSION 3.20)
project(ttmlir-toolchain LANGUAGES CXX C)
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir)
execute_process(
COMMAND git clone --recursive https://github.com/tenstorrent/tt-mlir.git ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir
)
endif()
execute_process(
COMMAND git clone --recursive https://github.com/tenstorrent/tt-mlir.git ${PROJECT_SOURCE_DIR}/tt-mlir/src/tt-mlir
RESULT_VARIABLE result1
OUTPUT_VARIABLE output1
ERROR_VARIABLE error_output1
COMMAND /bin/bash -c "git checkout ${TT_MLIR_VERSION}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir
)
if (NOT ${result1} EQUAL 0)
message(FATAL_ERROR "Failed to clone tt-mlir: ${error_output1}")
endif()

execute_process(
COMMAND pwd
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir
)

execute_process(
COMMAND /bin/bash -c "cd ${PROJECT_SOURCE_DIR}/tt-mlir/src/tt-mlir && git checkout ${TT_MLIR_VERSION}"
COMMAND /bin/bash ../../../build_mlir_env.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir
)
else()
set(TT_RUNTIME_DEBUG OFF CACHE BOOL "Enable runtime debugging")
Expand Down
7 changes: 7 additions & 0 deletions third_party/build_mlir_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0

cmake -B env/build env
cmake --build env/build

0 comments on commit b789056

Please sign in to comment.