Skip to content

Commit 2285937

Browse files
committed
build: do not search for native LLVM when not building tools
The standard library does not depend on the LLVM libraries at runtime. Do not perform the search for the LLVM configuration when the tools are not being built. This is needed to permit cross-compiling the standard library standalone for android on a Linux host without building LLVM and Clang for android.
1 parent 9c8d449 commit 2285937

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,32 +62,34 @@ macro(swift_common_standalone_build_config_llvm product)
6262
set(${product}_NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
6363
endif()
6464

65-
if(CMAKE_CROSSCOMPILING)
66-
set(LLVM_NATIVE_BUILD_DIR "${LLVM_BINARY_DIR}/NATIVE")
67-
if(NOT EXISTS "${LLVM_NATIVE_BUILD_DIR}")
68-
message(FATAL_ERROR
69-
"Attempting to cross-compile swift standalone but no native LLVM build
70-
found. Please cross-compile LLVM as well.")
71-
endif()
72-
73-
if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
74-
set(HOST_EXECUTABLE_SUFFIX ".exe")
75-
endif()
76-
77-
if(NOT CMAKE_CONFIGURATION_TYPES)
78-
set(LLVM_TABLEGEN_EXE
79-
"${LLVM_NATIVE_BUILD_DIR}/bin/llvm-tblgen${HOST_EXECUTABLE_SUFFIX}")
65+
if(SWIFT_INCLUDE_TOOLS)
66+
if(CMAKE_CROSSCOMPILING)
67+
set(LLVM_NATIVE_BUILD_DIR "${LLVM_BINARY_DIR}/NATIVE")
68+
if(NOT EXISTS "${LLVM_NATIVE_BUILD_DIR}")
69+
message(FATAL_ERROR
70+
"Attempting to cross-compile swift standalone but no native LLVM build
71+
found. Please cross-compile LLVM as well.")
72+
endif()
73+
74+
if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
75+
set(HOST_EXECUTABLE_SUFFIX ".exe")
76+
endif()
77+
78+
if(NOT CMAKE_CONFIGURATION_TYPES)
79+
set(LLVM_TABLEGEN_EXE
80+
"${LLVM_NATIVE_BUILD_DIR}/bin/llvm-tblgen${HOST_EXECUTABLE_SUFFIX}")
81+
else()
82+
# NOTE: LLVM NATIVE build is always built Release, as is specified in
83+
# CrossCompile.cmake
84+
set(LLVM_TABLEGEN_EXE
85+
"${LLVM_NATIVE_BUILD_DIR}/Release/bin/llvm-tblgen${HOST_EXECUTABLE_SUFFIX}")
86+
endif()
8087
else()
81-
# NOTE: LLVM NATIVE build is always built Release, as is specified in
82-
# CrossCompile.cmake
83-
set(LLVM_TABLEGEN_EXE
84-
"${LLVM_NATIVE_BUILD_DIR}/Release/bin/llvm-tblgen${HOST_EXECUTABLE_SUFFIX}")
85-
endif()
86-
else()
87-
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" HINTS ${LLVM_TOOLS_BINARY_DIR}
88-
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
89-
if(LLVM_TABLEGEN_EXE STREQUAL "LLVM_TABLEGEN_EXE-NOTFOUND")
90-
message(FATAL_ERROR "Failed to find tablegen in ${LLVM_TOOLS_BINARY_DIR}")
88+
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" HINTS ${LLVM_TOOLS_BINARY_DIR}
89+
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
90+
if(LLVM_TABLEGEN_EXE STREQUAL "LLVM_TABLEGEN_EXE-NOTFOUND")
91+
message(FATAL_ERROR "Failed to find tablegen in ${LLVM_TOOLS_BINARY_DIR}")
92+
endif()
9193
endif()
9294
endif()
9395

0 commit comments

Comments
 (0)