Index: clang/CMakeLists.txt =================================================================== --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -866,6 +866,24 @@ llvm_distribution_add_targets() endif() +# add LLVM_TOOLS_BINARY_DIR to Defines to make llc, llvm-link and opt available +# for HIP toolchain +if(DEFINED LLVM_TOOLS_BINARY_DIR) + add_definitions( -DLLVM_TOOLS_BINARY_DIR="${LLVM_TOOLS_BINARY_DIR} " ) + message(STATUS "found llvm executable dir: ${LLVM_TOOLS_BINARY_DIR}") +endif() + +# add LLD_BINARY_DIR to Defines to make lld available for HIP toolchain +find_program(LLD_BINARY NAMES lld) +if(NOT LLD_BINARY MATCHES "-NOTFOUND" AND NOT DEFINED LLD_BINARY_DIR) + message(STATUS "found lld executable: ${LLD_BINARY}") + get_filename_component(LLD_BINARY_DIR ${LLD_BINARY} DIRECTORY) +endif() +if(DEFINED LLD_BINARY) + add_definitions( -DLLD_BINARY_DIR="${LLD_BINARY_DIR} " ) +endif() + + configure_file( ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake ${CLANG_BINARY_DIR}/include/clang/Config/config.h) Index: clang/lib/Driver/ToolChains/HIP.cpp =================================================================== --- clang/lib/Driver/ToolChains/HIP.cpp +++ clang/lib/Driver/ToolChains/HIP.cpp @@ -277,6 +277,16 @@ // Lookup binaries into the driver directory, this is used to // discover the clang-offload-bundler executable. getProgramPaths().push_back(getDriver().Dir); + +// add llvm binaries in case they are not in the driver directory +#if defined(LLVM_TOOLS_BINARY_DIR) + getProgramPaths().push_back(LLVM_TOOLS_BINARY_DIR); +#endif + +// add lld binary in case they are not in the driver directory +#if defined(LLD_BINARY_DIR) + getProgramPaths().push_back(LLD_BINARY_DIR); +#endif } void HIPToolChain::addClangTargetOptions(