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:
parent
a245f9b263
commit
7330ed3228
@ -42,6 +42,10 @@ option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
|
||||
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
|
||||
option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF)
|
||||
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
|
||||
option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
|
||||
option(LIBCXX_ENABLE_MONOTONIC_CLOCK
|
||||
"Build libc++ with support for a monotonic clock.
|
||||
This option may only be used when LIBCXX_ENABLE_THREADS=OFF." ON)
|
||||
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
|
||||
if (LIBCXX_BUILT_STANDALONE)
|
||||
set(LLVM_USE_SANITIZER "" CACHE STRING
|
||||
@ -206,6 +210,18 @@ if (MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
# LIBCXX_ENABLE_THREADS configuration
|
||||
if (NOT LIBCXX_ENABLE_THREADS)
|
||||
add_definitions(-D_LIBCPP_HAS_NO_THREADS)
|
||||
if (NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
|
||||
add_definitions(-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
|
||||
endif()
|
||||
# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON.
|
||||
elseif(NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
|
||||
message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF"
|
||||
" when LIBCXX_ENABLE_THREADS is also set to OFF.")
|
||||
endif()
|
||||
|
||||
# Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do
|
||||
# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
|
||||
if (LIBCXX_BUILT_STANDALONE)
|
||||
|
@ -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!")
|
||||
|
||||
|
21
test/lit.cfg
21
test/lit.cfg
@ -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
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user