Skip to content

Commit e5ce27c

Browse files
committed
[lto] Make sure to use lipo from the toolchain ${SWIFT_DARWIN_XCRUN_TOOLCHAIN}.
Otherwise, we may get lipo from the wrong toolchain and it may not be able to understand all of the architectures/bit code we are lipoing together yielding an unknown architecture error. rdar://24717107
1 parent 4613b17 commit e5ce27c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ else()
301301
endif()
302302

303303
# lipo is used to create universal binaries.
304-
find_program(LIPO "lipo")
304+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
305+
include(SwiftDarwin)
306+
find_toolchain_tool(LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
307+
endif()
305308

306309
if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "")
307310
set(SWIFT_CROSS_COMPILING FALSE)

cmake/modules/SwiftDarwin.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ function(get_default_toolchain_dir result_var_name)
1111
set("${result_var_name}" "${toolchain_dir}" PARENT_SCOPE)
1212
endfunction()
1313

14+
function(find_toolchain_tool result_var_name toolchain tool)
15+
execute_process(
16+
COMMAND "xcrun" "--toolchain" "${toolchain}" "--find" "${tool}"
17+
OUTPUT_VARIABLE tool_path
18+
OUTPUT_STRIP_TRAILING_WHITESPACE)
19+
set("${result_var_name}" "${tool_path}" PARENT_SCOPE)
20+
endfunction()

0 commit comments

Comments
 (0)