From 2cdfe14e5a8cbdefd3533d3bb0b0ac09fa9e4fa6 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 10:47:39 +0200 Subject: [PATCH 01/17] compilers: make sure cxx11_flag() is defined for all compilers --- lib/spack/spack/compilers/clang.py | 11 +++++++++++ lib/spack/spack/compilers/nag.py | 6 ++++++ lib/spack/spack/compilers/pgi.py | 7 ++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index e406d86a24..8a60ebcaed 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -47,6 +47,17 @@ class Clang(Compiler): 'f77' : 'f77', 'fc' : 'f90' } + @property + def cxx11_flag(self): + if ver.endswith('-apple'): + # FIXME: figure out from which version Apple's clang supports c++11 + return "-std=c++11" + else: + if self.version < ver('3.3'): + tty.die("Only Clang 3.3 and above support c++11.") + else: + return "-std=c++11" + @classmethod def default_version(self, comp): """The '--version' option works for clang compilers. diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py index 527a05a090..1df6b1c591 100644 --- a/lib/spack/spack/compilers/nag.py +++ b/lib/spack/spack/compilers/nag.py @@ -20,6 +20,12 @@ class Nag(Compiler): 'f77' : 'nag/nagfor', 'fc' : 'nag/nagfor' } + @property + def cxx11_flag(self): + tty.die("cxx11_flag() is not implemented for nag. Consider creating a pull-request.") + return "-std=c++11" + + @classmethod def default_version(self, comp): """The '-V' option works for nag compilers. diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py index c6a1078bd9..ebf644404b 100644 --- a/lib/spack/spack/compilers/pgi.py +++ b/lib/spack/spack/compilers/pgi.py @@ -43,6 +43,12 @@ class Pgi(Compiler): 'f77' : 'pgi/pgfortran', 'fc' : 'pgi/pgfortran' } + @property + def cxx11_flag(self): + tty.die("cxx11_flag() is not implemented for pgi. Consider creating a pull-request.") + return "-std=c++11" + + @classmethod def default_version(cls, comp): """The '-V' option works for all the PGI compilers. @@ -54,4 +60,3 @@ def default_version(cls, comp): """ return get_compiler_version( comp, '-V', r'pg[^ ]* ([^ ]+) \d\d\d?-bit target') - From 9776dc0433fee264ae1fd2cbff9b16fd499fdb1a Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 10:49:04 +0200 Subject: [PATCH 02/17] compilers: add openmp_flag() method --- lib/spack/spack/compilers/clang.py | 8 ++++++++ lib/spack/spack/compilers/gcc.py | 4 ++++ lib/spack/spack/compilers/intel.py | 6 ++++-- lib/spack/spack/compilers/nag.py | 4 ++++ lib/spack/spack/compilers/pgi.py | 4 ++++ lib/spack/spack/compilers/xl.py | 4 ++++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index 8a60ebcaed..44de77af4f 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -47,6 +47,14 @@ class Clang(Compiler): 'f77' : 'f77', 'fc' : 'f90' } + @property + def openmp_flag(self): + ver = '%s' % self.version + if ver.endswith('-apple'): + tty.die("Clang from Apple does not support Openmp yet.") + else: + return "-fopenmp" + @property def cxx11_flag(self): if ver.endswith('-apple'): diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py index 2e57e44856..91c498ac82 100644 --- a/lib/spack/spack/compilers/gcc.py +++ b/lib/spack/spack/compilers/gcc.py @@ -49,6 +49,10 @@ class Gcc(Compiler): 'f77' : 'gcc/gfortran', 'fc' : 'gcc/gfortran' } + @property + def openmp_flag(self): + return "-fopenmp" + @property def cxx11_flag(self): if self.version < ver('4.3'): diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py index 69e9764790..f04a6aa899 100644 --- a/lib/spack/spack/compilers/intel.py +++ b/lib/spack/spack/compilers/intel.py @@ -43,6 +43,10 @@ class Intel(Compiler): 'f77' : 'intel/ifort', 'fc' : 'intel/ifort' } + @property + def openmp_flag(self): + return "-openmp" + @property def cxx11_flag(self): if self.version < ver('11.1'): @@ -68,5 +72,3 @@ def default_version(cls, comp): """ return get_compiler_version( comp, '--version', r'\((?:IFORT|ICC)\) ([^ ]+)') - - diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py index 1df6b1c591..61486f22bd 100644 --- a/lib/spack/spack/compilers/nag.py +++ b/lib/spack/spack/compilers/nag.py @@ -20,6 +20,10 @@ class Nag(Compiler): 'f77' : 'nag/nagfor', 'fc' : 'nag/nagfor' } + @property + def openmp_flag(self): + return "-openmp" + @property def cxx11_flag(self): tty.die("cxx11_flag() is not implemented for nag. Consider creating a pull-request.") diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py index ebf644404b..299b9a7016 100644 --- a/lib/spack/spack/compilers/pgi.py +++ b/lib/spack/spack/compilers/pgi.py @@ -43,6 +43,10 @@ class Pgi(Compiler): 'f77' : 'pgi/pgfortran', 'fc' : 'pgi/pgfortran' } + @property + def openmp_flag(self): + return "-mp" + @property def cxx11_flag(self): tty.die("cxx11_flag() is not implemented for pgi. Consider creating a pull-request.") diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py index c1d55109a3..657309fe06 100644 --- a/lib/spack/spack/compilers/xl.py +++ b/lib/spack/spack/compilers/xl.py @@ -44,6 +44,10 @@ class Xl(Compiler): 'f77' : 'xl/xlf', 'fc' : 'xl/xlf90' } + @property + def openmp_flag(self): + return "-qsmp=omp" + @property def cxx11_flag(self): if self.version < ver('13.1'): From c078deaab1d62d881bbed8efece779ca01c504c7 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 11:08:44 +0200 Subject: [PATCH 03/17] compilers: add missing import statements --- lib/spack/spack/compilers/clang.py | 2 ++ lib/spack/spack/compilers/intel.py | 2 ++ lib/spack/spack/compilers/nag.py | 1 + lib/spack/spack/compilers/pgi.py | 1 + lib/spack/spack/compilers/xl.py | 1 + 5 files changed, 7 insertions(+) diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index 44de77af4f..799b92b20d 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -26,6 +26,8 @@ import spack.compiler as cpr from spack.compiler import * from spack.util.executable import * +import llnl.util.tty as tty +from spack.version import ver class Clang(Compiler): # Subclasses use possible names of C compiler diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py index f04a6aa899..bc13db5dc7 100644 --- a/lib/spack/spack/compilers/intel.py +++ b/lib/spack/spack/compilers/intel.py @@ -23,6 +23,8 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack.compiler import * +import llnl.util.tty as tty +from spack.version import ver class Intel(Compiler): # Subclasses use possible names of C compiler diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py index 61486f22bd..729aed0caf 100644 --- a/lib/spack/spack/compilers/nag.py +++ b/lib/spack/spack/compilers/nag.py @@ -1,4 +1,5 @@ from spack.compiler import * +import llnl.util.tty as tty class Nag(Compiler): # Subclasses use possible names of C compiler diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py index 299b9a7016..5ab4a9d109 100644 --- a/lib/spack/spack/compilers/pgi.py +++ b/lib/spack/spack/compilers/pgi.py @@ -23,6 +23,7 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack.compiler import * +import llnl.util.tty as tty class Pgi(Compiler): # Subclasses use possible names of C compiler diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py index 657309fe06..fd78abd091 100644 --- a/lib/spack/spack/compilers/xl.py +++ b/lib/spack/spack/compilers/xl.py @@ -24,6 +24,7 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack.compiler import * +import llnl.util.tty as tty class Xl(Compiler): # Subclasses use possible names of C compiler From 3cd3052c564451f375977522e23a458edd25611a Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 11:26:03 +0200 Subject: [PATCH 04/17] compilers: minor fixes to Clang::cxx11_flag() and Clang::openmp_flag() --- lib/spack/spack/compilers/clang.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index 799b92b20d..1f0eda3220 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -51,15 +51,16 @@ class Clang(Compiler): @property def openmp_flag(self): - ver = '%s' % self.version - if ver.endswith('-apple'): + ver_string = '%s' % self.version + if ver_string.endswith('-apple'): tty.die("Clang from Apple does not support Openmp yet.") else: return "-fopenmp" @property def cxx11_flag(self): - if ver.endswith('-apple'): + ver_string = '%s' % self.version + if ver_string.endswith('-apple'): # FIXME: figure out from which version Apple's clang supports c++11 return "-std=c++11" else: From 592045cd5453f3214737de04ce489126287f52dc Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 11:28:49 +0200 Subject: [PATCH 05/17] compilers: make Intel::openmp_flag() return -openmp and -qopenmp based on the compiler version --- lib/spack/spack/compilers/intel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py index bc13db5dc7..9b1cf07c36 100644 --- a/lib/spack/spack/compilers/intel.py +++ b/lib/spack/spack/compilers/intel.py @@ -47,7 +47,10 @@ class Intel(Compiler): @property def openmp_flag(self): - return "-openmp" + if self.version < ver('16.0'): + return "-openmp" + else: + return "-qopenmp" @property def cxx11_flag(self): From 07fd0ccc9aeb1fb47ce6bbb1353a5c5fe7cf7e9a Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 12:13:31 +0200 Subject: [PATCH 06/17] compiler: add Clang.is_apple property which checks if Clang is from Apple or not using version --- lib/spack/spack/compilers/clang.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index 1f0eda3220..a6c9a69505 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -50,17 +50,23 @@ class Clang(Compiler): 'fc' : 'f90' } @property - def openmp_flag(self): + def is_apple(self): ver_string = '%s' % self.version if ver_string.endswith('-apple'): + return True + else: + return False + + @property + def openmp_flag(self): + if self.is_apple: tty.die("Clang from Apple does not support Openmp yet.") else: return "-fopenmp" @property def cxx11_flag(self): - ver_string = '%s' % self.version - if ver_string.endswith('-apple'): + if self.is_apple: # FIXME: figure out from which version Apple's clang supports c++11 return "-std=c++11" else: From f2f1c49c90de5c1b620d7bdb7cd5ff85173fcb22 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 15:21:33 +0200 Subject: [PATCH 07/17] compilers: one more missing import statement --- lib/spack/spack/compilers/xl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py index fd78abd091..61a2e730dc 100644 --- a/lib/spack/spack/compilers/xl.py +++ b/lib/spack/spack/compilers/xl.py @@ -25,6 +25,7 @@ ############################################################################## from spack.compiler import * import llnl.util.tty as tty +from spack.version import ver class Xl(Compiler): # Subclasses use possible names of C compiler From 6a418cfb8d60a26d1195aeb74b2d54ae9cb38616 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 17:09:49 +0200 Subject: [PATCH 08/17] compiler: simplify Clang.is_apple --- lib/spack/spack/compilers/clang.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index a6c9a69505..8c646905c7 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -51,11 +51,8 @@ class Clang(Compiler): @property def is_apple(self): - ver_string = '%s' % self.version - if ver_string.endswith('-apple'): - return True - else: - return False + ver_string = str(self.version) + return ver_string.endswith('-apple') @property def openmp_flag(self): From d5a760776a47552aab7b8575e7ad9ac9eaba9384 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 17:26:43 +0200 Subject: [PATCH 09/17] compiler: add default implementation of openmp_flag() and css11_flag() --- lib/spack/spack/compiler.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 20896f9eec..a707b2e3aa 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -120,6 +120,20 @@ def check(exe): def version(self): return self.spec.version + # default implementation of OpenMP linking flag. + # Override in derived classes if needed + @property + def openmp_flag(self): + return "-fopenmp" + + + # default implementation of c++11 linking flag. + # raise an error to force derived classes implement it when used + @property + def cxx11_flag(self): + return "-std=c++11" + + # # Compiler classes have methods for querying the version of # specific compiler executables. This is used when discovering compilers. From e28ca3922feaba84f5bc2e1b8bf6ababe964ace3 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 17:27:46 +0200 Subject: [PATCH 10/17] compiler: cleanup Nag.cxx11_flag and Pgi.cxx11_flag --- lib/spack/spack/compilers/nag.py | 5 ----- lib/spack/spack/compilers/pgi.py | 1 - 2 files changed, 6 deletions(-) diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py index 729aed0caf..bbc291d7b6 100644 --- a/lib/spack/spack/compilers/nag.py +++ b/lib/spack/spack/compilers/nag.py @@ -25,11 +25,6 @@ class Nag(Compiler): def openmp_flag(self): return "-openmp" - @property - def cxx11_flag(self): - tty.die("cxx11_flag() is not implemented for nag. Consider creating a pull-request.") - return "-std=c++11" - @classmethod def default_version(self, comp): diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py index 5ab4a9d109..94c6b8365c 100644 --- a/lib/spack/spack/compilers/pgi.py +++ b/lib/spack/spack/compilers/pgi.py @@ -50,7 +50,6 @@ def openmp_flag(self): @property def cxx11_flag(self): - tty.die("cxx11_flag() is not implemented for pgi. Consider creating a pull-request.") return "-std=c++11" From 30b65d3114e20506fb2d36c0aa7f34babf3c4f72 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 17:29:37 +0200 Subject: [PATCH 11/17] fix comment in Compiler class --- lib/spack/spack/compiler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index a707b2e3aa..1f1cf97ce9 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -120,15 +120,15 @@ def check(exe): def version(self): return self.spec.version - # default implementation of OpenMP linking flag. + # Default implementation of OpenMP linking flag. # Override in derived classes if needed @property def openmp_flag(self): return "-fopenmp" - # default implementation of c++11 linking flag. - # raise an error to force derived classes implement it when used + # Default implementation of c++11 linking flag. + # Override in derived classes if needed @property def cxx11_flag(self): return "-std=c++11" From 473a5542bed01e2f70370ddd5ceb70ac41fe178e Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 18:04:08 +0200 Subject: [PATCH 12/17] compiler: make default openmp_flag() and cxx11_flag() die when these properties are not implemented in a derived class --- lib/spack/spack/compiler.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 1f1cf97ce9..622eed6c10 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -120,19 +120,20 @@ def check(exe): def version(self): return self.spec.version - # Default implementation of OpenMP linking flag. - # Override in derived classes if needed + # This property should be overridden in the compiler subclass if + # OpenMP is supported by that compiler @property def openmp_flag(self): - return "-fopenmp" + # If it is not overridden, assume it is not supported and warn the user + tty.die("The compiler you have chosen does not currently support OpenMP. If you think it should, please edit the compiler subclass and submit a pull request or issue.") - # Default implementation of c++11 linking flag. - # Override in derived classes if needed + # This property should be overridden in the compiler subclass if + # C++11 is supported by that compiler @property def cxx11_flag(self): - return "-std=c++11" - + # If it is not overridden, assume it is not supported and warn the user + tty.die("The compiler you have chosen does not currently support C++11. If you think it should, please edit the compiler subclass and submit a pull request or issue.") # # Compiler classes have methods for querying the version of From ddcb97f9531c65bfc370177dfd2090c9e82a4cb3 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 19:04:42 +0200 Subject: [PATCH 13/17] add a temporary Nag.cxx11_flag property --- lib/spack/spack/compilers/nag.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py index bbc291d7b6..e9038c1039 100644 --- a/lib/spack/spack/compilers/nag.py +++ b/lib/spack/spack/compilers/nag.py @@ -25,6 +25,11 @@ class Nag(Compiler): def openmp_flag(self): return "-openmp" + @property + def cxx11_flag(self): + # NAG does not have a C++ compiler + # However, it can be mixed with a compiler that does support it + return "-std=c++11" @classmethod def default_version(self, comp): From c6fb6bde40798903dcdd5d503c32368068a0f8e4 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 May 2016 19:07:16 +0200 Subject: [PATCH 14/17] remove cxx11_flag from Compiler as it is now substituted by a property with the same name --- lib/spack/spack/compiler.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 622eed6c10..42529777bc 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -94,9 +94,6 @@ class Compiler(object): # Names of generic arguments used by this compiler arg_rpath = '-Wl,-rpath,%s' - # argument used to get C++11 options - cxx11_flag = "-std=c++11" - # argument used to get C++14 options cxx14_flag = "-std=c++1y" From f84f04591be44ba6c1aa5bef50d5efa872cfb1c9 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Thu, 5 May 2016 10:48:31 +0200 Subject: [PATCH 15/17] substitute cxx14_flag by a property with the same name to be overridden in derived classes --- lib/spack/spack/compiler.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 42529777bc..a28d7302aa 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -94,9 +94,6 @@ class Compiler(object): # Names of generic arguments used by this compiler arg_rpath = '-Wl,-rpath,%s' - # argument used to get C++14 options - cxx14_flag = "-std=c++1y" - def __init__(self, cspec, cc, cxx, f77, fc): def check(exe): @@ -132,6 +129,14 @@ def cxx11_flag(self): # If it is not overridden, assume it is not supported and warn the user tty.die("The compiler you have chosen does not currently support C++11. If you think it should, please edit the compiler subclass and submit a pull request or issue.") + # This property should be overridden in the compiler subclass if + # C++14 is supported by that compiler + @property + def cxx14_flag(self): + # If it is not overridden, assume it is not supported and warn the user + tty.die("The compiler you have chosen does not currently support C++14. If you think it should, please edit the compiler subclass and submit a pull request or issue.") + + # # Compiler classes have methods for querying the version of # specific compiler executables. This is used when discovering compilers. From c37ea9aff548bfdf106aa141b8d6e6adec2ffd01 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Thu, 5 May 2016 11:56:58 +0200 Subject: [PATCH 16/17] document usage of compiler flags properties --- lib/spack/docs/packaging_guide.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst index 34d11308f5..31c676d4f5 100644 --- a/lib/spack/docs/packaging_guide.rst +++ b/lib/spack/docs/packaging_guide.rst @@ -1831,6 +1831,25 @@ successfully find ``libdwarf.h`` and ``libdwarf.so``, without the packager having to provide ``--with-libdwarf=/path/to/libdwarf`` on the command line. +Compiler flags +~~~~~~~~~~~~~~ +In rare circumstances such as compiling and running small unit tests, a package +developer may need to know what are the appropriate compiler flags to enable +features like ``OpenMP``, ``c++11``, ``c++14`` and alike. To that end the +compiler classes in ``spack`` implement the following _properties_ : +``openmp_flag``, ``cxx11_flag``, ``cxx14_flag``, which can be accessed in a +package by ``self.compiler.cxx11_flag`` and alike. Note that the implementation +is such that if a given compiler version does not support this feature, an +error will be produced. Therefore package developers can also use these properties +to assert that a compiler supports the requested feature. This is handy when a +package supports additional variants like + +.. code-block:: python + + variant('openmp', default=True, description="Enable OpenMP support.") + + + Message Parsing Interface (MPI) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is common for high performance computing software/packages to use ``MPI``. From 7a2d65967ce60efef1a5cce4969f3607915427f5 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Mon, 9 May 2016 22:04:34 +0200 Subject: [PATCH 17/17] wrap tty.die to 80 chars --- lib/spack/spack/compiler.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index a28d7302aa..b53c17494c 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -119,7 +119,9 @@ def version(self): @property def openmp_flag(self): # If it is not overridden, assume it is not supported and warn the user - tty.die("The compiler you have chosen does not currently support OpenMP. If you think it should, please edit the compiler subclass and submit a pull request or issue.") + tty.die("The compiler you have chosen does not currently support OpenMP.", + "If you think it should, please edit the compiler subclass and", + "submit a pull request or issue.") # This property should be overridden in the compiler subclass if @@ -127,14 +129,20 @@ def openmp_flag(self): @property def cxx11_flag(self): # If it is not overridden, assume it is not supported and warn the user - tty.die("The compiler you have chosen does not currently support C++11. If you think it should, please edit the compiler subclass and submit a pull request or issue.") + tty.die("The compiler you have chosen does not currently support C++11.", + "If you think it should, please edit the compiler subclass and", + "submit a pull request or issue.") + # This property should be overridden in the compiler subclass if # C++14 is supported by that compiler @property def cxx14_flag(self): # If it is not overridden, assume it is not supported and warn the user - tty.die("The compiler you have chosen does not currently support C++14. If you think it should, please edit the compiler subclass and submit a pull request or issue.") + tty.die("The compiler you have chosen does not currently support C++14.", + "If you think it should, please edit the compiler subclass and", + "submit a pull request or issue.") + #