Skip to content

Commit

Permalink
[libc++abi] Use from-scratch testing configs for libc++abi by default
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ldionne committed May 26, 2022
1 parent f366acd commit 851bfc0
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 29 deletions.
19 changes: 18 additions & 1 deletion libcxxabi/CMakeLists.txt
Expand Up @@ -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}")
Expand Down
Expand Up @@ -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}',
Expand Down
2 changes: 1 addition & 1 deletion libcxxabi/test/configs/apple-libc++abi-shared.cfg.in
Expand Up @@ -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}',
Expand Down
7 changes: 6 additions & 1 deletion libcxxabi/test/configs/cmake-bridge.cfg.in
Expand Up @@ -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}', ''))
4 changes: 2 additions & 2 deletions libcxxabi/test/configs/ibm-libc++abi-shared.cfg.in
Expand Up @@ -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'
))
Expand Down
2 changes: 1 addition & 1 deletion libcxxabi/test/configs/llvm-libc++abi-merged.cfg.in
Expand Up @@ -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}',
Expand Down
25 changes: 25 additions & 0 deletions libcxxabi/test/configs/llvm-libc++abi-mingw.cfg.in
@@ -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
)
25 changes: 25 additions & 0 deletions libcxxabi/test/configs/llvm-libc++abi-shared-clangcl.cfg.in
@@ -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
)
26 changes: 26 additions & 0 deletions libcxxabi/test/configs/llvm-libc++abi-shared-gcc.cfg.in
@@ -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
)
27 changes: 27 additions & 0 deletions libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in
@@ -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
)
25 changes: 25 additions & 0 deletions libcxxabi/test/configs/llvm-libc++abi-static-clangcl.cfg.in
@@ -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
)
27 changes: 27 additions & 0 deletions libcxxabi/test/configs/llvm-libc++abi-static.cfg.in
@@ -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
)
2 changes: 1 addition & 1 deletion libcxxabi/test/cxa_thread_atexit_test.pass.cpp
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: libcxxabi-no-threads
// UNSUPPORTED: libcpp-has-no-threads
// REQUIRES: linux

#include <assert.h>
Expand Down
2 changes: 1 addition & 1 deletion libcxxabi/test/forced_unwind3.pass.cpp
Expand Up @@ -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>
Expand Down
11 changes: 9 additions & 2 deletions libcxxabi/test/guard_test_basic.pass.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion libcxxabi/test/guard_threaded_test.pass.cpp
Expand Up @@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03
// UNSUPPORTED: libcxxabi-no-threads
// UNSUPPORTED: libcpp-has-no-threads
// UNSUPPORTED: no-exceptions

#define TESTING_CXA_GUARD
Expand Down
2 changes: 1 addition & 1 deletion libcxxabi/test/libcxxabi/test/config.py
Expand Up @@ -50,7 +50,7 @@ def configure_compile_flags(self):
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):
Expand Down
12 changes: 7 additions & 5 deletions libcxxabi/test/test_exception_storage.pass.cpp
Expand Up @@ -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) {
Expand All @@ -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));
Expand All @@ -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
}
9 changes: 9 additions & 0 deletions libcxxabi/test/test_fallback_malloc.pass.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 851bfc0

Please sign in to comment.