Make LLD truly optional. (#15580)
diff --git a/build_tools/cmake/iree_llvm.cmake b/build_tools/cmake/iree_llvm.cmake
index 9eb9acf..437e3a6 100644
--- a/build_tools/cmake/iree_llvm.cmake
+++ b/build_tools/cmake/iree_llvm.cmake
@@ -150,7 +150,6 @@
# Unconditionally enable some other cheap LLVM tooling.
set(IREE_LLVM_LINK_TARGET llvm-link)
- set(IREE_LLD_TARGET lld)
# Unconditionally enable mlir.
list(APPEND LLVM_ENABLE_PROJECTS mlir)
diff --git a/compiler/src/iree/compiler/API/Internal/CMakeLists.txt b/compiler/src/iree/compiler/API/Internal/CMakeLists.txt
index 72512a2..635f865 100644
--- a/compiler/src/iree/compiler/API/Internal/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/Internal/CMakeLists.txt
@@ -116,11 +116,12 @@
# a compiler definition if not available.
macro(_add_dependent_lld_target target not_definition)
list(APPEND _lld_deps
- $<TARGET_NAME_IF_EXISTS:${target}>)
+ $<TARGET_NAME_IF_EXISTS:${target}>
+ $<IF:$<TARGET_EXISTS:${target}>,lldCommon,>
+ )
list(APPEND _lld_copts
$<IF:$<TARGET_EXISTS:${target}>,,-D${not_definition}>)
endmacro()
- list(APPEND _lld_deps lldCommon)
_add_dependent_lld_target(lldCOFF IREE_COMPILER_LLD_COFF_DISABLED)
_add_dependent_lld_target(lldELF IREE_COMPILER_LLD_ELF_DISABLED)
_add_dependent_lld_target(lldMachO IREE_COMPILER_LLD_MACHO_DISABLED)
diff --git a/compiler/src/iree/compiler/API/Internal/LLDToolEntryPoint.cpp b/compiler/src/iree/compiler/API/Internal/LLDToolEntryPoint.cpp
index d7756c0..d347dc1 100644
--- a/compiler/src/iree/compiler/API/Internal/LLDToolEntryPoint.cpp
+++ b/compiler/src/iree/compiler/API/Internal/LLDToolEntryPoint.cpp
@@ -9,7 +9,11 @@
// duplicate the flavor parsing and invoke the backend directly similar to
// what the lldMain() does.
-#ifdef IREE_COMPILER_LLD_DISABLED
+#if defined(IREE_COMPILER_LLD_DISABLED) || \
+ (defined(IREE_COMPILER_LLD_ELF_DISABLED) && \
+ defined(IREE_COMPILER_LLD_COFF_DISABLED) && \
+ defined(IREE_COMPILER_LLD_MACHO_DISABLED) && \
+ defined(IREE_COMPILER_LLD_WASM_DISABLED))
#include <stdio.h>
#include "iree/compiler/tool_entry_points_api.h"