Skip to content

Pass CLANG_VERSION_* cmake flags to the LLVM build. #8393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions utils/swift_build_support/swift_build_support/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,15 @@ def common_options(self):
define("CMAKE_CONFIGURATION_TYPES",
"Debug;Release;MinSizeRel;RelWithDebInfo")

if args.clang_compiler_version:
major, minor, patch, _ = args.clang_compiler_version.components
if args.clang_user_visible_version:
major, minor, patch, _ = args.clang_user_visible_version.components
define("LLVM_VERSION_MAJOR:STRING", major)
define("LLVM_VERSION_MINOR:STRING", minor)
define("LLVM_VERSION_PATCH:STRING", patch)
define("CLANG_VERSION_MAJOR:STRING", major)
define("CLANG_VERSION_MINOR:STRING", minor)
define("CLANG_VERSION_PATCH:STRING", patch)


if args.build_ninja and args.cmake_generator == 'Ninja':
define('CMAKE_MAKE_PROGRAM', toolchain.ninja)
Expand Down
41 changes: 32 additions & 9 deletions utils/swift_build_support/tests/test_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def default_args(self):
distcc=False,
cmake_generator="Ninja",
clang_compiler_version=None,
clang_user_visible_version=None,
build_jobs=8,
build_args=[],
verbose_build=False,
Expand Down Expand Up @@ -187,17 +188,33 @@ def test_common_options_xcode(self):
def test_common_options_clang_compiler_version(self):
args = self.default_args()
args.clang_compiler_version = CompilerVersion(
string_representation="3.8.0",
components=("3", "8", "0", None))
string_representation="999.0.999",
components=("999", "0", "999", None))
cmake = self.cmake(args)
self.assertEqual(
list(cmake.common_options()),
["-G", "Ninja",
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
"-DLLVM_VERSION_MAJOR:STRING=3",
"-DLLVM_VERSION_MINOR:STRING=8",
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])

def test_common_options_clang_user_visible_version(self):
args = self.default_args()
args.clang_user_visible_version = CompilerVersion(
string_representation="9.0.0",
components=("9", "0", "0", None))
cmake = self.cmake(args)
self.assertEqual(
list(cmake.common_options()),
["-G", "Ninja",
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
"-DLLVM_VERSION_MAJOR:STRING=9",
"-DLLVM_VERSION_MINOR:STRING=0",
"-DLLVM_VERSION_PATCH:STRING=0",
"-DCLANG_VERSION_MAJOR:STRING=9",
"-DCLANG_VERSION_MINOR:STRING=0",
"-DCLANG_VERSION_PATCH:STRING=0",
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])

def test_common_options_build_ninja(self):
Expand All @@ -218,9 +235,12 @@ def test_common_options_full(self):
args.export_compile_commands = True
args.distcc = True
args.cmake_generator = 'Xcode'
args.clang_user_visible_version = CompilerVersion(
string_representation="9.0.0",
components=("9", "0", "0", None))
args.clang_compiler_version = CompilerVersion(
string_representation="3.8.0",
components=("3", "8", "0", None))
string_representation="999.0.900",
components=("999", "0", "900", None))
args.build_ninja = True
cmake = self.cmake(args)
self.assertEqual(
Expand All @@ -234,9 +254,12 @@ def test_common_options_full(self):
"-DCMAKE_CXX_COMPILER_ARG1=/path/to/clang++",
"-DCMAKE_CONFIGURATION_TYPES=" +
"Debug;Release;MinSizeRel;RelWithDebInfo",
"-DLLVM_VERSION_MAJOR:STRING=3",
"-DLLVM_VERSION_MINOR:STRING=8",
"-DLLVM_VERSION_PATCH:STRING=0"])
"-DLLVM_VERSION_MAJOR:STRING=9",
"-DLLVM_VERSION_MINOR:STRING=0",
"-DLLVM_VERSION_PATCH:STRING=0",
"-DCLANG_VERSION_MAJOR:STRING=9",
"-DCLANG_VERSION_MINOR:STRING=0",
"-DCLANG_VERSION_PATCH:STRING=0"])
# NOTE: No "-DCMAKE_MAKE_PROGRAM=/path/to/built/ninja" because
# cmake_generator is 'Xcode'

Expand Down