diff options
| author | Eric Fiselier <eric@efcs.ca> | 2014-12-06 21:02:58 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2014-12-06 21:02:58 +0000 |
| commit | b9f99739bcb26fa6883df668be873be1e205f926 (patch) | |
| tree | 75f2affd1635ff8ef9fc4aa7cf909c63ef41db3a | |
| parent | 2050bedf035d926df6f4557f9ebb2283cc016f94 (diff) | |
| download | bcm5719-llvm-b9f99739bcb26fa6883df668be873be1e205f926.tar.gz bcm5719-llvm-b9f99739bcb26fa6883df668be873be1e205f926.zip | |
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.
llvm-svn: 223591
| -rw-r--r-- | libcxx/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | libcxx/test/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | libcxx/test/lit.cfg | 21 | ||||
| -rw-r--r-- | libcxx/test/lit.site.cfg.in | 20 |
4 files changed, 48 insertions, 11 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index f12c5257409..ca15f8743aa 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -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) diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt index 7236decfcc9..4c8193eab99 100644 --- a/libcxx/test/CMakeLists.txt +++ b/libcxx/test/CMakeLists.txt @@ -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!") diff --git a/libcxx/test/lit.cfg b/libcxx/test/lit.cfg index ec05d1c7cff..eef7314fe27 100644 --- a/libcxx/test/lit.cfg +++ b/libcxx/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 diff --git a/libcxx/test/lit.site.cfg.in b/libcxx/test/lit.site.cfg.in index 43fdb7d32bd..47e88d8c8e9 100644 --- a/libcxx/test/lit.site.cfg.in +++ b/libcxx/test/lit.site.cfg.in @@ -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") |

