Skip to content

Commit 81dcbef

Browse files
authored
[libc++] Add testing configurations for libstdc++ and a native stdlib (#98539)
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 05137cc commit 81dcbef

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#
2+
# This testing configuration runs the test suite using the libstdc++ Standard library.
3+
#
4+
# The additional '--param libstdcxx-install-prefix=<PATH>', '--param libstdcxx-triple=<TRIPLE>' and
5+
# '--param libstdcxx-version=<VERSION>' lit parameters must be provided when invoking lit for the
6+
# configuration to find the appropriate headers and library.
7+
#
8+
# For example:
9+
#
10+
# $ ./libcxx/utils/libcxx-lit <BUILD> -sv libcxx/test/std --param libstdcxx-install-prefix=/opt/homebrew/Cellar/gcc/14.1.0_1 \
11+
# --param libstdcxx-version=14 \
12+
# --param libstdcxx-triple=aarch64-apple-darwin22
13+
#
14+
15+
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
16+
17+
import os, site
18+
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
19+
import libcxx.test.params, libcxx.test.config, libcxx.test.dsl
20+
21+
# Additional parameters for libstdc++
22+
LIBSTDCXX_PARAMETERS = [
23+
libcxx.test.dsl.Parameter(name='libstdcxx-install-prefix', type=str,
24+
actions=lambda path: [libcxx.test.dsl.AddSubstitution('%{libstdcxx-install-prefix}', path)],
25+
help="""
26+
The installation prefix where libstdc++ was installed. This is used to find the libstdc++ headers,
27+
link against its built library, etc.
28+
"""),
29+
libcxx.test.dsl.Parameter(name='libstdcxx-triple', type=str,
30+
actions=lambda triple: [libcxx.test.dsl.AddSubstitution('%{libstdcxx-triple}', triple)],
31+
help="""
32+
The target triple used for the target-specific include directory of libstdc++. This is used to find the
33+
libstdc++ headers.
34+
"""),
35+
libcxx.test.dsl.Parameter(name='libstdcxx-version', type=str,
36+
actions=lambda version: [libcxx.test.dsl.AddSubstitution('%{libstdcxx-version}', version)],
37+
help="""
38+
The version of libstdc++. This is used to find the libstdc++ headers and library.
39+
"""),
40+
]
41+
42+
# Configure the compiler and flags
43+
config.substitutions.append(('%{flags}',
44+
'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
45+
))
46+
config.substitutions.append(('%{compile_flags}',
47+
'-nostdinc++ -isystem %{libstdcxx-install-prefix}/include/c++/%{libstdcxx-version} -isystem %{libstdcxx-install-prefix}/include/c++/%{libstdcxx-version}/%{libstdcxx-triple} -I %{libcxx-dir}/test/support'
48+
))
49+
config.substitutions.append(('%{link_flags}',
50+
'-nostdlib++ -L %{libstdcxx-install-prefix}/lib/gcc/%{libstdcxx-version} -Wl,-rpath,%{libstdcxx-install-prefix}/lib/gcc/%{libstdcxx-version} -lstdc++'
51+
))
52+
config.substitutions.append(('%{exec}',
53+
'%{executor} --execdir %T -- '
54+
))
55+
56+
import os, site
57+
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
58+
import libcxx.test.params, libcxx.test.config
59+
libcxx.test.config.configure(
60+
libcxx.test.params.DEFAULT_PARAMETERS + LIBSTDCXX_PARAMETERS,
61+
libcxx.test.features.DEFAULT_FEATURES,
62+
config,
63+
lit_config
64+
)
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)