Skip to content

Commit f0975f9

Browse files
authored
[AMD][Build] Fix build issue with AMD lld (#7608)
The PR triton-lang/triton#7548 requires the use of LLD as part of LLVM (as opposed to the system LDD), which causes the following error when - (1) ldd is not built, or - (2) the location of the `LLD_DIR` is not specified correctly: ``` CMake Error at third_party/amd/CMakeLists.txt:6 (find_package): Could not find a package configuration file provided by "LLD" with any of the following names: LLDConfig.cmake lld-config.cmake ``` To fix this issue, this PR made the following changes: - For (1), build lld in `scripts/build-llvm-project.sh`, which is invoked by `make dev-install-llvm`. The script was added in README in triton-lang/triton#6709, and building ldd was added in triton-lang/triton#6049. - For (2), make sure that `LLVM_BUILD_PATH` is an absolute path in Makefile, so `LLD_DIR` and `MLIR_DIR` are interpereted correctly. Otherwise CMake has hard time finding the relative location with CMakeLists.txt in a subdirectory. - Introduce `LLD_DIR` so we don't write `"${MLIR_DIR}/../lld"`.
1 parent 620c591 commit f0975f9

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ if(NOT MLIR_DIR)
9797
set(MLIR_DIR ${LLVM_LIBRARY_DIR}/cmake/mlir)
9898
endif()
9999

100+
if(NOT LLD_DIR)
101+
set(LLD_DIR ${LLVM_LIBRARY_DIR}/cmake/lld)
102+
endif()
103+
100104
# MLIR
101105
find_package(MLIR REQUIRED CONFIG PATHS ${MLIR_DIR})
102106

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PYTHON ?= python
66
BUILD_DIR := $(shell cd python; $(PYTHON) -c 'from build_helpers import get_cmake_dir; print(get_cmake_dir())')
77
TRITON_OPT := $(BUILD_DIR)/bin/triton-opt
88
PYTEST := $(PYTHON) -m pytest
9-
LLVM_BUILD_PATH ?= ".llvm-project/build"
9+
LLVM_BUILD_PATH ?= $(realpath .llvm-project/build)
1010
NUM_PROCS ?= 8
1111

1212
# Incremental builds

scripts/build-llvm-project.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
REPO_ROOT="$(git rev-parse --show-toplevel)"
44

55
LLVM_TARGETS=${LLVM_TARGETS:-Native;NVPTX;AMDGPU}
6-
LLVM_PROJECTS=${LLVM_PROJECTS:-mlir;llvm}
6+
LLVM_PROJECTS=${LLVM_PROJECTS:-mlir;llvm;lld}
77
LLVM_BUILD_TYPE=${LLVM_BUILD_TYPE:-Debug}
88
LLVM_COMMIT_HASH=${LLVM_COMMIT_HASH:-$(cat "$REPO_ROOT/cmake/llvm-hash.txt")}
99
LLVM_PROJECT_PATH=${LLVM_PROJECT_PATH:-"$REPO_ROOT/llvm-project"}

third_party/amd/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
33
add_subdirectory(include)
44
add_subdirectory(lib)
55
if(TRITON_BUILD_PYTHON_MODULE)
6-
find_package(LLD REQUIRED CONFIG PATHS "${MLIR_DIR}/../lld" NO_DEFAULT_PATH)
6+
find_package(LLD REQUIRED CONFIG PATHS "${LLD_DIR}" NO_DEFAULT_PATH)
77
include_directories(${LLD_INCLUDE_DIRS})
88
message(STATUS "Found LLD distro-package @ ${LLD_DIR} and LLD include dirs @ ${LLD_INCLUDE_DIRS}")
99
add_triton_plugin(TritonAMD ${CMAKE_CURRENT_SOURCE_DIR}/python/triton_amd.cc LINK_LIBS TritonAMDGPUToLLVM TritonAMDGPUTransforms TritonAMDGPUDialectToLLVM)

0 commit comments

Comments
 (0)