Skip to content

Commit 23987b2

Browse files
committed
[cmake] Add the option SWIFT_BUILD_RUNTIME_WITH_HOST_LIBLTO.
Currently when we build with bitcode, we use the liblto that we just built, despite the fact that we just compiled the runtime with the host clang. Really, we should be consistent. In the short term to unblock LTO (which wants to use the host liblto), provide an option to use the host liblto but leave it off so that the normal behavior is preserved.
1 parent 29ddcd8 commit 23987b2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ option(SWIFT_STDLIB_ASSERTIONS
9393
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
9494
"Use the host compiler and not the internal clang to build the swift runtime"
9595
FALSE)
96+
option(SWIFT_BUILD_RUNTIME_WITH_HOST_LIBLTO
97+
"Use the host liblto and not the internal liblto to build the swift runtime"
98+
FALSE)
9699

97100
set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
98101
"Build Swift with code coverage instrumenting enabled [FALSE, NOT-MERGED, MERGED]")

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,10 @@ function(_add_swift_library_single target name)
506506
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "IOS" OR "${SWIFTLIB_SINGLE_SDK}" STREQUAL "TVOS" OR "${SWIFTLIB_SINGLE_SDK}" STREQUAL "WATCHOS")
507507
list(APPEND SWIFTLIB_SINGLE_C_COMPILE_FLAGS "-fembed-bitcode")
508508
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-embed-bitcode")
509-
list(APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-bitcode_bundle" "-Xlinker" "-bitcode_hide_symbols" "-Xlinker" "-lto_library" "-Xlinker" "${LLVM_LIBRARY_DIR}/libLTO.dylib")
509+
list(APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-bitcode_bundle" "-Xlinker" "-bitcode_hide_symbols")
510+
if (NOT SWIFT_BUILD_RUNTIME_WITH_HOST_LIBLTO)
511+
list(APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-lto_library" "-Xlinker" "${LLVM_LIBRARY_DIR}/libLTO.dylib")
512+
endif()
510513
endif()
511514
endif()
512515

0 commit comments

Comments
 (0)