diff options
| -rw-r--r-- | libcxx/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | libcxx/test/libcxx/compiler.py | 11 | ||||
| -rw-r--r-- | libcxx/test/libcxx/test/config.py | 15 | ||||
| -rw-r--r-- | libcxx/test/lit.site.cfg.in | 4 | ||||
| -rw-r--r-- | libcxxabi/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | libcxxabi/test/lit.site.cfg.in | 1 |
6 files changed, 34 insertions, 4 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 94a682c6cce..537ae80acc0 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -312,6 +312,9 @@ add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") add_target_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}") add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}") add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}") +if (LIBCXX_TARGET_TRIPLE) + set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}") +endif() # Configure compiler. include(config-ix) diff --git a/libcxx/test/libcxx/compiler.py b/libcxx/test/libcxx/compiler.py index cb8542c64cd..24f7c36b783 100644 --- a/libcxx/test/libcxx/compiler.py +++ b/libcxx/test/libcxx/compiler.py @@ -193,6 +193,17 @@ class CXXCompiler(object): flags=flags) return rc == 0 + def addFlagIfSupported(self, flag): + if isinstance(flag, list): + flags = list(flag) + else: + flags = [flag] + if self.hasCompileFlag(flags): + self.flags += flags + return True + else: + return False + def addCompileFlagIfSupported(self, flag): if isinstance(flag, list): flags = list(flag) diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py index 6549324682a..ada260bacf4 100644 --- a/libcxx/test/libcxx/test/config.py +++ b/libcxx/test/libcxx/test/config.py @@ -83,6 +83,10 @@ class Configuration(object): conf = self.get_lit_conf(name) if conf is None: return default + if isinstance(conf, bool): + return conf + if not isinstance(conf, str): + raise TypeError('expected bool or string') if conf.lower() in ('1', 'true'): return True if conf.lower() in ('', '0', 'false'): @@ -375,7 +379,10 @@ class Configuration(object): if gcc_toolchain: self.cxx.flags += ['-gcc-toolchain', gcc_toolchain] if self.use_target: - self.cxx.flags += ['-target', self.config.target_triple] + if not self.cxx.addFlagIfSupported( + ['-target', self.config.target_triple]): + self.lit_config.warning('use_target is true but -target is '\ + 'not supported by the compiler') def configure_compile_flags_header_includes(self): support_path = os.path.join(self.libcxx_src_root, 'test/support') @@ -756,10 +763,12 @@ class Configuration(object): def configure_triple(self): # Get or infer the target triple. self.config.target_triple = self.get_lit_conf('target_triple') - self.use_target = bool(self.config.target_triple) + self.use_target = self.get_lit_bool('use_target', False) + if self.use_target and self.config.target_triple: + self.lit_config.warning('use_target is true but no triple is specified') # If no target triple was given, try to infer it from the compiler # under test. - if not self.use_target: + if not self.config.target_triple: target_triple = self.cxx.getTriple() # Drop sub-major version components from the triple, because the # current XFAIL handling expects exact matches for feature checks. diff --git a/libcxx/test/lit.site.cfg.in b/libcxx/test/lit.site.cfg.in index 5344992d728..741e9c89ac4 100644 --- a/libcxx/test/lit.site.cfg.in +++ b/libcxx/test/lit.site.cfg.in @@ -15,7 +15,9 @@ config.use_sanitizer = "@LLVM_USE_SANITIZER@" config.sanitizer_library = "@LIBCXX_SANITIZER_LIBRARY@" config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@" config.configuration_variant = "@LIBCXX_LIT_VARIANT@" -config.target_triple = "@LIBCXX_TARGET_TRIPLE@" +config.host_triple = "@LLVM_HOST_TRIPLE@" +config.target_triple = "@TARGET_TRIPLE@" +config.use_target = len("@LIBCXX_TARGET_TRIPLE@") > 0 config.sysroot = "@LIBCXX_SYSROOT@" config.gcc_toolchain = "@LIBCXX_GCC_TOOLCHAIN@" config.generate_coverage = "@LIBCXX_GENERATE_COVERAGE@" diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index b23936e2b11..5eb01090a4f 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -249,6 +249,10 @@ add_target_flags_if(LIBCXXABI_GCC_TOOLCHAIN add_target_flags_if(LIBCXXABI_SYSROOT "--sysroot=${LIBCXXABI_SYSROOT}") +if (LIBCXXABI_TARGET_TRIPLE) + set(TARGET_TRIPLE "${LIBCXXABI_TARGET_TRIPLE}") +endif() + # Configure compiler. Must happen after setting the target flags. include(config-ix) diff --git a/libcxxabi/test/lit.site.cfg.in b/libcxxabi/test/lit.site.cfg.in index 57e448a1de2..b8fb35c04fc 100644 --- a/libcxxabi/test/lit.site.cfg.in +++ b/libcxxabi/test/lit.site.cfg.in @@ -18,6 +18,7 @@ config.enable_shared = "@LIBCXX_ENABLE_SHARED@" config.enable_exceptions = "@LIBCXXABI_ENABLE_EXCEPTIONS@" config.host_triple = "@LLVM_HOST_TRIPLE@" config.target_triple = "@TARGET_TRIPLE@" +config.use_target = len("@LIBCXXABI_TARGET_TRIPLE@") > 0 # Let the main config do the real work. lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg") |

