summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWouter Deconinck <wdconinc@gmail.com>2024-05-12 09:45:59 -0500
committerGitHub <noreply@github.com>2024-05-12 07:45:59 -0700
commitf8f01c336c882f29ac364995423b9f69ac365462 (patch)
tree86fb0b417972c73bf6d57b430eba8ffa84dc9d6f /lib
parent12e3665df37ddf0839e808ff415c011507eccf22 (diff)
downloadspack-f8f01c336c882f29ac364995423b9f69ac365462.tar.gz
spack-f8f01c336c882f29ac364995423b9f69ac365462.tar.bz2
spack-f8f01c336c882f29ac364995423b9f69ac365462.tar.xz
spack-f8f01c336c882f29ac364995423b9f69ac365462.zip
clang: support cxx20_flag and cxx23_flag (#43438)
* clang: support cxx20_flag and cxx23_flag * clang: coverage test cxx{}_flag and c{}_flag additions
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/compilers/clang.py25
-rw-r--r--lib/spack/spack/test/compilers/basics.py9
2 files changed, 33 insertions, 1 deletions
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index 4f93d04f5f..577586cda1 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -96,6 +96,8 @@ class Clang(Compiler):
openmp_flag = "-fopenmp"
+ # C++ flags based on CMake Modules/Compiler/Clang.cmake
+
@property
def cxx11_flag(self):
if self.real_version < Version("3.3"):
@@ -121,6 +123,24 @@ class Clang(Compiler):
return "-std=c++17"
@property
+ def cxx20_flag(self):
+ if self.real_version < Version("5.0"):
+ raise UnsupportedCompilerFlag(self, "the C++20 standard", "cxx20_flag", "< 5.0")
+ elif self.real_version < Version("11.0"):
+ return "-std=c++2a"
+ else:
+ return "-std=c++20"
+
+ @property
+ def cxx23_flag(self):
+ if self.real_version < Version("12.0"):
+ raise UnsupportedCompilerFlag(self, "the C++23 standard", "cxx23_flag", "< 12.0")
+ elif self.real_version < Version("17.0"):
+ return "-std=c++2b"
+ else:
+ return "-std=c++23"
+
+ @property
def c99_flag(self):
return "-std=c99"
@@ -142,7 +162,10 @@ class Clang(Compiler):
def c23_flag(self):
if self.real_version < Version("9.0"):
raise UnsupportedCompilerFlag(self, "the C23 standard", "c23_flag", "< 9.0")
- return "-std=c2x"
+ elif self.real_version < Version("18.0"):
+ return "-std=c2x"
+ else:
+ return "-std=c23"
@property
def cc_pic_flag(self):
diff --git a/lib/spack/spack/test/compilers/basics.py b/lib/spack/spack/test/compilers/basics.py
index 2c46d434d1..0884f9b1a4 100644
--- a/lib/spack/spack/test/compilers/basics.py
+++ b/lib/spack/spack/test/compilers/basics.py
@@ -384,9 +384,18 @@ def test_clang_flags():
unsupported_flag_test("cxx17_flag", "clang@3.4")
supported_flag_test("cxx17_flag", "-std=c++1z", "clang@3.5")
supported_flag_test("cxx17_flag", "-std=c++17", "clang@5.0")
+ unsupported_flag_test("cxx20_flag", "clang@4.0")
+ supported_flag_test("cxx20_flag", "-std=c++2a", "clang@5.0")
+ supported_flag_test("cxx20_flag", "-std=c++20", "clang@11.0")
+ unsupported_flag_test("cxx23_flag", "clang@11.0")
+ supported_flag_test("cxx23_flag", "-std=c++2b", "clang@12.0")
+ supported_flag_test("cxx23_flag", "-std=c++23", "clang@17.0")
supported_flag_test("c99_flag", "-std=c99", "clang@3.3")
unsupported_flag_test("c11_flag", "clang@2.0")
supported_flag_test("c11_flag", "-std=c11", "clang@6.1.0")
+ unsupported_flag_test("c23_flag", "clang@8.0")
+ supported_flag_test("c23_flag", "-std=c2x", "clang@9.0")
+ supported_flag_test("c23_flag", "-std=c23", "clang@18.0")
supported_flag_test("cc_pic_flag", "-fPIC", "clang@3.3")
supported_flag_test("cxx_pic_flag", "-fPIC", "clang@3.3")
supported_flag_test("f77_pic_flag", "-fPIC", "clang@3.3")