Skip to content

Commit fde51e2

Browse files
authored
[libc++][test] Raise a useful error when no -std=c++NN flag is found to work (#99423)
Recently ran into an issue with symptoms very similar to #56816 while attempting to build and test libc++ on NixOS. The error message is cryptic (just `StopIteration`), which was very annoying to track down. The error at least saying "hey your compiler's bad" would have saved me quite a bit of time figuring out the issue.
1 parent 6a14161 commit fde51e2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

libcxx/utils/libcxx/test/params.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ def getStdFlag(cfg, std):
8888
return None
8989

9090

91+
def getDefaultStdValue(cfg):
92+
viable = [s for s in reversed(_allStandards) if getStdFlag(cfg, s)]
93+
94+
if not viable:
95+
raise RuntimeError(
96+
"Unable to successfully detect the presence of any -std=c++NN flag. This likely indicates an issue with your compiler."
97+
)
98+
99+
return viable[0]
100+
101+
91102
def getSpeedOptimizationFlag(cfg):
92103
if _isClang(cfg) or _isAppleClang(cfg) or _isGCC(cfg):
93104
return "-O3"
@@ -170,9 +181,7 @@ def getSuitableClangTidy(cfg):
170181
choices=_allStandards,
171182
type=str,
172183
help="The version of the standard to compile the test suite with.",
173-
default=lambda cfg: next(
174-
s for s in reversed(_allStandards) if getStdFlag(cfg, s)
175-
),
184+
default=lambda cfg: getDefaultStdValue(cfg),
176185
actions=lambda std: [
177186
AddFeature(std),
178187
AddSubstitution("%{cxx_std}", re.sub(r"\+", "x", std)),

0 commit comments

Comments
 (0)