File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,14 @@ option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
180
180
"Generate .swiftinterface files alongside .swiftmodule files"
181
181
TRUE )
182
182
183
+ # Allow building Swift with Clang's Profile Guided Optimization
184
+ if (SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE} )
185
+ if (NOT CMAKE_C_COMPILER_ID MATCHES Clang )
186
+ message (FATAL_ERROR "SWIFT_PROFDATA_FILE can only be specified when compiling with clang" )
187
+ endif ()
188
+ add_definitions ("-fprofile-instr-use=${SWIFT_PROFDATA_FILE} " )
189
+ endif ()
190
+
183
191
#
184
192
# User-configurable Android specific options.
185
193
#
Original file line number Diff line number Diff line change @@ -266,7 +266,8 @@ KNOWN_SETTINGS=(
266
266
user-config-args " " " **Renamed to --extra-cmake-options**: User-supplied arguments to cmake when used to do configuration."
267
267
only-execute " all" " Only execute the named action (see implementation)"
268
268
llvm-lit-args " " " If set, override the lit args passed to LLVM"
269
- clang-profile-instr-use " " " If set, profile file to use for clang PGO"
269
+ clang-profile-instr-use " " " If set, profile file to use for clang PGO while building llvm/clang"
270
+ swift-profile-instr-use " " " If set, profile file to use for clang PGO while building swift"
270
271
coverage-db " " " If set, coverage database to use when prioritizing testing"
271
272
build-toolchain-only " " " If set, only build the necessary tools to build an external toolchain"
272
273
skip-local-host-install " " " If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
@@ -759,6 +760,11 @@ function set_build_options_for_host() {
759
760
)
760
761
fi
761
762
763
+ if [[ " ${SWIFT_PROFILE_INSTR_USE} " ]]; then
764
+ swift_cmake_options+=(
765
+ -DSWIFT_PROFDATA_FILE=" ${SWIFT_PROFILE_INSTR_USE} "
766
+ )
767
+ fi
762
768
swift_cmake_options+=(
763
769
-DCOVERAGE_DB=" ${COVERAGE_DB} "
764
770
)
You can’t perform that action at this time.
0 commit comments