[libcxx-commits] [libcxx] fde51e2 - [libc++][test] Raise a useful error when no -std=c++NN flag is found to work (#99423)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 18 06:04:18 PDT 2024


Author: Janet Cobb
Date: 2024-07-18T09:04:15-04:00
New Revision: fde51e24b593087a15494203ef68a77bb4f12115

URL: https://github.com/llvm/llvm-project/commit/fde51e24b593087a15494203ef68a77bb4f12115
DIFF: https://github.com/llvm/llvm-project/commit/fde51e24b593087a15494203ef68a77bb4f12115.diff

LOG: [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
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.

Added: 
    

Modified: 
    libcxx/utils/libcxx/test/params.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 3aadc54cf92dc..13c7297fd7304 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -88,6 +88,17 @@ def getStdFlag(cfg, 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):
         return "-O3"
@@ -170,9 +181,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)),


        


More information about the libcxx-commits mailing list