Skip to content

Commit 2a06415

Browse files
authored
Merge pull request #7301 from erg/cmake-add-host-lipo-flag
Cmake add host lipo flag
2 parents f98c325 + 9d0d533 commit 2a06415

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,11 @@ endif()
412412
# lipo is used to create universal binaries.
413413
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
414414
include(SwiftDarwin)
415-
find_toolchain_tool(LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
415+
if(SWIFT_LIPO)
416+
set(LIPO ${SWIFT_LIPO})
417+
else()
418+
find_toolchain_tool(LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
419+
endif()
416420
endif()
417421

418422
if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "")

utils/build-script

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ class BuildScriptInvocation(object):
781781
"--toolchain-prefix",
782782
swift_build_support.targets.darwin_toolchain_prefix(
783783
args.install_prefix),
784+
"--host-lipo", toolchain.lipo,
784785
]
785786

786787
# If we have extra_swift_args, combine all of them together and then
@@ -1931,6 +1932,11 @@ iterations with -O",
19311932
"platform. Default is auto detected.",
19321933
type=arguments.type.executable,
19331934
metavar="PATH")
1935+
parser.add_argument(
1936+
"--host-lipo",
1937+
help="the absolute path to lipo. Default is auto detected.",
1938+
type=arguments.type.executable,
1939+
metavar="PATH")
19341940
parser.add_argument(
19351941
"--distcc",
19361942
help="use distcc in pump mode",
@@ -2108,6 +2114,8 @@ iterations with -O",
21082114
toolchain.cc = args.host_cc
21092115
if args.host_cxx is not None:
21102116
toolchain.cxx = args.host_cxx
2117+
if args.host_lipo is not None:
2118+
toolchain.lipo = args.host_lipo
21112119
if args.cmake is not None:
21122120
toolchain.cmake = args.cmake
21132121

utils/build-script-impl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ KNOWN_SETTINGS=(
4747
build-dir "" "out-of-tree build directory; default is in-tree. **This argument is required**"
4848
host-cc "" "the path to CC, the 'clang' compiler for the host platform. **This argument is required**"
4949
host-cxx "" "the path to CXX, the 'clang++' compiler for the host platform. **This argument is required**"
50+
host-lipo "" "the path to lipo for creating universal binaries on Darwin"
5051
darwin-xcrun-toolchain "default" "the name of the toolchain to use on Darwin"
5152
ninja-bin "" "the path to Ninja tool"
5253
cmark-build-type "Debug" "the CMake build variant for CommonMark (Debug, RelWithDebInfo, Release, MinSizeRel). Defaults to Debug."
@@ -2120,6 +2121,13 @@ for host in "${ALL_HOSTS[@]}"; do
21202121
)
21212122
fi
21222123

2124+
if [ "${HOST_LIPO}" ] ; then
2125+
cmake_options=(
2126+
"${cmake_options[@]}"
2127+
-DSWIFT_LIPO:PATH="${HOST_LIPO}"
2128+
)
2129+
fi
2130+
21232131
cmake_options=(
21242132
"${cmake_options[@]}"
21252133
-DCMAKE_C_FLAGS="$(swift_c_flags ${host})"
@@ -3384,7 +3392,13 @@ if [[ ${#LIPO_SRC_DIRS[@]} -gt 0 ]]; then
33843392

33853393
echo "--- Merging and running lipo ---"
33863394

3387-
call "${SWIFT_SOURCE_DIR}"/utils/recursive-lipo --lipo=$(xcrun_find_tool lipo) --copy-subdirs="$(get_host_install_prefix ${host})lib/swift $(get_host_install_prefix ${host})lib/swift_static" --destination="$(get_host_install_destdir ${mergedHost})" ${LIPO_SRC_DIRS[@]}
3395+
# Allow passing lipo with --host-lipo
3396+
if [[ -z "${HOST_LIPO}" ]] ; then
3397+
LIPO_PATH=$(xcrun_find_tool lipo)
3398+
else
3399+
LIPO_PATH="${HOST_LIPO}"
3400+
fi
3401+
call "${SWIFT_SOURCE_DIR}"/utils/recursive-lipo --lipo=${LIPO_PATH} --copy-subdirs="$(get_host_install_prefix ${host})lib/swift $(get_host_install_prefix ${host})lib/swift_static" --destination="$(get_host_install_destdir ${mergedHost})" ${LIPO_SRC_DIRS[@]}
33883402

33893403
# Build and test the lipo-ed package.
33903404
build_and_test_installable_package ${mergedHost}

utils/swift_build_support/swift_build_support/toolchain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def _getter(self):
5151
_register("distcc_pump", "distcc-pump", "pump")
5252
_register("llvm_profdata", "llvm-profdata")
5353
_register("llvm_cov", "llvm-cov")
54+
_register("lipo", "lipo")
5455

5556

5657
class Darwin(Toolchain):

0 commit comments

Comments
 (0)