Skip to content

Commit 0cd01eb

Browse files
authored
Merge pull request swiftlang#22385 from gottesmm/pr-af26f08a0904c49030b0c365d8e3e69d15e79833
[cmake] Rather than using CMAKE_{C,CXX}_COMPILER and CMAKE_{C,CXX}_CO…
2 parents d376a0f + f13b8eb commit 0cd01eb

File tree

4 files changed

+18
-33
lines changed

4 files changed

+18
-33
lines changed

stdlib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ else()
3030
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang")
3131
endif()
3232

33-
set(CMAKE_CXX_COMPILER_ARG1 "")
34-
set(CMAKE_C_COMPILER_ARG1 "")
33+
set(CMAKE_C_COMPILER_LAUNCHER "")
34+
set(CMAKE_CXX_COMPILER_LAUNCHER "")
3535
# The sanitizers require using the same version of the compiler for
3636
# everything and there are various places where we link runtime code with
3737
# code built by the host compiler. Disable sanitizers for the runtime for

utils/build-script-impl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,21 +1551,6 @@ eval COMMON_CMAKE_OPTIONS=(${COMMON_CMAKE_OPTIONS})
15511551
eval EXTRA_CMAKE_OPTIONS=(${EXTRA_CMAKE_OPTIONS})
15521552
eval BUILD_ARGS=(${BUILD_ARGS})
15531553

1554-
if [[ -n "${DISTCC}" ]]; then
1555-
if [[ "$(uname -s)" == "Darwin" ]] ; then
1556-
# These are normally deduced by CMake, but when the compiler is set to
1557-
# distcc which is installed elsewhere, we need to set them explicitly.
1558-
COMMON_CMAKE_OPTIONS=(
1559-
"${COMMON_CMAKE_OPTIONS[@]}" "-DCMAKE_AR=$(xcrun_find_tool ar)"
1560-
"-DCMAKE_LINKER=$(xcrun_find_tool ld)"
1561-
"-DCMAKE_NM=$(xcrun_find_tool nm)"
1562-
"-DCMAKE_OBJDUMP=$(xcrun_find_tool objdump)"
1563-
"-DCMAKE_RANLIB=$(xcrun_find_tool ranlib)"
1564-
"-DCMAKE_STRIP=$(xcrun_find_tool strip)"
1565-
)
1566-
fi
1567-
fi
1568-
15691554
eval CMAKE_BUILD=("${DISTCC_PUMP}" "${CMAKE}" "--build")
15701555

15711556

utils/swift_build_support/swift_build_support/cmake.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,12 @@ def common_options(self):
104104
define("CMAKE_EXPORT_COMPILE_COMMANDS", "ON")
105105

106106
if args.distcc:
107-
define("CMAKE_C_COMPILER:PATH", toolchain.distcc)
108-
define("CMAKE_C_COMPILER_ARG1", toolchain.cc)
109-
define("CMAKE_CXX_COMPILER:PATH", toolchain.distcc)
110-
define("CMAKE_CXX_COMPILER_ARG1", toolchain.cxx)
111-
else:
112-
define("CMAKE_C_COMPILER:PATH", toolchain.cc)
113-
define("CMAKE_CXX_COMPILER:PATH", toolchain.cxx)
114-
define("CMAKE_LIBTOOL:PATH", toolchain.libtool)
107+
define("CMAKE_C_COMPILER_LAUNCHER:PATH", toolchain.distcc)
108+
define("CMAKE_CXX_COMPILER_LAUNCHER:PATH", toolchain.distcc)
109+
110+
define("CMAKE_C_COMPILER:PATH", toolchain.cc)
111+
define("CMAKE_CXX_COMPILER:PATH", toolchain.cxx)
112+
define("CMAKE_LIBTOOL:PATH", toolchain.libtool)
115113

116114
if args.cmake_generator == 'Xcode':
117115
define("CMAKE_CONFIGURATION_TYPES",

utils/swift_build_support/tests/test_cmake.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,11 @@ def test_common_options_distcc(self):
205205
self.assertEqual(
206206
list(cmake.common_options()),
207207
["-G", "Ninja",
208-
"-DCMAKE_C_COMPILER:PATH=" + self.mock_distcc_path(),
209-
"-DCMAKE_C_COMPILER_ARG1=/path/to/clang",
210-
"-DCMAKE_CXX_COMPILER:PATH=" + self.mock_distcc_path(),
211-
"-DCMAKE_CXX_COMPILER_ARG1=/path/to/clang++",
208+
"-DCMAKE_C_COMPILER_LAUNCHER:PATH=" + self.mock_distcc_path(),
209+
"-DCMAKE_CXX_COMPILER_LAUNCHER:PATH=" + self.mock_distcc_path(),
210+
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
211+
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
212+
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
212213
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
213214

214215
def test_common_options_xcode(self):
@@ -290,10 +291,11 @@ def test_common_options_full(self):
290291
["-G", "Xcode",
291292
"-DLLVM_USE_SANITIZER=Address;Undefined",
292293
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
293-
"-DCMAKE_C_COMPILER:PATH=" + self.mock_distcc_path(),
294-
"-DCMAKE_C_COMPILER_ARG1=/path/to/clang",
295-
"-DCMAKE_CXX_COMPILER:PATH=" + self.mock_distcc_path(),
296-
"-DCMAKE_CXX_COMPILER_ARG1=/path/to/clang++",
294+
"-DCMAKE_C_COMPILER_LAUNCHER:PATH=" + self.mock_distcc_path(),
295+
"-DCMAKE_CXX_COMPILER_LAUNCHER:PATH=" + self.mock_distcc_path(),
296+
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
297+
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
298+
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
297299
"-DCMAKE_CONFIGURATION_TYPES=" +
298300
"Debug;Release;MinSizeRel;RelWithDebInfo",
299301
"-DLLVM_VERSION_MAJOR:STRING=9",

0 commit comments

Comments
 (0)