diff --git a/clang/cmake/caches/CrossWinToARMLinux.cmake b/clang/cmake/caches/CrossWinToARMLinux.cmake --- a/clang/cmake/caches/CrossWinToARMLinux.cmake +++ b/clang/cmake/caches/CrossWinToARMLinux.cmake @@ -141,13 +141,8 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "") set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "") -set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "") -set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX OFF CACHE BOOL "") set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") -set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "") -set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX OFF CACHE BOOL "") - set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ABI_VERSION 2 CACHE STRING "") @@ -163,20 +158,13 @@ if(NOT DEFINED DEFAULT_TEST_EXECUTOR) set(DEFAULT_TEST_EXECUTOR "\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/libcxx/utils/ssh.py\\\" --host=${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}") endif() - if(NOT DEFINED DEFAULT_TEST_TARGET_INFO) - set(DEFAULT_TEST_TARGET_INFO "libcxx.test.target_info.LinuxRemoteTI") - endif() set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_EMULATOR - "\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/llvm/utils/remote-exec.py\\\" --execdir %%T --exec-pattern='.*\\.c.*\\.tmp.*' --host=${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}" + "\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/llvm/utils/remote-exec.py\\\" --execdir %T --exec-pattern='.*\\.c.*\\.tmp.*' --host=${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}" CACHE STRING "") - set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_TARGET_INFO "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "") set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "") - - set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_TARGET_INFO "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "") set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "") - set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_TARGET_INFO "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "") set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "") endif() diff --git a/libcxx/cmake/caches/MinGW.cmake b/libcxx/cmake/caches/MinGW.cmake --- a/libcxx/cmake/caches/MinGW.cmake +++ b/libcxx/cmake/caches/MinGW.cmake @@ -8,8 +8,6 @@ set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") -set(LIBCXX_TARGET_INFO "libcxx.test.target_info.MingwLocalTI" CACHE STRING "") - # Without this flag, 'long double' (which is 80 bit on x86 mingw, but # 64 bit in MSVC) isn't handled correctly in printf. set(LIBCXX_EXTRA_SITE_DEFINES "__USE_MINGW_ANSI_STDIO=1" CACHE STRING "") diff --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst --- a/libcxx/docs/BuildingLibcxx.rst +++ b/libcxx/docs/BuildingLibcxx.rst @@ -157,8 +157,7 @@ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DLLVM_ENABLE_RUNTIMES=libcxx \ - -DLIBCXX_CXX_ABI=libstdc++ \ - -DLIBCXX_TARGET_INFO="libcxx.test.target_info.MingwLocalTI" + -DLIBCXX_CXX_ABI=libstdc++ > ninja -C build cxx > cp /mingw64/bin/{libstdc++-6,libgcc_s_seh-1,libwinpthread-1}.dll lib > ninja -C build check-cxx diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -72,6 +72,10 @@ incidental transitive includes more aggressively, in particular regardless of the language version in use. +- The legacy testing system for libc++, libc++abi and libunwind has been removed. + All known clients have been migrated to the new configuration system, but please + reach out to the libc++ developers if you find something missing in the new + configuration system. Upcoming Deprecations and Removals ---------------------------------- diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt --- a/libcxx/test/CMakeLists.txt +++ b/libcxx/test/CMakeLists.txt @@ -1,84 +1,9 @@ -macro(pythonize_bool var) - if (${var}) - set(${var} True) - else() - set(${var} False) - endif() -endmacro() - -set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING - "Configuration variant to use for LIT.") - -set(LIBCXX_TEST_LINKER_FLAGS "" CACHE STRING - "Additonal linker flags to pass when compiling the tests") -set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING - "Additonal linker flags to pass when compiling the tests") - -# The tests shouldn't link to any ABI library when it has been linked into -# libc++ statically or via a linker script. -if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT) - set(LIBCXX_CXXABI_FOR_TESTS "none") -else() - set(LIBCXX_CXXABI_FOR_TESTS "${LIBCXX_CXX_ABI}") -endif() - -# The tests shouldn't link to libunwind if we have a linker script which -# already does so. -if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) - set(LIBCXXABI_USE_LLVM_UNWINDER OFF) -endif() - -# TODO: Clients using those options should switch to from-scratch Lit configuration files. -option(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI - "Whether the libc++ tests should link with the shared libc++abi library" - ${LIBCXXABI_ENABLE_SHARED}) - -option(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX - "Whether the libc++ tests should link with the shared libc++ library" - ${LIBCXX_ENABLE_SHARED}) - -if(DEFINED LIBCXXABI_ENABLE_SHARED - AND LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI - AND NOT LIBCXXABI_ENABLE_SHARED) - message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI being ON requires LIBCXXABI_ENABLE_SHARED to be ON") -endif() - -if(DEFINED LIBCXXABI_ENABLE_STATIC - AND NOT LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI - AND NOT LIBCXXABI_ENABLE_STATIC) - message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI being OFF requires LIBCXXABI_ENABLE_STATIC to be ON") -endif() - -if(LIBCXX_INCLUDE_TESTS AND LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_SHARED) - message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX being ON requires LIBCXX_ENABLE_SHARED to be ON") -endif() - -if(LIBCXX_INCLUDE_TESTS AND NOT LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_STATIC) - message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON") -endif() - -pythonize_bool(LIBCXX_ENABLE_SHARED) -pythonize_bool(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX) -pythonize_bool(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI) -pythonize_bool(LIBCXX_ENABLE_FILESYSTEM) -pythonize_bool(LIBCXX_GENERATE_COVERAGE) -pythonize_bool(LIBCXXABI_ENABLE_SHARED) -pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) -pythonize_bool(LIBCXX_USE_COMPILER_RT) -pythonize_bool(LIBCXX_HAS_ATOMIC_LIB) -pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB) -pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) -pythonize_bool(LIBCXX_DEBUG_BUILD) -pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS) - # By default, libcxx and libcxxabi share a library directory. if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH) set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH "The path to libc++abi library.") endif() -set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING - "TargetInfo to use when setting up test environment.") set(LIBCXX_EXECUTOR "\\\"${Python3_EXECUTABLE}\\\" ${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING "Executor to use when running tests.") diff --git a/libcxx/test/configs/legacy.cfg.in b/libcxx/test/configs/legacy.cfg.in deleted file mode 100644 --- a/libcxx/test/configs/legacy.cfg.in +++ /dev/null @@ -1,67 +0,0 @@ -@AUTO_GEN_COMMENT@ - -@SERIALIZED_LIT_PARAMS@ - -import os -import site - -config.cxx_headers = "@LIBCXX_GENERATED_INCLUDE_DIR@" -config.cxx_under_test = "@CMAKE_CXX_COMPILER@" -config.project_obj_root = "@CMAKE_BINARY_DIR@" -config.install_root = "@CMAKE_BINARY_DIR@" -config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@" -config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@" -config.cxx_library_root = "@LIBCXX_LIBRARY_DIR@" -config.abi_library_root = "@LIBCXX_CXX_ABI_LIBRARY_PATH@" -config.enable_shared = @LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX@ -config.cxx_abi = "@LIBCXX_CXXABI_FOR_TESTS@" -config.configuration_variant = "@LIBCXX_LIT_VARIANT@" -config.host_triple = "@LLVM_HOST_TRIPLE@" -config.sysroot = "@CMAKE_SYSROOT@" -config.gcc_toolchain = "@CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN@" -config.generate_coverage = @LIBCXX_GENERATE_COVERAGE@ -config.target_info = "@LIBCXX_TARGET_INFO@" -config.test_linker_flags = "@LIBCXX_TEST_LINKER_FLAGS@" -config.test_compiler_flags = "@LIBCXX_TEST_COMPILER_FLAGS@" - -config.executor = "@LIBCXX_EXECUTOR@" -config.llvm_unwinder = @LIBCXXABI_USE_LLVM_UNWINDER@ -config.builtins_library = "@LIBCXX_BUILTINS_LIBRARY@" -config.has_libatomic = @LIBCXX_HAS_ATOMIC_LIB@ -config.debug_build = @LIBCXX_DEBUG_BUILD@ -config.libcxxabi_shared = @LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI@ -config.cxx_ext_threads = @LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY@ -config.pstl_src_root = "@ParallelSTL_SOURCE_DIR@" if @LIBCXX_ENABLE_PARALLEL_ALGORITHMS@ else None -config.pstl_obj_root = "@ParallelSTL_BINARY_DIR@" if @LIBCXX_ENABLE_PARALLEL_ALGORITHMS@ else None - -# Code signing -config.llvm_codesign_identity = "@LLVM_CODESIGNING_IDENTITY@" - -site.addsitedir(os.path.join(config.libcxx_src_root, 'utils')) - -# name: The name of this test suite. -config.name = 'libc++' - -# suffixes: A list of file extensions to treat as test files. -config.suffixes = ['.pass.cpp', '.fail.cpp', '.sh.cpp', '.pass.mm'] - -# test_source_root: The root path where tests are located. -config.test_source_root = os.path.join(config.libcxx_src_root, 'test') - -# Allow expanding substitutions that are based on other substitutions -config.recursiveExpansionLimit = 10 - -# Infer the test_exec_root from the libcxx_object root. -config.test_exec_root = os.path.join(config.libcxx_obj_root, 'test') - -import libcxx.test.format -config.test_format = libcxx.test.format.CxxStandardLibraryTest() - -lit_config.note('Using configuration variant: {}'.format(config.configuration_variant)) -import libcxx.test.config -configuration = libcxx.test.config.Configuration(lit_config, config) -configuration.configure() -configuration.print_config_info() - -lit_config.warning("This is a legacy testing configuration which will be removed in LLVM 16. " - "Please use one of the configurations in libcxx/test/configs or define your own.") diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -366,23 +366,6 @@ - group: "Legacy" steps: - - label: "Legacy Lit configuration" - command: "libcxx/utils/ci/run-buildbot legacy-test-config" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - env: - CC: "clang-${LLVM_HEAD_VERSION}" - CXX: "clang++-${LLVM_HEAD_VERSION}" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - label: "Legacy LLVM_ENABLE_PROJECTS build" command: "libcxx/utils/ci/run-buildbot legacy-project-build" artifact_paths: diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -492,13 +492,6 @@ echo "--- Installing libc++ and libc++abi to a fake location" ${NINJA} -C "${BUILD_DIR}" install-runtimes ;; -legacy-test-config) - clean - generate-cmake -DLIBCXX_TEST_CONFIG="legacy.cfg.in" \ - -DLIBCXXABI_TEST_CONFIG="${MONOREPO_ROOT}/libcxxabi/test/lit.site.cfg.in" \ - -DLIBUNWIND_TEST_CONFIG="${MONOREPO_ROOT}/libunwind/test/lit.site.cfg.in" - check-runtimes -;; legacy-project-build) clean diff --git a/libcxx/utils/libcxx/compiler.py b/libcxx/utils/libcxx/compiler.py deleted file mode 100644 --- a/libcxx/utils/libcxx/compiler.py +++ /dev/null @@ -1,308 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===## - -import platform -import os -import libcxx.util - - -class CXXCompiler(object): - CM_Default = 0 - CM_PreProcess = 1 - CM_Compile = 2 - CM_Link = 3 - - def __init__(self, config, path, flags=None, compile_flags=None, link_flags=None, - warning_flags=None, verify_supported=None, - verify_flags=None, use_verify=False, - modules_flags=None, use_modules=False, - use_ccache=False, use_warnings=False, compile_env=None, - cxx_type=None, cxx_version=None): - self.libcxx_config = config - self.source_lang = 'c++' - self.path = path - self.flags = list(flags or []) - self.compile_flags = list(compile_flags or []) - self.link_flags = list(link_flags or []) - self.warning_flags = list(warning_flags or []) - self.verify_supported = verify_supported - self.use_verify = use_verify - self.verify_flags = list(verify_flags or []) - assert not use_verify or verify_supported - assert not use_verify or verify_flags is not None - self.modules_flags = list(modules_flags or []) - self.use_modules = use_modules - assert not use_modules or modules_flags is not None - self.use_ccache = use_ccache - self.use_warnings = use_warnings - if compile_env is not None: - self.compile_env = dict(compile_env) - else: - self.compile_env = None - self.type = cxx_type - self.version = cxx_version - if self.type is None or self.version is None: - self._initTypeAndVersion() - - def isVerifySupported(self): - if self.verify_supported is None: - self.verify_supported = self.hasCompileFlag(['-Xclang', - '-verify-ignore-unexpected']) - if self.verify_supported: - self.verify_flags = [ - '-Xclang', '-verify', - '-Xclang', '-verify-ignore-unexpected=note', - '-ferror-limit=1024' - ] - return self.verify_supported - - def useVerify(self, value=True): - self.use_verify = value - assert not self.use_verify or self.verify_flags is not None - - def useModules(self, value=True): - self.use_modules = value - assert not self.use_modules or self.modules_flags is not None - - def useCCache(self, value=True): - self.use_ccache = value - - def useWarnings(self, value=True): - self.use_warnings = value - - def _initTypeAndVersion(self): - # Get compiler type and version - macros = self.dumpMacros() - if macros is None: - return - compiler_type = None - major_ver = minor_ver = patchlevel = None - if '__clang__' in macros.keys(): - compiler_type = 'clang' - # Treat apple's llvm fork differently. - if '__apple_build_version__' in macros.keys(): - compiler_type = 'apple-clang' - major_ver = macros['__clang_major__'] - minor_ver = macros['__clang_minor__'] - patchlevel = macros['__clang_patchlevel__'] - elif '__GNUC__' in macros.keys(): - compiler_type = 'gcc' - major_ver = macros['__GNUC__'] - minor_ver = macros['__GNUC_MINOR__'] - patchlevel = macros['__GNUC_PATCHLEVEL__'] - self.type = compiler_type - self.version = (major_ver, minor_ver, patchlevel) - - def _basicCmd(self, source_files, out, mode=CM_Default, flags=[], - input_is_cxx=False): - cmd = [] - if self.use_ccache \ - and not mode == self.CM_Link \ - and not mode == self.CM_PreProcess: - cmd += ['ccache'] - cmd += [self.path] - if out is not None: - cmd += ['-o', out] - if input_is_cxx: - cmd += ['-x', self.source_lang] - if isinstance(source_files, list): - cmd += source_files - elif isinstance(source_files, str): - cmd += [source_files] - else: - raise TypeError('source_files must be a string or list') - if mode == self.CM_PreProcess: - cmd += ['-E'] - elif mode == self.CM_Compile: - cmd += ['-c'] - cmd += self.flags - if self.use_verify: - cmd += self.verify_flags - assert mode in [self.CM_Default, self.CM_Compile] - if self.use_modules: - cmd += self.modules_flags - if mode != self.CM_Link: - cmd += self.compile_flags - if self.use_warnings: - cmd += self.warning_flags - if mode != self.CM_PreProcess and mode != self.CM_Compile: - cmd += self.link_flags - cmd += flags - return cmd - - def preprocessCmd(self, source_files, out=None, flags=[]): - return self._basicCmd(source_files, out, flags=flags, - mode=self.CM_PreProcess, - input_is_cxx=True) - - def compileCmd(self, source_files, out=None, flags=[]): - return self._basicCmd(source_files, out, flags=flags, - mode=self.CM_Compile, - input_is_cxx=True) + ['-c'] - - def linkCmd(self, source_files, out=None, flags=[]): - return self._basicCmd(source_files, out, flags=flags, - mode=self.CM_Link) - - def compileLinkCmd(self, source_files, out=None, flags=[]): - return self._basicCmd(source_files, out, flags=flags) - - def preprocess(self, source_files, out=None, flags=[], cwd=None): - cmd = self.preprocessCmd(source_files, out, flags) - out, err, rc = libcxx.util.executeCommand(cmd, env=self.compile_env, - cwd=cwd) - return cmd, out, err, rc - - def compile(self, source_files, out=None, flags=[], cwd=None): - cmd = self.compileCmd(source_files, out, flags) - out, err, rc = libcxx.util.executeCommand(cmd, env=self.compile_env, - cwd=cwd) - return cmd, out, err, rc - - def link(self, source_files, exec_path=None, flags=[], cwd=None): - cmd = self.linkCmd(source_files, exec_path, flags) - out, err, rc = libcxx.util.executeCommand(cmd, env=self.compile_env, - cwd=cwd) - cs_cmd, cs_out, cs_err, cs_rc = self.codesign(exec_path, cwd) - if cs_rc != 0: - return cs_cmd, cs_out, cs_err, cs_rc - return cmd, out, err, rc - - def compileLink(self, source_files, exec_path=None, flags=[], - cwd=None): - cmd = self.compileLinkCmd(source_files, exec_path, flags) - out, err, rc = libcxx.util.executeCommand(cmd, env=self.compile_env, - cwd=cwd) - cs_cmd, cs_out, cs_err, cs_rc = self.codesign(exec_path, cwd) - if cs_rc != 0: - return cs_cmd, cs_out, cs_err, cs_rc - return cmd, out, err, rc - - def codesign(self, exec_path, cwd=None): - null_op = [], '', '', 0 - if not exec_path: - return null_op - codesign_ident = self.libcxx_config.get_lit_conf('llvm_codesign_identity', '') - if not codesign_ident: - return null_op - cmd = ['xcrun', 'codesign', '-s', codesign_ident, exec_path] - out, err, rc = libcxx.util.executeCommand(cmd, cwd=cwd) - return cmd, out, err, rc - - def compileLinkTwoSteps(self, source_file, out=None, object_file=None, - flags=[], cwd=None): - if not isinstance(source_file, str): - raise TypeError('This function only accepts a single input file') - if object_file is None: - # Create, use and delete a temporary object file if none is given. - with_fn = lambda: libcxx.util.guardedTempFilename(suffix='.o') - else: - # Otherwise wrap the filename in a context manager function. - with_fn = lambda: libcxx.util.nullContext(object_file) - with with_fn() as object_file: - cc_cmd, cc_stdout, cc_stderr, rc = self.compile( - source_file, object_file, flags=flags, cwd=cwd) - if rc != 0: - return cc_cmd, cc_stdout, cc_stderr, rc - - link_cmd, link_stdout, link_stderr, rc = self.link( - object_file, exec_path=out, flags=flags, cwd=cwd) - return (cc_cmd + ['&&'] + link_cmd, cc_stdout + link_stdout, - cc_stderr + link_stderr, rc) - - def dumpMacros(self, source_files=None, flags=[], cwd=None): - if source_files is None: - source_files = os.devnull - flags = ['-dM'] + flags - cmd, out, err, rc = self.preprocess(source_files, flags=flags, cwd=cwd) - if rc != 0: - return cmd, out, err, rc - parsed_macros = {} - lines = [l.strip() for l in out.split('\n') if l.strip()] - for l in lines: - assert l.startswith('#define ') - l = l[len('#define '):] - macro, _, value = l.partition(' ') - parsed_macros[macro] = value - return parsed_macros - - def getTriple(self): - cmd = [self.path] + self.flags + ['-dumpmachine'] - return libcxx.util.capture(cmd).strip() - - def hasCompileFlag(self, flag): - if isinstance(flag, list): - flags = list(flag) - else: - flags = [flag] - # Add -Werror to ensure that an unrecognized flag causes a non-zero - # exit code. -Werror is supported on all known compiler types. - if self.type is not None: - flags += ['-Werror', '-fsyntax-only'] - cmd, out, err, rc = self.compile(os.devnull, out=os.devnull, - 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) - else: - flags = [flag] - if self.hasCompileFlag(flags): - self.compile_flags += flags - return True - else: - return False - - def hasWarningFlag(self, flag): - """ - hasWarningFlag - Test if the compiler supports a given warning flag. - Unlike addCompileFlagIfSupported, this function detects when - "-Wno-" flags are unsupported. If flag is a - "-Wno-" GCC will not emit an unknown option diagnostic unless - another error is triggered during compilation. - """ - assert isinstance(flag, str) - assert flag.startswith('-W') - if not flag.startswith('-Wno-'): - return self.hasCompileFlag(flag) - flags = ['-Werror', flag] - old_use_warnings = self.use_warnings - self.useWarnings(False) - cmd = self.compileCmd('-', os.devnull, flags) - self.useWarnings(old_use_warnings) - # Remove '-v' because it will cause the command line invocation - # to be printed as part of the error output. - # TODO(EricWF): Are there other flags we need to worry about? - if '-v' in cmd: - cmd.remove('-v') - out, err, rc = libcxx.util.executeCommand( - cmd, input=libcxx.util.to_bytes('#error\n')) - - assert rc != 0 - if flag in err: - return False - return True - - def addWarningFlagIfSupported(self, flag): - if self.hasWarningFlag(flag): - if flag not in self.warning_flags: - self.warning_flags += [flag] - return True - return False diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py deleted file mode 100644 --- a/libcxx/utils/libcxx/test/config.py +++ /dev/null @@ -1,461 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===## - -import copy -import os -import pkgutil -import pipes -import platform -import re -import shlex -import shutil -import sys - -from libcxx.compiler import CXXCompiler -from libcxx.test.target_info import make_target_info -import libcxx.util -import libcxx.test.features -import libcxx.test.newconfig -import libcxx.test.params -import lit - -def loadSiteConfig(lit_config, config, param_name, env_name): - # We haven't loaded the site specific configuration (the user is - # probably trying to run on a test file directly, and either the site - # configuration hasn't been created by the build system, or we are in an - # out-of-tree build situation). - site_cfg = lit_config.params.get(param_name, - os.environ.get(env_name)) - if not site_cfg: - lit_config.warning('No site specific configuration file found!' - ' Running the tests in the default configuration.') - elif not os.path.isfile(site_cfg): - lit_config.fatal( - "Specified site configuration file does not exist: '%s'" % - site_cfg) - else: - lit_config.note('using site specific configuration at %s' % site_cfg) - ld_fn = lit_config.load_config - - # Null out the load_config function so that lit.site.cfg doesn't - # recursively load a config even if it tries. - # TODO: This is one hell of a hack. Fix it. - def prevent_reload_fn(*args, **kwargs): - pass - lit_config.load_config = prevent_reload_fn - ld_fn(config, site_cfg) - lit_config.load_config = ld_fn - -# Extract the value of a numeric macro such as __cplusplus or a feature-test -# macro. -def intMacroValue(token): - return int(token.rstrip('LlUu')) - -class Configuration(object): - # pylint: disable=redefined-outer-name - def __init__(self, lit_config, config): - self.lit_config = lit_config - self.config = config - self.cxx = None - self.cxx_is_clang_cl = None - self.cxx_stdlib_under_test = None - self.project_obj_root = None - self.libcxx_src_root = None - self.libcxx_obj_root = None - self.cxx_library_root = None - self.cxx_runtime_root = None - self.abi_library_root = None - self.link_shared = self.get_lit_bool('enable_shared', default=True) - self.debug_build = self.get_lit_bool('debug_build', default=False) - self.exec_env = dict() - self.use_clang_verify = False - - def get_lit_conf(self, name, default=None): - val = self.lit_config.params.get(name, None) - if val is None: - val = getattr(self.config, name, None) - if val is None: - val = default - return val - - def get_lit_bool(self, name, default=None, env_var=None): - def check_value(value, var_name): - if value is None: - return default - if isinstance(value, bool): - return value - if not isinstance(value, str): - raise TypeError('expected bool or string') - if value.lower() in ('1', 'true'): - return True - if value.lower() in ('', '0', 'false'): - return False - self.lit_config.fatal( - "parameter '{}' should be true or false".format(var_name)) - - conf_val = self.get_lit_conf(name) - if env_var is not None and env_var in os.environ and \ - os.environ[env_var] is not None: - val = os.environ[env_var] - if conf_val is not None: - self.lit_config.warning( - 'Environment variable %s=%s is overriding explicit ' - '--param=%s=%s' % (env_var, val, name, conf_val)) - return check_value(val, env_var) - return check_value(conf_val, name) - - def make_static_lib_name(self, name): - """Return the full filename for the specified library name""" - if self.target_info.is_windows() and not self.target_info.is_mingw(): - assert name == 'c++' # Only allow libc++ to use this function for now. - return 'lib' + name + '.lib' - else: - return 'lib' + name + '.a' - - def configure(self): - self.target_info = make_target_info(self) - self.executor = self.get_lit_conf('executor') - self.configure_cxx() - self.configure_src_root() - self.configure_obj_root() - self.cxx_stdlib_under_test = self.get_lit_conf('cxx_stdlib_under_test', 'libc++') - self.cxx_library_root = self.get_lit_conf('cxx_library_root', self.libcxx_obj_root) - self.abi_library_root = self.get_lit_conf('abi_library_root') or self.cxx_library_root - self.cxx_runtime_root = self.get_lit_conf('cxx_runtime_root', self.cxx_library_root) - self.abi_runtime_root = self.get_lit_conf('abi_runtime_root', self.abi_library_root) - self.configure_compile_flags() - self.configure_link_flags() - self.configure_env() - self.configure_coverage() - self.configure_substitutions() - - libcxx.test.newconfig.configure( - libcxx.test.params.DEFAULT_PARAMETERS, - libcxx.test.features.DEFAULT_FEATURES, - self.config, - self.lit_config - ) - - self.lit_config.note("All available features: {}".format(self.config.available_features)) - - def print_config_info(self): - if self.cxx.use_modules: - self.lit_config.note('Using modules flags: %s' % - self.cxx.modules_flags) - if len(self.cxx.warning_flags): - self.lit_config.note('Using warnings: %s' % self.cxx.warning_flags) - show_env_vars = {} - for k,v in self.exec_env.items(): - if k not in os.environ or os.environ[k] != v: - show_env_vars[k] = v - self.lit_config.note('Adding environment variables: %r' % show_env_vars) - self.lit_config.note("Linking against the C++ Library at {}".format(self.cxx_library_root)) - self.lit_config.note("Running against the C++ Library at {}".format(self.cxx_runtime_root)) - self.lit_config.note("Linking against the ABI Library at {}".format(self.abi_library_root)) - self.lit_config.note("Running against the ABI Library at {}".format(self.abi_runtime_root)) - - def configure_cxx(self): - # Gather various compiler parameters. - cxx = self.get_lit_conf('cxx_under_test') - self.cxx_is_clang_cl = cxx is not None and \ - os.path.basename(cxx).startswith('clang-cl') - # If no specific cxx_under_test was given, attempt to infer it as - # clang++. - if cxx is None or self.cxx_is_clang_cl: - search_paths = self.config.environment['PATH'] - if cxx is not None and os.path.isabs(cxx): - search_paths = os.path.dirname(cxx) - clangxx = libcxx.util.which('clang++', search_paths) - if clangxx: - cxx = clangxx - self.lit_config.note( - "inferred cxx_under_test as: %r" % cxx) - elif self.cxx_is_clang_cl: - self.lit_config.fatal('Failed to find clang++ substitution for' - ' clang-cl') - if not cxx: - self.lit_config.fatal('must specify user parameter cxx_under_test ' - '(e.g., --param=cxx_under_test=clang++)') - self.cxx = CXXCompiler(self, cxx) if not self.cxx_is_clang_cl else \ - self._configure_clang_cl(cxx) - self.cxx.compile_env = dict(os.environ) - - def _configure_clang_cl(self, clang_path): - def _split_env_var(var): - return [p.strip() for p in os.environ.get(var, '').split(';') if p.strip()] - - def _prefixed_env_list(var, prefix): - from itertools import chain - return list(chain.from_iterable((prefix, path) for path in _split_env_var(var))) - - assert self.cxx_is_clang_cl - flags = [] - compile_flags = [] - link_flags = _prefixed_env_list('LIB', '-L') - return CXXCompiler(self, clang_path, flags=flags, - compile_flags=compile_flags, - link_flags=link_flags) - - def configure_src_root(self): - self.libcxx_src_root = self.get_lit_conf( - 'libcxx_src_root', os.path.dirname(self.config.test_source_root)) - - def configure_obj_root(self): - self.project_obj_root = self.get_lit_conf('project_obj_root') - self.libcxx_obj_root = self.get_lit_conf('libcxx_obj_root') - if not self.libcxx_obj_root and self.project_obj_root is not None: - possible_roots = [ - os.path.join(self.project_obj_root, 'libcxx'), - os.path.join(self.project_obj_root, 'projects', 'libcxx'), - os.path.join(self.project_obj_root, 'runtimes', 'libcxx'), - ] - for possible_root in possible_roots: - if os.path.isdir(possible_root): - self.libcxx_obj_root = possible_root - break - else: - self.libcxx_obj_root = self.project_obj_root - - def configure_compile_flags(self): - self.configure_default_compile_flags() - # Configure extra flags - compile_flags_str = self.get_lit_conf('compile_flags', '') - self.cxx.compile_flags += shlex.split(compile_flags_str) - if self.target_info.is_windows(): - self.cxx.compile_flags += ['-D_CRT_SECURE_NO_WARNINGS'] - # Don't warn about using common but nonstandard unprefixed functions - # like chdir, fileno. - self.cxx.compile_flags += ['-D_CRT_NONSTDC_NO_WARNINGS'] - # Build the tests in the same configuration as libcxx itself, - # to avoid mismatches if linked statically. - self.cxx.compile_flags += ['-D_CRT_STDIO_ISO_WIDE_SPECIFIERS'] - # Required so that tests using min/max don't fail on Windows, - # and so that those tests don't have to be changed to tolerate - # this insanity. - self.cxx.compile_flags += ['-DNOMINMAX'] - additional_flags = self.get_lit_conf('test_compiler_flags') - if additional_flags: - self.cxx.compile_flags += shlex.split(additional_flags) - - def configure_default_compile_flags(self): - # Configure include paths - self.configure_compile_flags_header_includes() - self.target_info.add_cxx_compile_flags(self.cxx.compile_flags) - self.target_info.add_cxx_flags(self.cxx.flags) - # Use verbose output for better errors - self.cxx.flags += ['-v'] - sysroot = self.get_lit_conf('sysroot') - if sysroot: - self.cxx.flags += ['--sysroot=' + sysroot] - gcc_toolchain = self.get_lit_conf('gcc_toolchain') - if gcc_toolchain: - self.cxx.flags += ['--gcc-toolchain=' + gcc_toolchain] - # NOTE: the _DEBUG definition must preceed the triple check because for - # the Windows build of libc++, the forced inclusion of a header requires - # that _DEBUG is defined. Incorrect ordering will result in -target - # being elided. - if self.target_info.is_windows() and self.debug_build: - self.cxx.compile_flags += ['-D_DEBUG'] - - # Add includes for support headers used in the tests. - support_path = os.path.join(self.libcxx_src_root, 'test/support') - self.cxx.compile_flags += ['-I' + support_path] - - # Add includes for the PSTL headers - pstl_src_root = self.get_lit_conf('pstl_src_root') - pstl_obj_root = self.get_lit_conf('pstl_obj_root') - if pstl_src_root is not None and pstl_obj_root is not None: - self.cxx.compile_flags += ['-I' + os.path.join(pstl_src_root, 'include')] - self.cxx.compile_flags += ['-I' + os.path.join(pstl_obj_root, 'generated_headers')] - self.cxx.compile_flags += ['-I' + os.path.join(pstl_src_root, 'test')] - self.config.available_features.add('parallel-algorithms') - - def configure_compile_flags_header_includes(self): - support_path = os.path.join(self.libcxx_src_root, 'test', 'support') - if self.cxx_stdlib_under_test == 'msvc': - self.cxx.compile_flags += [ - '-include', os.path.join(support_path, - 'msvc_stdlib_force_include.h')] - pass - if self.target_info.is_windows() and self.debug_build and \ - self.cxx_stdlib_under_test != 'msvc': - self.cxx.compile_flags += [ - '-include', os.path.join(support_path, - 'set_windows_crt_report_mode.h') - ] - cxx_headers = self.get_lit_conf('cxx_headers') - if cxx_headers is None and self.cxx_stdlib_under_test != 'libc++': - self.lit_config.note('using the system cxx headers') - return - self.cxx.compile_flags += ['-nostdinc++'] - if not os.path.isdir(cxx_headers): - self.lit_config.fatal("cxx_headers='{}' is not a directory.".format(cxx_headers)) - (path, version) = os.path.split(cxx_headers) - (path, cxx) = os.path.split(path) - triple = self.get_lit_conf('target_triple', None) - if triple is not None: - cxx_target_headers = os.path.join(path, triple, cxx, version) - if os.path.isdir(cxx_target_headers): - self.cxx.compile_flags += ['-I', cxx_target_headers] - self.cxx.compile_flags += ['-I', cxx_headers] - if self.libcxx_obj_root is not None: - cxxabi_headers = os.path.join(self.libcxx_obj_root, 'include', - 'c++build') - if os.path.isdir(cxxabi_headers): - self.cxx.compile_flags += ['-I' + cxxabi_headers] - - def configure_link_flags(self): - # Configure library path - self.configure_link_flags_cxx_library_path() - self.configure_link_flags_abi_library_path() - - # Configure libraries - if self.cxx_stdlib_under_test == 'libc++': - if self.target_info.is_mingw(): - self.cxx.link_flags += ['-nostdlib++'] - else: - self.cxx.link_flags += ['-nodefaultlibs'] - # FIXME: Handle MSVCRT as part of the ABI library handling. - if self.target_info.is_windows() and not self.target_info.is_mingw(): - self.cxx.link_flags += ['-nostdlib'] - self.configure_link_flags_cxx_library() - self.configure_link_flags_abi_library() - self.configure_extra_library_flags() - elif self.cxx_stdlib_under_test == 'libstdc++': - self.cxx.link_flags += ['-lstdc++fs', '-lm', '-pthread'] - elif self.cxx_stdlib_under_test == 'msvc': - # FIXME: Correctly setup debug/release flags here. - pass - elif self.cxx_stdlib_under_test == 'cxx_default': - self.cxx.link_flags += ['-pthread'] - else: - self.lit_config.fatal('invalid stdlib under test') - - link_flags_str = self.get_lit_conf('link_flags', '') - self.cxx.link_flags += shlex.split(link_flags_str) - - def configure_link_flags_cxx_library_path(self): - if self.cxx_library_root: - self.cxx.link_flags += ['-L' + self.cxx_library_root] - if self.target_info.is_windows() and self.link_shared: - self.add_path(self.cxx.compile_env, self.cxx_library_root) - if self.cxx_runtime_root: - if not self.target_info.is_windows(): - self.cxx.link_flags += ['-Wl,-rpath,' + - self.cxx_runtime_root] - elif self.target_info.is_windows() and self.link_shared: - self.add_path(self.exec_env, self.cxx_runtime_root) - additional_flags = self.get_lit_conf('test_linker_flags') - if additional_flags: - self.cxx.link_flags += shlex.split(additional_flags) - - def configure_link_flags_abi_library_path(self): - # Configure ABI library paths. - if self.abi_library_root: - self.cxx.link_flags += ['-L' + self.abi_library_root] - if self.abi_runtime_root: - if not self.target_info.is_windows(): - self.cxx.link_flags += ['-Wl,-rpath,' + self.abi_runtime_root] - else: - self.add_path(self.exec_env, self.abi_runtime_root) - - def configure_link_flags_cxx_library(self): - if self.link_shared: - self.cxx.link_flags += ['-lc++'] - else: - if self.cxx_library_root: - libname = self.make_static_lib_name('c++') - abs_path = os.path.join(self.cxx_library_root, libname) - assert os.path.exists(abs_path) and \ - "static libc++ library does not exist" - self.cxx.link_flags += [abs_path] - else: - self.cxx.link_flags += ['-lc++'] - - def configure_link_flags_abi_library(self): - cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi') - if cxx_abi == 'libstdc++': - self.cxx.link_flags += ['-lstdc++'] - elif cxx_abi == 'libsupc++': - self.cxx.link_flags += ['-lsupc++'] - elif cxx_abi == 'libcxxabi': - # If the C++ library requires explicitly linking to libc++abi, or - # if we're testing libc++abi itself (the test configs are shared), - # then link it. - testing_libcxxabi = self.get_lit_conf('name', '') == 'libc++abi' - if self.target_info.allow_cxxabi_link() or testing_libcxxabi: - libcxxabi_shared = self.get_lit_bool('libcxxabi_shared', default=True) - if libcxxabi_shared: - self.cxx.link_flags += ['-lc++abi'] - else: - if self.abi_library_root: - libname = self.make_static_lib_name('c++abi') - abs_path = os.path.join(self.abi_library_root, libname) - self.cxx.link_flags += [abs_path] - else: - self.cxx.link_flags += ['-lc++abi'] - elif cxx_abi == 'system-libcxxabi': - self.cxx.link_flags += ['-lc++abi'] - elif cxx_abi == 'libcxxrt': - self.cxx.link_flags += ['-lcxxrt'] - elif cxx_abi == 'vcruntime': - debug_suffix = 'd' if self.debug_build else '' - # This matches the set of libraries linked in the toplevel - # libcxx CMakeLists.txt if building targeting msvc. - self.cxx.link_flags += ['-l%s%s' % (lib, debug_suffix) for lib in - ['vcruntime', 'ucrt', 'msvcrt', 'msvcprt']] - # The compiler normally links in oldnames.lib too, but we've - # specified -nostdlib above, so we need to specify it manually. - self.cxx.link_flags += ['-loldnames'] - elif cxx_abi == 'none': - if self.target_info.is_windows(): - debug_suffix = 'd' if self.debug_build else '' - self.cxx.link_flags += ['-lmsvcrt%s' % debug_suffix] - else: - self.lit_config.fatal( - 'C++ ABI setting %s unsupported for tests' % cxx_abi) - - def configure_extra_library_flags(self): - if self.get_lit_bool('cxx_ext_threads', default=False): - self.cxx.link_flags += ['-lc++external_threads'] - self.target_info.add_cxx_link_flags(self.cxx.link_flags) - - def configure_coverage(self): - self.generate_coverage = self.get_lit_bool('generate_coverage', False) - if self.generate_coverage: - self.cxx.flags += ['-g', '--coverage'] - self.cxx.compile_flags += ['-O0'] - - def quote(self, s): - if platform.system() == 'Windows': - return lit.TestRunner.quote_windows_command([s]) - return pipes.quote(s) - - def configure_substitutions(self): - sub = self.config.substitutions - sub.append(('%{cxx}', self.quote(self.cxx.path))) - flags = self.cxx.flags + (self.cxx.modules_flags if self.cxx.use_modules else []) - compile_flags = self.cxx.compile_flags + (self.cxx.warning_flags if self.cxx.use_warnings else []) - sub.append(('%{flags}', ' '.join(map(self.quote, flags)))) - sub.append(('%{compile_flags}', ' '.join(map(self.quote, compile_flags)))) - sub.append(('%{link_flags}', ' '.join(map(self.quote, self.cxx.link_flags)))) - - codesign_ident = self.get_lit_conf('llvm_codesign_identity', '') - env_vars = ' '.join('%s=%s' % (k, self.quote(v)) for (k, v) in self.exec_env.items()) - exec_args = [ - '--execdir %T', - '--codesign_identity "{}"'.format(codesign_ident), - '--env {}'.format(env_vars) - ] - sub.append(('%{exec}', '{} {} -- '.format(self.executor, ' '.join(exec_args)))) - - def configure_env(self): - self.config.environment = dict(os.environ) - - def add_path(self, dest_env, new_path): - self.target_info.add_path(dest_env, new_path) diff --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py deleted file mode 100644 --- a/libcxx/utils/libcxx/test/target_info.py +++ /dev/null @@ -1,171 +0,0 @@ -#===----------------------------------------------------------------------===// -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===// - -import importlib -import lit.util -import os -import platform -import re -import subprocess -import sys - -from libcxx.util import executeCommand - -class DefaultTargetInfo(object): - def __init__(self, full_config): - self.full_config = full_config - self.executor = None - - def is_windows(self): - return False - - def is_zos(self): - return False - - def is_mingw(self): - return False - - def add_cxx_flags(self, flags): pass - def add_cxx_compile_flags(self, flags): pass - def add_cxx_link_flags(self, flags): pass - def allow_cxxabi_link(self): return True - - def add_path(self, dest_env, new_path): - if not new_path: - return - if 'PATH' not in dest_env: - dest_env['PATH'] = new_path - else: - split_char = ';' if self.is_windows() else ':' - dest_env['PATH'] = '%s%s%s' % (new_path, split_char, - dest_env['PATH']) - - -class DarwinLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(DarwinLocalTI, self).__init__(full_config) - - def add_cxx_flags(self, flags): - out, err, exit_code = executeCommand(['xcrun', '--show-sdk-path']) - if exit_code != 0: - self.full_config.lit_config.warning("Could not determine macOS SDK path! stderr was " + err) - if exit_code == 0 and out: - sdk_path = out.strip() - self.full_config.lit_config.note('using SDKROOT: %r' % sdk_path) - assert isinstance(sdk_path, str) - flags += ["-isysroot", sdk_path] - - def add_cxx_link_flags(self, flags): - flags += ['-lSystem'] - - def allow_cxxabi_link(self): - # Don't link libc++abi explicitly on OS X because the symbols - # should be available in libc++ directly. - return False - - -class FreeBSDLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(FreeBSDLocalTI, self).__init__(full_config) - - def add_cxx_link_flags(self, flags): - flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lcxxrt'] - - -class NetBSDLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(NetBSDLocalTI, self).__init__(full_config) - - def add_cxx_link_flags(self, flags): - flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lc++abi', - '-lunwind'] - - -class LinuxLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(LinuxLocalTI, self).__init__(full_config) - - def add_cxx_compile_flags(self, flags): - flags += ['-D__STDC_FORMAT_MACROS', - '-D__STDC_LIMIT_MACROS', - '-D__STDC_CONSTANT_MACROS'] - - def add_cxx_link_flags(self, flags): - enable_threads = ('no-threads' not in - self.full_config.config.available_features) - llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False) - shared_libcxx = self.full_config.get_lit_bool('enable_shared', True) - flags += ['-lm'] - if not llvm_unwinder: - flags += ['-lgcc_s', '-lgcc'] - if enable_threads: - flags += ['-lpthread'] - if not shared_libcxx: - flags += ['-lrt'] - flags += ['-lc'] - if llvm_unwinder: - flags += ['-lunwind', '-ldl'] - else: - flags += ['-lgcc_s'] - builtins_lib = self.full_config.get_lit_conf('builtins_library') - if builtins_lib: - flags += [builtins_lib] - else: - flags += ['-lgcc'] - has_libatomic = self.full_config.get_lit_bool('has_libatomic', False) - if has_libatomic: - flags += ['-latomic'] - san = self.full_config.get_lit_conf('use_sanitizer', '').strip() - if san: - # The libraries and their order are taken from the - # linkSanitizerRuntimeDeps function in - # clang/lib/Driver/Tools.cpp - flags += ['-lpthread', '-lrt', '-lm', '-ldl'] - -class LinuxRemoteTI(LinuxLocalTI): - def __init__(self, full_config): - super(LinuxRemoteTI, self).__init__(full_config) - -class WindowsLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(WindowsLocalTI, self).__init__(full_config) - - def is_windows(self): - return True - -class ZOSLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(ZOSLocalTI, self).__init__(full_config) - - def is_zos(self): - return True - -class MingwLocalTI(WindowsLocalTI): - def __init__(self, full_config): - super(MingwLocalTI, self).__init__(full_config) - - def is_mingw(self): - return True - -def make_target_info(full_config): - default = "libcxx.test.target_info.LocalTI" - info_str = full_config.get_lit_conf('target_info', default) - if info_str != default: - mod_path, _, info = info_str.rpartition('.') - mod = importlib.import_module(mod_path) - target_info = getattr(mod, info)(full_config) - full_config.lit_config.note("inferred target_info as: %r" % info_str) - return target_info - target_system = platform.system() - if target_system == 'Darwin': return DarwinLocalTI(full_config) - if target_system == 'FreeBSD': return FreeBSDLocalTI(full_config) - if target_system == 'NetBSD': return NetBSDLocalTI(full_config) - if target_system == 'Linux': return LinuxLocalTI(full_config) - if target_system == 'Windows': return WindowsLocalTI(full_config) - if target_system == 'OS/390': return ZOSLocalTI(full_config) - return DefaultTargetInfo(full_config) diff --git a/libcxx/utils/libcxx/util.py b/libcxx/utils/libcxx/util.py deleted file mode 100644 --- a/libcxx/utils/libcxx/util.py +++ /dev/null @@ -1,298 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===## - -from contextlib import contextmanager -import errno -import os -import platform -import signal -import subprocess -import sys -import tempfile -import threading - - -# FIXME: Most of these functions are cribbed from LIT -def to_bytes(str): - # Encode to UTF-8 to get binary data. - if isinstance(str, bytes): - return str - return str.encode('utf-8') - -def to_string(bytes): - if isinstance(bytes, str): - return bytes - return to_bytes(bytes) - -def convert_string(bytes): - try: - return to_string(bytes.decode('utf-8')) - except AttributeError: # 'str' object has no attribute 'decode'. - return str(bytes) - except UnicodeError: - return str(bytes) - - -def cleanFile(filename): - try: - os.remove(filename) - except OSError: - pass - - -@contextmanager -def guardedTempFilename(suffix='', prefix='', dir=None): - # Creates and yeilds a temporary filename within a with statement. The file - # is removed upon scope exit. - handle, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir) - os.close(handle) - yield name - cleanFile(name) - - -@contextmanager -def guardedFilename(name): - # yeilds a filename within a with statement. The file is removed upon scope - # exit. - yield name - cleanFile(name) - - -@contextmanager -def nullContext(value): - # yeilds a variable within a with statement. No action is taken upon scope - # exit. - yield value - - -def makeReport(cmd, out, err, rc): - report = "Command: %s\n" % cmd - report += "Exit Code: %d\n" % rc - if out: - report += "Standard Output:\n--\n%s--\n" % out - if err: - report += "Standard Error:\n--\n%s--\n" % err - report += '\n' - return report - - -def capture(args, env=None): - """capture(command) - Run the given command (or argv list) in a shell and - return the standard output. Raises a CalledProcessError if the command - exits with a non-zero status.""" - p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=env) - out, err = p.communicate() - out = convert_string(out) - err = convert_string(err) - if p.returncode != 0: - raise subprocess.CalledProcessError(cmd=args, - returncode=p.returncode, - output="{}\n{}".format(out, err)) - return out - - -def which(command, paths = None): - """which(command, [paths]) - Look up the given command in the paths string - (or the PATH environment variable, if unspecified).""" - - if paths is None: - paths = os.environ.get('PATH', '') - - # Check for absolute match first. - if os.path.isfile(command): - return command - - # Would be nice if Python had a lib function for this. - if not paths: - paths = os.defpath - - # Get suffixes to search. - # On Cygwin, 'PATHEXT' may exist but it should not be used. - if os.pathsep == ';': - pathext = os.environ.get('PATHEXT', '').split(';') - else: - pathext = [''] - - # Search the paths... - for path in paths.split(os.pathsep): - for ext in pathext: - p = os.path.join(path, command + ext) - if os.path.exists(p) and not os.path.isdir(p): - return p - - return None - - -def checkToolsPath(dir, tools): - for tool in tools: - if not os.path.exists(os.path.join(dir, tool)): - return False - return True - - -def whichTools(tools, paths): - for path in paths.split(os.pathsep): - if checkToolsPath(path, tools): - return path - return None - -def mkdir_p(path): - """mkdir_p(path) - Make the "path" directory, if it does not exist; this - will also make directories for any missing parent directories.""" - if not path or os.path.exists(path): - return - - parent = os.path.dirname(path) - if parent != path: - mkdir_p(parent) - - try: - os.mkdir(path) - except OSError: - e = sys.exc_info()[1] - # Ignore EEXIST, which may occur during a race condition. - if e.errno != errno.EEXIST: - raise - - -class ExecuteCommandTimeoutException(Exception): - def __init__(self, msg, out, err, exitCode): - assert isinstance(msg, str) - assert isinstance(out, str) - assert isinstance(err, str) - assert isinstance(exitCode, int) - self.msg = msg - self.out = out - self.err = err - self.exitCode = exitCode - -# Close extra file handles on UNIX (on Windows this cannot be done while -# also redirecting input). -kUseCloseFDs = not (platform.system() == 'Windows') -def executeCommand(command, cwd=None, env=None, input=None, timeout=0): - """ - Execute command ``command`` (list of arguments or string) - with - * working directory ``cwd`` (str), use None to use the current - working directory - * environment ``env`` (dict), use None for none - * Input to the command ``input`` (str), use string to pass - no input. - * Max execution time ``timeout`` (int) seconds. Use 0 for no timeout. - - Returns a tuple (out, err, exitCode) where - * ``out`` (str) is the standard output of running the command - * ``err`` (str) is the standard error of running the command - * ``exitCode`` (int) is the exitCode of running the command - - If the timeout is hit an ``ExecuteCommandTimeoutException`` - is raised. - """ - if input is not None: - input = to_bytes(input) - p = subprocess.Popen(command, cwd=cwd, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - env=env, close_fds=kUseCloseFDs) - timerObject = None - hitTimeOut = False - try: - if timeout > 0: - def killProcess(): - # We may be invoking a shell so we need to kill the - # process and all its children. - nonlocal hitTimeOut - hitTimeOut = True - killProcessAndChildren(p.pid) - - timerObject = threading.Timer(timeout, killProcess) - timerObject.start() - - out, err = p.communicate(input=input) - exitCode = p.wait() - finally: - if timerObject != None: - timerObject.cancel() - - # Ensure the resulting output is always of string type. - out = convert_string(out) - err = convert_string(err) - - if hitTimeOut: - raise ExecuteCommandTimeoutException( - msg='Reached timeout of {} seconds'.format(timeout), - out=out, - err=err, - exitCode=exitCode - ) - - # Detect Ctrl-C in subprocess. - if exitCode == -signal.SIGINT: - raise KeyboardInterrupt - - return out, err, exitCode - - -def killProcessAndChildren(pid): - """ - This function kills a process with ``pid`` and all its - running children (recursively). It is currently implemented - using the psutil module which provides a simple platform - neutral implementation. - - TODO: Reimplement this without using psutil so we can - remove our dependency on it. - """ - if platform.system() == 'AIX': - subprocess.call('kill -kill $(ps -o pid= -L{})'.format(pid), shell=True) - else: - import psutil - try: - psutilProc = psutil.Process(pid) - # Handle the different psutil API versions - try: - # psutil >= 2.x - children_iterator = psutilProc.children(recursive=True) - except AttributeError: - # psutil 1.x - children_iterator = psutilProc.get_children(recursive=True) - for child in children_iterator: - try: - child.kill() - except psutil.NoSuchProcess: - pass - psutilProc.kill() - except psutil.NoSuchProcess: - pass - - -def executeCommandVerbose(cmd, *args, **kwargs): - """ - Execute a command and print its output on failure. - """ - out, err, exitCode = executeCommand(cmd, *args, **kwargs) - if exitCode != 0: - report = makeReport(cmd, out, err, exitCode) - report += "\n\nFailed!" - sys.stderr.write('%s\n' % report) - return out, err, exitCode - - -def executeCommandOrDie(cmd, *args, **kwargs): - """ - Execute a command and print its output on failure. - """ - out, err, exitCode = executeCommand(cmd, *args, **kwargs) - if exitCode != 0: - report = makeReport(cmd, out, err, exitCode) - report += "\n\nFailed!" - sys.stderr.write('%s\n' % report) - sys.exit(exitCode) - return out, err, exitCode diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt --- a/libcxxabi/test/CMakeLists.txt +++ b/libcxxabi/test/CMakeLists.txt @@ -7,47 +7,7 @@ endif() endmacro() -if (NOT DEFINED LIBCXX_ENABLE_SHARED) - set(LIBCXX_ENABLE_SHARED ON) -endif() - -option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI - "Whether the libc++abi tests should link with the shared libc++abi library" - ${LIBCXXABI_ENABLE_SHARED}) - -option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX - "Whether the libc++abi tests should link with the shared libc++ library" - ${LIBCXX_ENABLE_SHARED}) - -if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI AND NOT LIBCXXABI_ENABLE_SHARED) - message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI being ON requires LIBCXXABI_ENABLE_SHARED to be ON") -endif() - -if(NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI AND NOT LIBCXXABI_ENABLE_STATIC) - message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI being OFF requires LIBCXXABI_ENABLE_STATIC to be ON") -endif() - -if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_SHARED) - message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being ON requires LIBCXX_ENABLE_SHARED to be ON") -endif() - -if(DEFINED LIBCXX_ENABLE_STATIC - AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX - AND NOT LIBCXX_ENABLE_STATIC) - message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON") -endif() - -pythonize_bool(LIBCXX_ENABLE_SHARED) -pythonize_bool(LIBCXXABI_ENABLE_SHARED) -pythonize_bool(LIBCXXABI_ENABLE_THREADS) pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) -pythonize_bool(LIBCXXABI_USE_COMPILER_RT) -pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) -pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS) -pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX) -pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI) -set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING - "TargetInfo to use when setting up test environment.") set(LIBCXXABI_EXECUTOR "${Python3_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/run.py" CACHE STRING "Executor to use when running tests.") diff --git a/libcxxabi/test/libcxxabi/__init__.py b/libcxxabi/test/libcxxabi/__init__.py deleted file mode 100644 diff --git a/libcxxabi/test/libcxxabi/test/__init__.py b/libcxxabi/test/libcxxabi/test/__init__.py deleted file mode 100644 diff --git a/libcxxabi/test/libcxxabi/test/config.py b/libcxxabi/test/libcxxabi/test/config.py deleted file mode 100644 --- a/libcxxabi/test/libcxxabi/test/config.py +++ /dev/null @@ -1,89 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===## -import os -import sys - -from libcxx.test.config import Configuration as LibcxxConfiguration -from libcxx.test.config import intMacroValue - - -class Configuration(LibcxxConfiguration): - # pylint: disable=redefined-outer-name - def __init__(self, lit_config, config): - super(Configuration, self).__init__(lit_config, config) - self.libcxxabi_hdr_root = None - self.libcxxabi_src_root = None - self.libcxxabi_obj_root = None - self.abi_library_root = None - self.libcxx_src_root = None - - def configure_src_root(self): - self.libcxxabi_hdr_root = self.get_lit_conf( - 'libcxxabi_hdr_root', - self.project_obj_root) - self.libcxxabi_src_root = self.get_lit_conf( - 'libcxxabi_src_root', - os.path.dirname(self.config.test_source_root)) - self.libcxx_src_root = self.get_lit_conf( - 'libcxx_src_root', - os.path.join(self.libcxxabi_src_root, '/../libcxx')) - - def configure_obj_root(self): - self.libcxxabi_obj_root = self.get_lit_conf('libcxxabi_obj_root') - super(Configuration, self).configure_obj_root() - - def configure_features(self): - super(Configuration, self).configure_features() - if not self.get_lit_bool('llvm_unwinder', False): - self.config.available_features.add('libcxxabi-has-system-unwinder') - - def configure_compile_flags(self): - self.cxx.compile_flags += [ - '-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS', - ] - if self.get_lit_bool('enable_exceptions', True): - self.cxx.compile_flags += ['-funwind-tables'] - if not self.get_lit_bool('enable_threads', True): - self.cxx.compile_flags += ['-D_LIBCXXABI_HAS_NO_THREADS'] - self.config.available_features.add('no-threads') - super(Configuration, self).configure_compile_flags() - - def configure_compile_flags_header_includes(self): - cxx_headers = self.get_lit_conf('cxx_headers', None) or \ - os.path.join(self.libcxxabi_hdr_root, 'include', 'c++', 'v1') - if cxx_headers == '': - self.lit_config.note('using the systems c++ headers') - else: - self.cxx.compile_flags += ['-nostdinc++'] - if not os.path.isdir(cxx_headers): - self.lit_config.fatal("cxx_headers='%s' is not a directory." - % cxx_headers) - (path, version) = os.path.split(cxx_headers) - (path, cxx) = os.path.split(path) - triple = self.get_lit_conf('target_triple', None) - if triple is not None: - cxx_target_headers = os.path.join(path, triple, cxx, version) - if os.path.isdir(cxx_target_headers): - self.cxx.compile_flags += ['-I' + cxx_target_headers] - self.cxx.compile_flags += ['-I' + cxx_headers] - self.cxx.compile_flags += ['-I' + os.path.join(self.libcxx_src_root, 'src')] - - libcxxabi_headers = self.get_lit_conf( - 'libcxxabi_headers', - os.path.join(self.libcxxabi_src_root, 'include')) - if not os.path.isdir(libcxxabi_headers): - self.lit_config.fatal("libcxxabi_headers='%s' is not a directory." - % libcxxabi_headers) - self.cxx.compile_flags += ['-I' + libcxxabi_headers] - - libunwind_headers = self.get_lit_conf('libunwind_headers', None) - if self.get_lit_bool('llvm_unwinder', False) and libunwind_headers: - if not os.path.isdir(libunwind_headers): - self.lit_config.fatal("libunwind_headers='%s' is not a directory." - % libunwind_headers) - self.cxx.compile_flags += ['-I' + libunwind_headers] diff --git a/libcxxabi/test/lit.site.cfg.in b/libcxxabi/test/lit.site.cfg.in deleted file mode 100644 --- a/libcxxabi/test/lit.site.cfg.in +++ /dev/null @@ -1,65 +0,0 @@ -@AUTO_GEN_COMMENT@ - -@SERIALIZED_LIT_PARAMS@ - -import os -import site - -config.cxx_under_test = "@CMAKE_CXX_COMPILER@" -config.project_obj_root = "@CMAKE_BINARY_DIR@" -config.install_root = "@CMAKE_BINARY_DIR@" -config.libcxxabi_hdr_root = "@LIBCXXABI_HEADER_DIR@" -config.libcxxabi_src_root = "@LIBCXXABI_SOURCE_DIR@" -config.libcxxabi_obj_root = "@LIBCXXABI_BINARY_DIR@" -config.abi_library_root = "@LIBCXXABI_LIBRARY_DIR@" -config.libcxx_src_root = "@LIBCXXABI_LIBCXX_PATH@" -config.cxx_headers = "@LIBCXXABI_LIBCXX_INCLUDES@" -config.libunwind_headers = "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@" -config.cxx_library_root = "@LIBCXXABI_LIBCXX_LIBRARY_PATH@" -config.llvm_unwinder = @LIBCXXABI_USE_LLVM_UNWINDER@ -config.builtins_library = "@LIBCXXABI_BUILTINS_LIBRARY@" -config.enable_threads = @LIBCXXABI_ENABLE_THREADS@ -config.target_info = "@LIBCXXABI_TARGET_INFO@" -config.executor = "@LIBCXXABI_EXECUTOR@" -config.libcxxabi_shared = @LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI@ -config.enable_shared = @LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX@ -config.host_triple = "@LLVM_HOST_TRIPLE@" -config.sysroot = "@CMAKE_SYSROOT@" -config.gcc_toolchain = "@CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN@" -config.cxx_ext_threads = @LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY@ - -config.pstl_src_root = "@ParallelSTL_SOURCE_DIR@" if @LIBCXX_ENABLE_PARALLEL_ALGORITHMS@ else None -config.pstl_obj_root = "@ParallelSTL_BINARY_DIR@" if @LIBCXX_ENABLE_PARALLEL_ALGORITHMS@ else None - -# Code signing -config.llvm_codesign_identity = "@LLVM_CODESIGNING_IDENTITY@" - -site.addsitedir(os.path.join(config.libcxxabi_src_root, 'test')) -site.addsitedir(os.path.join(config.libcxx_src_root, 'utils')) - -# name: The name of this test suite. -config.name = 'libc++abi' - -# suffixes: A list of file extensions to treat as test files. -config.suffixes = ['.cpp', '.s'] - -# test_source_root: The root path where tests are located. -config.test_source_root = os.path.join(config.libcxxabi_src_root, 'test') - -# Allow expanding substitutions that are based on other substitutions -config.recursiveExpansionLimit = 10 - -# Infer the test_exec_root from the build directory. -config.test_exec_root = os.path.join(config.libcxxabi_obj_root, 'test') - -import libcxx.test.format -config.test_format = libcxx.test.format.CxxStandardLibraryTest() - -lit_config.note('Using configuration variant: libcxxabi') -import libcxxabi.test.config -configuration = libcxxabi.test.config.Configuration(lit_config, config) -configuration.configure() -configuration.print_config_info() - -lit_config.warning("This is a legacy testing configuration which will be removed in LLVM 16. " - "Please use one of the configurations in libcxxabi/test/configs or define your own.") diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -60,10 +60,6 @@ cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY "Install the shared libunwind library." ON "LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF) -set(LIBUNWIND_TEST_LINKER_FLAGS "" CACHE STRING - "Additional linker flags for test programs.") -set(LIBUNWIND_TEST_COMPILER_FLAGS "" CACHE STRING - "Additional compiler flags for test programs.") # TODO: Remove this after branching for LLVM 15 if(LIBUNWIND_SYSROOT OR LIBUNWIND_TARGET_TRIPLE OR LIBUNWIND_GCC_TOOLCHAIN) diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt --- a/libunwind/test/CMakeLists.txt +++ b/libunwind/test/CMakeLists.txt @@ -7,19 +7,9 @@ endif() endmacro() -if (NOT DEFINED LIBCXX_ENABLE_SHARED) - set(LIBCXX_ENABLE_SHARED ON) -endif() - pythonize_bool(LIBUNWIND_ENABLE_CET) -pythonize_bool(LIBCXX_ENABLE_SHARED) -pythonize_bool(LIBUNWIND_ENABLE_SHARED) pythonize_bool(LIBUNWIND_ENABLE_THREADS) pythonize_bool(LIBUNWIND_USES_ARM_EHABI) -pythonize_bool(LIBUNWIND_USE_COMPILER_RT) -pythonize_bool(LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY) -set(LIBUNWIND_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING - "TargetInfo to use when setting up test environment.") set(LIBUNWIND_EXECUTOR "${Python3_EXECUTABLE} ${LIBUNWIND_LIBCXX_PATH}/utils/run.py" CACHE STRING "Executor to use when running tests.") diff --git a/libunwind/test/configs/cmake-bridge.cfg.in b/libunwind/test/configs/cmake-bridge.cfg.in --- a/libunwind/test/configs/cmake-bridge.cfg.in +++ b/libunwind/test/configs/cmake-bridge.cfg.in @@ -21,7 +21,6 @@ config.test_format = libcxx.test.format.CxxStandardLibraryTest() config.recursiveExpansionLimit = 10 config.test_exec_root = '@CMAKE_BINARY_DIR@' -config.target_info = "@LIBUNWIND_TARGET_INFO@" # Add a few features that are common to all the configurations if @LIBUNWIND_USES_ARM_EHABI@: diff --git a/libunwind/test/libunwind/__init__.py b/libunwind/test/libunwind/__init__.py deleted file mode 100644 diff --git a/libunwind/test/libunwind/test/__init__.py b/libunwind/test/libunwind/test/__init__.py deleted file mode 100644 diff --git a/libunwind/test/libunwind/test/config.py b/libunwind/test/libunwind/test/config.py deleted file mode 100644 --- a/libunwind/test/libunwind/test/config.py +++ /dev/null @@ -1,71 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===## -import os -import sys - -from libcxx.test.config import Configuration as LibcxxConfiguration - - -class Configuration(LibcxxConfiguration): - # pylint: disable=redefined-outer-name - def __init__(self, lit_config, config): - super(Configuration, self).__init__(lit_config, config) - self.libunwind_src_root = None - self.libunwind_obj_root = None - self.abi_library_root = None - self.libcxx_src_root = None - - def configure_src_root(self): - self.libunwind_src_root = (self.get_lit_conf('libunwind_src_root') - or os.path.dirname(self.config.test_source_root)) - self.libcxx_src_root = (self.get_lit_conf('libcxx_src_root') - or os.path.join(self.libunwind_src_root, '..', 'libcxx')) - - def configure_obj_root(self): - self.libunwind_obj_root = self.get_lit_conf('libunwind_obj_root') - super(Configuration, self).configure_obj_root() - - def has_cpp_feature(self, feature, required_value): - return int(self.cxx.dumpMacros().get('__cpp_' + feature, 0)) >= required_value - - def configure_features(self): - super(Configuration, self).configure_features() - if self.get_lit_bool('arm_ehabi', False): - self.config.available_features.add('libunwind-arm-ehabi') - - def configure_compile_flags(self): - # Stack unwinding tests need unwinding tables and these are not - # generated by default on all Targets. - self.cxx.compile_flags += ['-funwind-tables'] - # Make symbols available in the tests. - triple = self.get_lit_conf('target_triple', None) - if triple is not None and 'linux' in triple: - self.cxx.link_flags += ['-Wl,--export-dynamic'] - if not self.get_lit_bool('enable_threads', True): - self.cxx.compile_flags += ['-D_LIBUNWIND_HAS_NO_THREADS'] - self.config.available_features.add('libunwind-no-threads') - if self.get_lit_bool('x86_cet', False): - self.cxx.compile_flags += ['-fcf-protection=full'] - super(Configuration, self).configure_compile_flags() - - def configure_compile_flags_header_includes(self): - libunwind_headers = self.get_lit_conf( - 'libunwind_headers', - os.path.join(self.libunwind_src_root, 'include')) - if not os.path.isdir(libunwind_headers): - self.lit_config.fatal("libunwind_headers='%s' is not a directory." - % libunwind_headers) - self.cxx.compile_flags += ['-I' + libunwind_headers] - - def configure_link_flags_cxx_library(self): - # libunwind tests should not link with libc++ - pass - - def configure_link_flags_abi_library(self): - # libunwind tests should not link with libc++abi - pass diff --git a/libunwind/test/lit.site.cfg.in b/libunwind/test/lit.site.cfg.in deleted file mode 100644 --- a/libunwind/test/lit.site.cfg.in +++ /dev/null @@ -1,61 +0,0 @@ -@AUTO_GEN_COMMENT@ - -@SERIALIZED_LIT_PARAMS@ - -import os -import site - -config.cxx_under_test = "@CMAKE_CXX_COMPILER@" -config.project_obj_root = "@CMAKE_BINARY_DIR@" -config.install_root = "@CMAKE_BINARY_DIR@" -config.libunwind_src_root = "@LIBUNWIND_SOURCE_DIR@" -config.libunwind_obj_root = "@LIBUNWIND_BINARY_DIR@" -config.abi_library_root = "@LIBUNWIND_LIBRARY_DIR@" -config.libcxx_src_root = "@LIBUNWIND_LIBCXX_PATH@" -config.libunwind_headers = "@LIBUNWIND_SOURCE_DIR@/include" -config.cxx_library_root = "@LIBUNWIND_LIBCXX_LIBRARY_PATH@" -config.llvm_unwinder = True -config.builtins_library = "@LIBUNWIND_BUILTINS_LIBRARY@" -config.enable_threads = @LIBUNWIND_ENABLE_THREADS@ -config.target_info = "@LIBUNWIND_TARGET_INFO@" -config.test_linker_flags = "@LIBUNWIND_TEST_LINKER_FLAGS@" -config.test_compiler_flags = "@LIBUNWIND_TEST_COMPILER_FLAGS@" -config.executor = "@LIBUNWIND_EXECUTOR@" -config.libunwind_shared = @LIBUNWIND_ENABLE_SHARED@ -config.enable_shared = @LIBCXX_ENABLE_SHARED@ -config.arm_ehabi = @LIBUNWIND_USES_ARM_EHABI@ -config.host_triple = "@LLVM_HOST_TRIPLE@" -config.sysroot = "@CMAKE_SYSROOT@" -config.gcc_toolchain = "@CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN@" -config.cxx_ext_threads = @LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@ -config.x86_cet = @LIBUNWIND_ENABLE_CET@ - -site.addsitedir(os.path.join(config.libunwind_src_root, 'test')) -site.addsitedir(os.path.join(config.libcxx_src_root, 'utils')) - -# name: The name of this test suite. -config.name = 'libunwind' - -# suffixes: A list of file extensions to treat as test files. -config.suffixes = ['.cpp', '.s'] - -# test_source_root: The root path where tests are located. -config.test_source_root = os.path.join(config.libunwind_src_root, 'test') - -# Allow expanding substitutions that are based on other substitutions -config.recursiveExpansionLimit = 10 - -# Infer the test_exec_root from the build directory. -config.test_exec_root = os.path.join(config.libunwind_obj_root, 'test') - -import libcxx.test.format -config.test_format = libcxx.test.format.CxxStandardLibraryTest() - -lit_config.note('Using configuration variant: libunwind') -import libunwind.test.config -configuration = libunwind.test.config.Configuration(lit_config, config) -configuration.configure() -configuration.print_config_info() - -lit_config.warning("This is a legacy testing configuration which will be removed in LLVM 16. " - "Please use one of the configurations in libunwind/test/configs or define your own.")