summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJustin S <3630356+codeandkey@users.noreply.github.com>2019-06-05 04:43:11 -0500
committerAxel Huebl <axel.huebl@plasma.ninja>2019-06-05 11:43:11 +0200
commit4ac64e6cd88bc0216c6c77e0d50d56287300f7da (patch)
treeae9ad13d08f06f10d65862d8208c20fb61be0e18 /lib
parentb3379a88903a22333f296640d107719439bef9fe (diff)
downloadspack-4ac64e6cd88bc0216c6c77e0d50d56287300f7da.tar.gz
spack-4ac64e6cd88bc0216c6c77e0d50d56287300f7da.tar.bz2
spack-4ac64e6cd88bc0216c6c77e0d50d56287300f7da.tar.xz
spack-4ac64e6cd88bc0216c6c77e0d50d56287300f7da.zip
add C standard flags to compiler classes (#11618)
* add c99_flag, c11_flag to compiler class * implement c99_flag, c11_flag for gcc * implement c99_flag, c11_flag for arm * implement c99_flag for cce * implement c99_flag, c11_flag for clang * implement c99_flag, c11_flag for intel * implement c99_flag, c11_flag for xl
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/compiler.py18
-rw-r--r--lib/spack/spack/compilers/arm.py8
-rw-r--r--lib/spack/spack/compilers/cce.py4
-rw-r--r--lib/spack/spack/compilers/clang.py14
-rw-r--r--lib/spack/spack/compilers/gcc.py18
-rw-r--r--lib/spack/spack/compilers/intel.py20
-rw-r--r--lib/spack/spack/compilers/xl.py8
7 files changed, 90 insertions, 0 deletions
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
index d5cb2cc47d..37d36166ec 100644
--- a/lib/spack/spack/compiler.py
+++ b/lib/spack/spack/compiler.py
@@ -195,6 +195,24 @@ class Compiler(object):
"the C++17 standard",
"cxx17_flag")
+ # This property should be overridden in the compiler subclass if
+ # C99 is supported by that compiler
+ @property
+ def c99_flag(self):
+ # If it is not overridden, assume it is not supported and warn the user
+ raise UnsupportedCompilerFlag(self,
+ "the C99 standard",
+ "c99_flag")
+
+ # This property should be overridden in the compiler subclass if
+ # C11 is supported by that compiler
+ @property
+ def c11_flag(self):
+ # If it is not overridden, assume it is not supported and warn the user
+ raise UnsupportedCompilerFlag(self,
+ "the C11 standard",
+ "c11_flag")
+
#
# Compiler classes have methods for querying the version of
# specific compiler executables. This is used when discovering compilers.
diff --git a/lib/spack/spack/compilers/arm.py b/lib/spack/spack/compilers/arm.py
index 4b3aa70f2b..4892c5a63d 100644
--- a/lib/spack/spack/compilers/arm.py
+++ b/lib/spack/spack/compilers/arm.py
@@ -54,6 +54,14 @@ class Arm(spack.compiler.Compiler):
return "-std=c++1z"
@property
+ def c99_flag(self):
+ return "-std=c99"
+
+ @property
+ def c11_flag(self):
+ return "-std=c11"
+
+ @property
def pic_flag(self):
return "-fPIC"
diff --git a/lib/spack/spack/compilers/cce.py b/lib/spack/spack/compilers/cce.py
index 2941ed2c11..349ed394d7 100644
--- a/lib/spack/spack/compilers/cce.py
+++ b/lib/spack/spack/compilers/cce.py
@@ -43,5 +43,9 @@ class Cce(spack.compiler.Compiler):
return "-h std=c++11"
@property
+ def c99_flag(self):
+ return "-h c99"
+
+ @property
def pic_flag(self):
return "-h PIC"
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index 811e465ad3..658884b5de 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -158,6 +158,20 @@ class Clang(Compiler):
return "-std=c++17"
@property
+ def c99_flag(self):
+ return '-std=c99'
+
+ @property
+ def c11_flag(self):
+ if self.version < ver('6.1.0'):
+ raise UnsupportedCompilerFlag(self,
+ "the C11 standard",
+ "c11_flag",
+ "< 3.3")
+ else:
+ return "-std=c11"
+
+ @property
def pic_flag(self):
return "-fPIC"
diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py
index 5dc0b514b7..4d3c319c85 100644
--- a/lib/spack/spack/compilers/gcc.py
+++ b/lib/spack/spack/compilers/gcc.py
@@ -88,6 +88,24 @@ class Gcc(Compiler):
return "-std=c++17"
@property
+ def c99_flag(self):
+ if self.version < ver('4.5'):
+ raise UnsupportedCompilerFlag(self,
+ "the C99 standard",
+ "c99_flag",
+ "< 4.5")
+ return "-std=c99"
+
+ @property
+ def c11_flag(self):
+ if self.version < ver('4.7'):
+ raise UnsupportedCompilerFlag(self,
+ "the C11 standard",
+ "c11_flag",
+ "< 4.7")
+ return "-std=c11"
+
+ @property
def pic_flag(self):
return "-fPIC"
diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py
index 7485471241..c0fb5ebe51 100644
--- a/lib/spack/spack/compilers/intel.py
+++ b/lib/spack/spack/compilers/intel.py
@@ -66,6 +66,26 @@ class Intel(Compiler):
return "-std=c++14"
@property
+ def c99_flag(self):
+ if self.version < ver('12'):
+ raise UnsupportedCompilerFlag(self,
+ "the C99 standard",
+ "c99_flag",
+ "< 12")
+ else:
+ return "-std=c99"
+
+ @property
+ def c11_flag(self):
+ if self.version < ver('16'):
+ raise UnsupportedCompilerFlag(self,
+ "the C11 standard",
+ "c11_flag",
+ "< 16")
+ else:
+ return "-std=c1x"
+
+ @property
def pic_flag(self):
return "-fPIC"
diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py
index acedd2fdb8..6e33075408 100644
--- a/lib/spack/spack/compilers/xl.py
+++ b/lib/spack/spack/compilers/xl.py
@@ -44,6 +44,14 @@ class Xl(Compiler):
return "-qlanglvl=extended0x"
@property
+ def c99_flag(self):
+ return '-std=c99'
+
+ @property
+ def c11_flag(self):
+ return '-std=c11'
+
+ @property
def pic_flag(self):
return "-qpic"