[libc++abi] Use from-scratch testing configs for libc++abi by default

Like we have been doing for libc++ for a while now, start using
from-scratch testing configurations for libc++abi.

As a fly-by fix, remove the LIBCXXABI_NO_TIMER macro, which was defined
but never used.

Differential Revision: https://reviews.llvm.org/D125242
This commit is contained in:
Louis Dionne 2022-05-09 11:54:10 -04:00
parent f366acdbf6
commit 851bfc07c8
21 changed files with 223 additions and 29 deletions

View File

@ -143,7 +143,24 @@ endif()
option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
"Do not export any symbols from the static library." ${LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT})
set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-shared-gcc.cfg.in")
elseif(MINGW)
set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-mingw.cfg.in")
elseif(WIN32) # clang-cl
if (LIBCXXABI_ENABLE_SHARED)
set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-shared-clangcl.cfg.in")
else()
set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-static-clangcl.cfg.in")
endif()
else()
if (LIBCXXABI_ENABLE_SHARED)
set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-shared.cfg.in")
else()
set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-static.cfg.in")
endif()
endif()
set(LIBCXXABI_TEST_CONFIG "${LIBCXXABI_DEFAULT_TEST_CONFIG}" CACHE STRING
"The path to the Lit testing configuration to use when running the tests.
If a relative path is provided, it is assumed to be relative to '<monorepo>/libcxxabi/test/configs'.")
if (NOT IS_ABSOLUTE "${LIBCXXABI_TEST_CONFIG}")

View File

@ -45,7 +45,7 @@ config.substitutions.append(('%{flags}',
'-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} -DLIBCXXABI_NO_TIMER -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
'-I %{libcxx}/test/support -I %{libcxx}/src'
))
config.substitutions.append(('%{link_flags}',

View File

@ -6,7 +6,7 @@ config.substitutions.append(('%{flags}',
'-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} -DLIBCXXABI_NO_TIMER -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
'-I %{libcxx}/test/support -I %{libcxx}/src'
))
config.substitutions.append(('%{link_flags}',

View File

@ -30,6 +30,11 @@ config.substitutions.append(('%{cxx}', '@CMAKE_CXX_COMPILER@'))
config.substitutions.append(('%{libcxx}', '@LIBCXXABI_LIBCXX_PATH@'))
config.substitutions.append(('%{include}', '@LIBCXXABI_SOURCE_DIR@/include'))
config.substitutions.append(('%{cxx-include}', '@LIBCXXABI_HEADER_DIR@/include/c++/v1'))
config.substitutions.append(('%{cxx-target-include}', '@LIBCXXABI_HEADER_DIR@/%{triple}/include/c++/v1'))
config.substitutions.append(('%{cxx-target-include}', '@LIBCXXABI_HEADER_DIR@/include/%{triple}/c++/v1'))
config.substitutions.append(('%{lib}', '@LIBCXXABI_LIBRARY_DIR@'))
config.substitutions.append(('%{executor}', '@LIBCXXABI_EXECUTOR@'))
if @LIBCXXABI_USE_LLVM_UNWINDER@:
config.substitutions.append(('%{maybe-include-libunwind}', '-I "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@"'))
else:
config.substitutions.append(('%{maybe-include-libunwind}', ''))

View File

@ -4,8 +4,8 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
config.substitutions.append(('%{flags}',''))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} ' +
'-D__LIBC_NO_CPP_MATH_OVERLOADS__ -DLIBCXXABI_NO_TIMER ' +
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} ' +
'-D__LIBC_NO_CPP_MATH_OVERLOADS__ ' +
'-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
'-I %{libcxx}/test/support -I %{libcxx}/src'
))

View File

@ -6,7 +6,7 @@ config.substitutions.append(('%{flags}',
'-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} -DLIBCXXABI_NO_TIMER -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
'-I %{libcxx}/test/support -I %{libcxx}/src'
))
config.substitutions.append(('%{link_flags}',

View File

@ -0,0 +1,25 @@
# This testing configuration handles running the test suite against LLVM's libc++abi
# using either a DLL or a static library, with MinGW/Clang on Windows.
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
config.substitutions.append(('%{flags}', ''))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
))
config.substitutions.append(('%{link_flags}',
'-nostdlib++ -L %{lib} -lc++ -lc++abi'
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T --env PATH=%{lib} -- '
))
import os, site
site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
import libcxx.test.params, libcxx.test.newconfig
libcxx.test.newconfig.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)

View File

@ -0,0 +1,25 @@
# This testing configuration handles running the test suite against LLVM's libc++abi
# using a DLL, with Clang-cl on Windows.
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
config.substitutions.append(('%{flags}', '--driver-mode=g++'))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX'
))
config.substitutions.append(('%{link_flags}',
'-nostdlib -L %{lib} -lc++ -lc++abi -lmsvcrt -lmsvcprt -loldnames'
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T --env PATH=%{lib} -- '
))
import os, site
site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
import libcxx.test.params, libcxx.test.newconfig
libcxx.test.newconfig.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)

View File

@ -0,0 +1,26 @@
# This testing configuration handles running the test suite against LLVM's libc++abi
# using a shared library, with GCC. This is done differently from Clang because
# GCC does not support the -nostdlib++ command-line flag.
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
config.substitutions.append(('%{flags}', ''))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
))
config.substitutions.append(('%{link_flags}',
'-L %{lib} -Wl,-rpath,%{lib} -nodefaultlibs -lc++ -lc++abi -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc -latomic'
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T -- '
))
import os, site
site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
import libcxx.test.params, libcxx.test.newconfig
libcxx.test.newconfig.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)

View File

@ -0,0 +1,27 @@
# This testing configuration handles running the test suite against LLVM's libc++abi
# using a shared library.
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
config.substitutions.append(('%{flags}',
'-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
))
config.substitutions.append(('%{link_flags}',
'-nostdlib++ -L %{lib} -Wl,-rpath,%{lib} -lc++ -lc++abi -pthread'
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T -- '
))
import os, site
site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
import libcxx.test.params, libcxx.test.newconfig
libcxx.test.newconfig.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)

View File

@ -0,0 +1,25 @@
# This testing configuration handles running the test suite against LLVM's libc++abi
# using a static library, with Clang-cl on Windows.
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
config.substitutions.append(('%{flags}', '--driver-mode=g++'))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX'
))
config.substitutions.append(('%{link_flags}',
'-nostdlib -L %{lib} -llibc++ -llibc++abi -lmsvcrt -lmsvcprt -loldnames'
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T --env PATH=%{lib} -- '
))
import os, site
site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
import libcxx.test.params, libcxx.test.newconfig
libcxx.test.newconfig.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)

View File

@ -0,0 +1,27 @@
# This testing configuration handles running the test suite against LLVM's libc++abi
# using a static library.
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
config.substitutions.append(('%{flags}',
'-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
))
config.substitutions.append(('%{link_flags}',
'-nostdlib++ -L %{lib} -lc++ -lc++abi -pthread'
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T -- '
))
import os, site
site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
import libcxx.test.params, libcxx.test.newconfig
libcxx.test.newconfig.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-threads
// UNSUPPORTED: libcpp-has-no-threads
// REQUIRES: linux
#include <assert.h>

View File

@ -10,7 +10,7 @@
// what pthread_cancel does.
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxxabi-no-threads
// UNSUPPORTED: libcpp-has-no-threads
// UNSUPPORTED: no-exceptions
#include <assert.h>

View File

@ -8,6 +8,13 @@
//
// UNSUPPORTED: c++03
// Necessary because we include a private header of libc++abi, which
// only understands _LIBCXXABI_HAS_NO_THREADS.
#include "test_macros.h"
#ifdef TEST_HAS_NO_THREADS
# define _LIBCXXABI_HAS_NO_THREADS
#endif
#define TESTING_CXA_GUARD
#include "../src/cxa_guard_impl.h"
#include <cassert>
@ -117,7 +124,7 @@ uint32_t MockGetThreadID() { return 0; }
int main(int, char**) {
{
#if defined(_LIBCXXABI_HAS_NO_THREADS)
#if defined(TEST_HAS_NO_THREADS)
static_assert(CurrentImplementation == Implementation::NoThreads, "");
static_assert(std::is_same<SelectedImplementation, NoThreadsGuard>::value, "");
#else
@ -129,7 +136,7 @@ int main(int, char**) {
#endif
}
{
#if (defined(__APPLE__) || defined(__linux__)) && !defined(_LIBCXXABI_HAS_NO_THREADS)
#if (defined(__APPLE__) || defined(__linux__)) && !defined(TEST_HAS_NO_THREADS)
assert(PlatformThreadID);
#endif
if (PlatformThreadID != nullptr) {

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxxabi-no-threads
// UNSUPPORTED: libcpp-has-no-threads
// UNSUPPORTED: no-exceptions
#define TESTING_CXA_GUARD

View File

@ -50,7 +50,7 @@ class Configuration(LibcxxConfiguration):
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('libcxxabi-no-threads')
self.config.available_features.add('libcpp-has-no-threads')
super(Configuration, self).configure_compile_flags()
def configure_compile_flags_header_includes(self):

View File

@ -14,6 +14,8 @@
#include "../src/cxa_exception.h"
#include "test_macros.h"
typedef __cxxabiv1::__cxa_eh_globals globals_t ;
void *thread_code (void *parm) {
@ -29,20 +31,20 @@ void *thread_code (void *parm) {
std::printf("Got different globals!\n");
*result = (size_t) glob1;
#ifndef _LIBCXXABI_HAS_NO_THREADS
#ifndef TEST_HAS_NO_THREADS
sleep ( 1 );
#endif
return parm;
}
#ifndef _LIBCXXABI_HAS_NO_THREADS
#ifndef TEST_HAS_NO_THREADS
#define NUMTHREADS 10
size_t thread_globals [ NUMTHREADS ] = { 0 };
std::__libcpp_thread_t threads [ NUMTHREADS ];
#endif
int main() {
#ifndef _LIBCXXABI_HAS_NO_THREADS
#ifndef TEST_HAS_NO_THREADS
// Make the threads, let them run, and wait for them to finish
for ( int i = 0; i < NUMTHREADS; ++i )
std::__libcpp_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
@ -65,10 +67,10 @@ int main() {
}
}
return retVal;
#else // _LIBCXXABI_HAS_NO_THREADS
#else // TEST_HAS_NO_THREADS
size_t thread_globals;
thread_code(&thread_globals);
// Check that __cxa_get_globals() is not NULL.
return (thread_globals == 0) ? 1 : 0;
#endif // !_LIBCXXABI_HAS_NO_THREADS
#endif // !TEST_HAS_NO_THREADS
}

View File

@ -11,6 +11,15 @@
#include <__threading_support>
// UNSUPPORTED: modules-build && libcpp-has-no-threads
// Necessary because we include a private source file of libc++abi, which
// only understands _LIBCXXABI_HAS_NO_THREADS.
#include "test_macros.h"
#ifdef TEST_HAS_NO_THREADS
# define _LIBCXXABI_HAS_NO_THREADS
#endif
typedef std::deque<void *> container;
// #define DEBUG_FALLBACK_MALLOC

View File

@ -6,17 +6,16 @@
//
//===----------------------------------------------------------------------===//
#include "cxxabi.h"
#include <cassert>
#ifndef _LIBCXXABI_HAS_NO_THREADS
#include <thread>
#include "make_test_thread.h"
#endif
#include <cxxabi.h>
#include "test_macros.h"
#ifndef TEST_HAS_NO_THREADS
# include <thread>
# include "make_test_thread.h"
#endif
// Ensure that we initialize each variable once and only once.
namespace test1 {
static int run_count = 0;
@ -83,7 +82,7 @@ namespace test3 {
}
}
#ifndef _LIBCXXABI_HAS_NO_THREADS
#ifndef TEST_HAS_NO_THREADS
// A simple thread test of two threads racing to initialize a variable. This
// isn't guaranteed to catch any particular threading problems.
namespace test4 {
@ -136,14 +135,14 @@ namespace test5 {
assert(run_count == 1);
}
}
#endif /* _LIBCXXABI_HAS_NO_THREADS */
#endif /* TEST_HAS_NO_THREADS */
int main(int, char**)
{
test1::test();
test2::test();
test3::test();
#ifndef _LIBCXXABI_HAS_NO_THREADS
#ifndef TEST_HAS_NO_THREADS
test4::test();
test5::test();
#endif

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxxabi-no-threads
// UNSUPPORTED: libcpp-has-no-threads
#include <cassert>
#include <thread>