Skip to content

Commit b559855

Browse files
authored
Merge pull request #8393 from zisko/what-clang-doesnt-know-will-hurt-it
Pass CLANG_VERSION_* cmake flags to the LLVM build.
2 parents f4de4fc + 2647ca2 commit b559855

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

utils/swift_build_support/swift_build_support/cmake.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,15 @@ def common_options(self):
111111
define("CMAKE_CONFIGURATION_TYPES",
112112
"Debug;Release;MinSizeRel;RelWithDebInfo")
113113

114-
if args.clang_compiler_version:
115-
major, minor, patch, _ = args.clang_compiler_version.components
114+
if args.clang_user_visible_version:
115+
major, minor, patch, _ = args.clang_user_visible_version.components
116116
define("LLVM_VERSION_MAJOR:STRING", major)
117117
define("LLVM_VERSION_MINOR:STRING", minor)
118118
define("LLVM_VERSION_PATCH:STRING", patch)
119+
define("CLANG_VERSION_MAJOR:STRING", major)
120+
define("CLANG_VERSION_MINOR:STRING", minor)
121+
define("CLANG_VERSION_PATCH:STRING", patch)
122+
119123

120124
if args.build_ninja and args.cmake_generator == 'Ninja':
121125
define('CMAKE_MAKE_PROGRAM', toolchain.ninja)

utils/swift_build_support/tests/test_cmake.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def default_args(self):
3737
distcc=False,
3838
cmake_generator="Ninja",
3939
clang_compiler_version=None,
40+
clang_user_visible_version=None,
4041
build_jobs=8,
4142
build_args=[],
4243
verbose_build=False,
@@ -187,17 +188,33 @@ def test_common_options_xcode(self):
187188
def test_common_options_clang_compiler_version(self):
188189
args = self.default_args()
189190
args.clang_compiler_version = CompilerVersion(
190-
string_representation="3.8.0",
191-
components=("3", "8", "0", None))
191+
string_representation="999.0.999",
192+
components=("999", "0", "999", None))
192193
cmake = self.cmake(args)
193194
self.assertEqual(
194195
list(cmake.common_options()),
195196
["-G", "Ninja",
196197
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
197198
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
198-
"-DLLVM_VERSION_MAJOR:STRING=3",
199-
"-DLLVM_VERSION_MINOR:STRING=8",
199+
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
200+
201+
def test_common_options_clang_user_visible_version(self):
202+
args = self.default_args()
203+
args.clang_user_visible_version = CompilerVersion(
204+
string_representation="9.0.0",
205+
components=("9", "0", "0", None))
206+
cmake = self.cmake(args)
207+
self.assertEqual(
208+
list(cmake.common_options()),
209+
["-G", "Ninja",
210+
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
211+
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
212+
"-DLLVM_VERSION_MAJOR:STRING=9",
213+
"-DLLVM_VERSION_MINOR:STRING=0",
200214
"-DLLVM_VERSION_PATCH:STRING=0",
215+
"-DCLANG_VERSION_MAJOR:STRING=9",
216+
"-DCLANG_VERSION_MINOR:STRING=0",
217+
"-DCLANG_VERSION_PATCH:STRING=0",
201218
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
202219

203220
def test_common_options_build_ninja(self):
@@ -218,9 +235,12 @@ def test_common_options_full(self):
218235
args.export_compile_commands = True
219236
args.distcc = True
220237
args.cmake_generator = 'Xcode'
238+
args.clang_user_visible_version = CompilerVersion(
239+
string_representation="9.0.0",
240+
components=("9", "0", "0", None))
221241
args.clang_compiler_version = CompilerVersion(
222-
string_representation="3.8.0",
223-
components=("3", "8", "0", None))
242+
string_representation="999.0.900",
243+
components=("999", "0", "900", None))
224244
args.build_ninja = True
225245
cmake = self.cmake(args)
226246
self.assertEqual(
@@ -234,9 +254,12 @@ def test_common_options_full(self):
234254
"-DCMAKE_CXX_COMPILER_ARG1=/path/to/clang++",
235255
"-DCMAKE_CONFIGURATION_TYPES=" +
236256
"Debug;Release;MinSizeRel;RelWithDebInfo",
237-
"-DLLVM_VERSION_MAJOR:STRING=3",
238-
"-DLLVM_VERSION_MINOR:STRING=8",
239-
"-DLLVM_VERSION_PATCH:STRING=0"])
257+
"-DLLVM_VERSION_MAJOR:STRING=9",
258+
"-DLLVM_VERSION_MINOR:STRING=0",
259+
"-DLLVM_VERSION_PATCH:STRING=0",
260+
"-DCLANG_VERSION_MAJOR:STRING=9",
261+
"-DCLANG_VERSION_MINOR:STRING=0",
262+
"-DCLANG_VERSION_PATCH:STRING=0"])
240263
# NOTE: No "-DCMAKE_MAKE_PROGRAM=/path/to/built/ninja" because
241264
# cmake_generator is 'Xcode'
242265

0 commit comments

Comments
 (0)