Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASAN build fix #2400

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cmake/modules/TTMLIRBuildTypes.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
# Asan build type

# Find the Asan runtime library path
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so
OUTPUT_VARIABLE ASAN_LIBRARY_PATH
)
cmake_path(GET ASAN_LIBRARY_PATH PARENT_PATH ASAN_LIBRARY_DIR)

# Set the Asan flags
set(CMAKE_C_FLAGS_ASAN
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer -shared-libasan" CACHE STRING
"Flags used by the C compiler for Asan build type or configuration." FORCE)
set(CMAKE_CXX_FLAGS_ASAN
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer -shared-libasan" CACHE STRING
"Flags used by the C++ compiler for Asan build type or configuration." FORCE)
set(CMAKE_EXE_LINKER_FLAGS_ASAN
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address -shared-libasan" CACHE STRING
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address -shared-libasan -Wl,-rpath=${ASAN_LIBRARY_DIR}" CACHE STRING
"Linker flags to be used to create executables for Asan build type." FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_ASAN
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address -shared-libasan" CACHE STRING
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address -shared-libasan -Wl,-rpath=${ASAN_LIBRARY_DIR}" CACHE STRING
"Linker lags to be used to create shared libraries for Asan build type." FORCE)

# Assert build type
Expand Down
6 changes: 5 additions & 1 deletion third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ if ("${CMAKE_CXX_COMPILER_LAUNCHER}" STREQUAL "ccache")
endif()

if (TTMLIR_ENABLE_RUNTIME)
set(TTMETAL_BUILD_TYPE "Release")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(TTMETAL_BUILD_TYPE "Debug")
endif()
ExternalProject_Add(
tt-metal
PREFIX ${TTMLIR_SOURCE_DIR}/third_party/tt-metal
CMAKE_GENERATOR Ninja
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_BUILD_TYPE=${TTMETAL_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${METAL_INSTALL_PREFIX}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
Expand Down
Loading