[libcxx-commits] [libcxx] [libc++][test] Raise a useful error when no -std=c++NN flag is found to work (PR #99423)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 17 20:07:53 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Janet Cobb (randomnetcat)
<details>
<summary>Changes</summary>
Recently ran into an issue with symptoms very similar to https://github.com/llvm/llvm-project/issues/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.
---
Full diff: https://github.com/llvm/llvm-project/pull/99423.diff
1 Files Affected:
- (modified) libcxx/utils/libcxx/test/params.py (+10-3)
``````````diff
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 3aadc54cf92dc..320d550a0dc50 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -87,6 +87,15 @@ def getStdFlag(cfg, std):
return "-std=" + fallbacks[std]
return None
+def getDefaultStdValue(cfg):
+ viable = [s for s in reversed(_allStandards) if getStdFlag(cfg, s)]
+
+ if not viable:
+ raise RuntimeError(
+ "Unable to successfully detect the presence of any -std=c++NN flag. This likely indicates an issue with your compiler."
+ )
+
+ return viable[0]
def getSpeedOptimizationFlag(cfg):
if _isClang(cfg) or _isAppleClang(cfg) or _isGCC(cfg):
@@ -170,9 +179,7 @@ def getSuitableClangTidy(cfg):
choices=_allStandards,
type=str,
help="The version of the standard to compile the test suite with.",
- default=lambda cfg: next(
- s for s in reversed(_allStandards) if getStdFlag(cfg, s)
- ),
+ default=lambda cfg: getDefaultStdValue(cfg),
actions=lambda std: [
AddFeature(std),
AddSubstitution("%{cxx_std}", re.sub(r"\+", "x", std)),
``````````
</details>
https://github.com/llvm/llvm-project/pull/99423
More information about the libcxx-commits
mailing list