Add support for building and testing libc++ without threads to CMake.

Currently hacks must be used in to configure and build libc++ without threads
when using CMake. This patch adds CMake options to enable/disable building with
threads and a monotonic clock.

This patch also propagates the configuration information to lit so the tests
are properly configured as well.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@223591 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-06 21:02:58 +00:00
parent a245f9b263
commit 7330ed3228
4 changed files with 48 additions and 11 deletions

View File

@@ -28,6 +28,8 @@ if(PYTHONINTERP_FOUND)
set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR})
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_ENABLE_THREADS)
pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK)
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")

View File

@@ -360,10 +360,14 @@ class Configuration(object):
self.config.available_features.add(
'with_system_lib=%s' % self.config.target_triple)
if 'libcpp-has-no-threads' in self.config.available_features:
# TODO 6/12/2014: Remove these once the buildmaster restarts.
# Removing before will break the bot that tests libcpp-has-no-threads.
if 'libcpp-has-no-threads' in self.config.available_features \
and '-D_LIBCPP_HAS_NO_THREADS' not in self.compile_flags:
self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
if 'libcpp-has-no-monotonic-clock' in self.config.available_features:
if 'libcpp-has-no-monotonic-clock' in self.config.available_features \
and '-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK' not in self.compile_flags:
self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
# Some linux distributions have different locale data than others.
@@ -384,6 +388,19 @@ class Configuration(object):
self.compile_flags += ['-D__STDC_FORMAT_MACROS',
'-D__STDC_LIMIT_MACROS',
'-D__STDC_CONSTANT_MACROS']
# Configure threading features.
enable_threads = self.get_lit_bool('enable_threads')
enable_monotonic_clock = self.get_lit_bool('enable_monotonic_clock')
assert enable_threads is not None and enable_monotonic_clock is not None
if not enable_threads:
self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
self.config.available_features.add('libcpp-has-no-threads')
if not enable_monotonic_clock:
self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
self.config.available_features.add('libcpp-has-no-monotonic-clock')
elif not enable_monotonic_clock:
self.lit_config.fatal('enable_monotonic_clock cannot be false when'
' enable_threads is true.')
def configure_link_flags(self):
# Configure library search paths

View File

@@ -1,13 +1,15 @@
@AUTO_GEN_COMMENT@
config.cxx_under_test = "@LIBCXX_COMPILER@"
config.std = "@LIBCXX_STD_VERSION@"
config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.enable_shared = @LIBCXX_ENABLE_SHARED@
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
config.cxx_under_test = "@LIBCXX_COMPILER@"
config.std = "@LIBCXX_STD_VERSION@"
config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.enable_shared = "@LIBCXX_ENABLE_SHARED@"
config.enable_threads = "@LIBCXX_ENABLE_THREADS@"
config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@"
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
# Let the main config do the real work.
lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")