Skip to content

Commit 2e4227f

Browse files
committed
[libc++] Add testing configurations for libstdc++ and a native stdlib
This allows running the test suite against the native Standard Library on most systems, and against libstdc++ installed at a custom location. Of course, these configurations don't run 100% clean at the moment. In particular, running against the native stdlib is almost guaranteed not to work out-of-the-box, since the test suite generally contains tests for things that have been implemented on tip-of-trunk but not released to most major platforms yet. However, having an easy way to run the test suite against that library is still both useful and interesting.
1 parent b64c1de commit 2e4227f

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#
2+
# This testing configuration runs the test suite using the libstdc++ Standard library.
3+
#
4+
# The additional '--param libstdcxx-install-prefix=<PATH>' must be provided when invoking
5+
# lit for the configuration to find the appropriate headers and library.
6+
#
7+
8+
import os, site
9+
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
10+
import libcxx.test.params, libcxx.test.config, libcxx.test.dsl
11+
12+
# Basic configuration of the test suite
13+
config.name = 'libstdc++'
14+
config.test_source_root = os.path.join('@LIBCXX_SOURCE_DIR@', 'test')
15+
config.test_format = libcxx.test.format.CxxStandardLibraryTest()
16+
config.recursiveExpansionLimit = 10
17+
config.test_exec_root = os.path.join('@CMAKE_BINARY_DIR@', 'test')
18+
19+
# Additional parameters for libstdc++
20+
LIBSTDCXX_PARAMETERS = [
21+
libcxx.test.dsl.Parameter(name='libstdcxx-install-prefix', type=str,
22+
actions=lambda path: [libcxx.test.dsl.AddSubstitution('%{libstdcxx-install-prefix}', path)],
23+
help="""
24+
The installation prefix where libstdc++ was installed. This is used to find the libstdc++ headers,
25+
link against its built library, etc.
26+
"""),
27+
]
28+
29+
config.substitutions.append(('%{libcxx-dir}', '@LIBCXX_SOURCE_DIR@'))
30+
31+
# Configure the compiler and flags
32+
config.compiler = "@CMAKE_CXX_COMPILER@"
33+
config.target_triple = "@LLVM_DEFAULT_TARGET_TRIPLE@"
34+
config.stdlib = 'libstdc++'
35+
36+
config.substitutions.append(('%{flags}',
37+
'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
38+
))
39+
config.substitutions.append(('%{compile_flags}',
40+
'-nostdinc++ -isystem %{libstdcxx-install-prefix}/include/c++/14 -isystem %{libstdcxx-install-prefix}/include/c++/14/aarch64-apple-darwin23 -I %{libcxx-dir}/test/support'
41+
))
42+
config.substitutions.append(('%{link_flags}',
43+
'-nostdlib++ -L %{libstdcxx-install-prefix}/lib/gcc/14 -Wl,-rpath,%{libstdcxx-install-prefix}/lib/gcc/14 -lstdc++'
44+
))
45+
config.substitutions.append(('%{exec}',
46+
'%{executor} --execdir %T -- '
47+
))
48+
49+
import os, site
50+
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
51+
import libcxx.test.params, libcxx.test.config
52+
libcxx.test.config.configure(
53+
libcxx.test.params.DEFAULT_PARAMETERS + LIBSTDCXX_PARAMETERS,
54+
libcxx.test.features.DEFAULT_FEATURES,
55+
config,
56+
lit_config
57+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# This testing configuration handles running the test suite against the
3+
# native C++ Standard Library, i.e. whatever standard library is used by
4+
# default when no special compiler flags are provided.
5+
#
6+
7+
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
8+
9+
config.substitutions.append(('%{flags}',
10+
'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
11+
))
12+
config.substitutions.append(('%{compile_flags}', '-I %{libcxx-dir}/test/support'))
13+
config.substitutions.append(('%{link_flags}', ''))
14+
config.substitutions.append(('%{exec}', '%{executor} --execdir %T -- '))
15+
16+
import os, site
17+
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
18+
import libcxx.test.params, libcxx.test.config
19+
libcxx.test.config.configure(
20+
libcxx.test.params.DEFAULT_PARAMETERS,
21+
libcxx.test.features.DEFAULT_FEATURES,
22+
config,
23+
lit_config
24+
)

0 commit comments

Comments
 (0)