Skip to content

Commit d4d8f21

Browse files
authored
[libc++] Simplify how we select modules flavors in the test suite (#66385)
This gets rid of the separate parameter enable_modules_lsv in favor of adding a named option to the enable_modules parameter. The patch also removes the getModuleFlag helper, which was just a really complicated way of hardcoding "none".
1 parent 06f9ffa commit d4d8f21

File tree

2 files changed

+16
-32
lines changed

2 files changed

+16
-32
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
set(LIBCXX_TEST_PARAMS "enable_modules=clang;enable_modules_lsv=True" CACHE STRING "")
1+
set(LIBCXX_TEST_PARAMS "enable_modules=clang-lsv" CACHE STRING "")
22
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")

libcxx/utils/libcxx/test/params.py

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,6 @@ def getStdFlag(cfg, std):
8787
return None
8888

8989

90-
_allModules = ["none", "clang"]
91-
92-
93-
def getModuleFlag(cfg, enable_modules):
94-
if enable_modules in _allModules:
95-
return enable_modules
96-
return None
97-
98-
9990
# fmt: off
10091
DEFAULT_PARAMETERS = [
10192
Parameter(
@@ -128,32 +119,25 @@ def getModuleFlag(cfg, enable_modules):
128119
),
129120
Parameter(
130121
name="enable_modules",
131-
choices=_allModules,
122+
choices=["none", "clang", "clang-lsv"],
132123
type=str,
133-
help="Whether to build the test suite with modules enabled. Select "
134-
"`clang` for Clang modules",
135-
default=lambda cfg: next(s for s in _allModules if getModuleFlag(cfg, s)),
136-
actions=lambda enable_modules: [
137-
AddFeature("clang-modules-build"),
138-
AddCompileFlag("-fmodules"),
139-
AddCompileFlag("-fcxx-modules"), # AppleClang disregards -fmodules entirely when compiling C++. This enables modules for C++.
124+
help="Whether to build the test suite with modules enabled. "
125+
"Select `clang` for Clang modules, and 'clang-lsv' for Clang modules with Local Submodule Visibility.",
126+
default="none",
127+
actions=lambda modules: filter(None, [
128+
AddFeature("clang-modules-build") if modules in ("clang", "clang-lsv") else None,
129+
130+
# Note: AppleClang disregards -fmodules entirely when compiling C++, so we also pass -fcxx-modules
131+
# to enable modules for C++.
132+
AddCompileFlag("-fmodules -fcxx-modules") if modules in ("clang", "clang-lsv") else None,
133+
140134
# Note: We use a custom modules cache path to make sure that we don't reuse
141135
# the default one, which can be shared across CI builds with different
142136
# configurations.
143-
AddCompileFlag(lambda cfg: f"-fmodules-cache-path={cfg.test_exec_root}/ModuleCache"),
144-
]
145-
if enable_modules == "clang"
146-
else [],
147-
),
148-
Parameter(
149-
name="enable_modules_lsv",
150-
choices=[True, False],
151-
type=bool,
152-
default=False,
153-
help="Whether to enable Local Submodule Visibility in the Modules build.",
154-
actions=lambda lsv: [] if not lsv else [
155-
AddCompileFlag("-Xclang -fmodules-local-submodule-visibility"),
156-
],
137+
AddCompileFlag(lambda cfg: f"-fmodules-cache-path={cfg.test_exec_root}/ModuleCache") if modules in ("clang", "clang-lsv") else None,
138+
139+
AddCompileFlag("-Xclang -fmodules-local-submodule-visibility") if modules == "clang-lsv" else None,
140+
])
157141
),
158142
Parameter(
159143
name="enable_exceptions",

0 commit comments

Comments
 (0)