Skip to content

Commit d214373

Browse files
committed
[lto] Add the option llvm-enable-lto that compiles LLVM/Clang with LTO.
If you also set swift-enable-lto to 1, then you get a swiftc that is compiled fully with LTO.
1 parent 5c35136 commit d214373

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

utils/build-script-impl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ KNOWN_SETTINGS=(
7272
swift-build-type "Debug" "the CMake build variant for Swift"
7373
swift-enable-assertions "1" "enable assertions in Swift"
7474
swift-analyze-code-coverage "not-merged" "Code coverage analysis mode for Swift (false, not-merged, merged). Defaults to false if the argument is not present, and not-merged if the argument is present without a modifier."
75-
swift-enable-lto "0" "enable LTO compilation of the Swift compiler"
75+
swift-enable-lto "0" "enable LTO compilation of just Swift."
76+
llvm-enable-lto "0" "enable LTO compilation of LLVM/Clang."
7677
swift-stdlib-build-type "Debug" "the CMake build variant for Swift"
7778
swift-stdlib-enable-assertions "1" "enable assertions in Swift"
7879
swift-stdlib-enable-resilience "0" "build the Swift stdlib and overlays with resilience enabled"
@@ -422,6 +423,16 @@ function set_deployment_target_based_options() {
422423
-DLLVM_HOST_TRIPLE:STRING="${llvm_host_triple}"
423424
-DLLVM_ENABLE_LIBCXX:BOOL=TRUE
424425
)
426+
if [[ -n "${LLVM_ENABLE_LTO}" ]]; then
427+
llvm_cmake_options=(
428+
"${llvm_cmake_options[@]}"
429+
"-DCMAKE_C_FLAGS=-O2 -flto -gline-tables-only -fno-stack-protector "
430+
"-DCMAKE_CXX_FLAGS=-O2 -flto -gline-tables-only -fno-stack-protector "
431+
"-DCMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -flto -gline-tables-only -fno-stack-protector "
432+
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -flto -gline-tables-only -fno-stack-protector "
433+
"-DLLVM_PARALLEL_LINK_JOBS=5"
434+
)
435+
fi
425436
swift_cmake_options=(
426437
"${swift_cmake_options[@]}"
427438
-DSWIFT_DARWIN_DEPLOYMENT_VERSION_OSX="${DARWIN_DEPLOYMENT_VERSION_OSX}"

0 commit comments

Comments
 (0)