diff options
author | Chris Green <greenc@fnal.gov> | 2018-06-08 15:49:31 -0500 |
---|---|---|
committer | scheibelp <scheibel1@llnl.gov> | 2018-06-08 13:49:31 -0700 |
commit | 15c98fa57c0022df3c3788f19b3febd484d8ccd7 (patch) | |
tree | f285eb74e697f4ff2ad581eee8c3d69c06a5a7d7 /var | |
parent | ceb2790f30c5ad5a9d90121057bb93f45448778e (diff) | |
download | spack-15c98fa57c0022df3c3788f19b3febd484d8ccd7.tar.gz spack-15c98fa57c0022df3c3788f19b3febd484d8ccd7.tar.bz2 spack-15c98fa57c0022df3c3788f19b3febd484d8ccd7.tar.xz spack-15c98fa57c0022df3c3788f19b3febd484d8ccd7.zip |
compiler flags: add cxx98 standard support (#7601)
The following improvements are made to cxx standard support
(e.g. compiler.cxxNN_flag functions) in compilers:
* Add cxx98_flag property
* Add support for throwing an exception when a flag is not supported (previously
if a flag was not supported the application was terminated with tty.die)
* The name of the flag associated with e.g. c++14 standard support changes for
different compiler versions (e.g. c++1y vs c++14). This makes a few corrections
on what flag to return for which version.
* Added tests to confirm that versions report expected flags for various c++
standards (or raise an exception for versions that don't provide a given cxx
standard)
Note that if a given cxx standard is the default, the associated flag property will
return ""; cxx98 is assumed to be the default standard so this is the behavior for
the associated property in the base compiler class.
Package changes:
* Improvements to the boost spec to take advantage of the improved standard
flag facility.
* Update the clingo spec to catch the new exception rather than look for an
empty flag to indicate non-support (which is not part of the compiler flag API)
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/boost/package.py | 41 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/clingo/package.py | 4 |
2 files changed, 43 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/boost/package.py b/var/spack/repos/builtin/packages/boost/package.py index 5666df8baa..db72c06212 100644 --- a/var/spack/repos/builtin/packages/boost/package.py +++ b/var/spack/repos/builtin/packages/boost/package.py @@ -126,6 +126,11 @@ class Boost(Package): variant(lib, default=(lib not in default_noinstall_libs), description="Compile with {0} library".format(lib)) + variant('cxxstd', + default='default', + values=('default', '98', '11', '14', '17'), + multi=False, + description='Use the specified C++ standard when building.') variant('debug', default=False, description='Switch to the debug version of Boost') variant('shared', default=True, @@ -250,6 +255,26 @@ class Boost(Package): if '+python' in spec: f.write(self.bjam_python_line(spec)) + def cxxstd_to_flag(self, std): + flag = '' + if self.spec.variants['cxxstd'].value == '98': + flag = self.compiler.cxx98_flag + elif self.spec.variants['cxxstd'].value == '11': + flag = self.compiler.cxx11_flag + elif self.spec.variants['cxxstd'].value == '14': + flag = self.compiler.cxx14_flag + elif self.spec.variants['cxxstd'].value == '17': + flag = self.compiler.cxx17_flag + elif self.spec.variants['cxxstd'].value == 'default': + # Let the compiler do what it usually does. + pass + else: + # The user has selected a (new?) legal value that we've + # forgotten to deal with here. + tty.die("INTERNAL ERROR: cannot accommodate unexpected variant ", + "cxxstd={0}".format(spec.variants['cxxstd'].value)) + return flag + def determine_b2_options(self, spec, options): if '+debug' in spec: options.append('variant=debug') @@ -299,6 +324,17 @@ class Boost(Package): 'toolset=%s' % self.determine_toolset(spec) ]) + # Other C++ flags. + cxxflags = [] + + # Deal with C++ standard. + if spec.satisfies('@1.66:'): + options.append('cxxstd={0}'.format(spec.variants['cxxstd'].value)) + else: # Add to cxxflags for older Boost. + flag = self.cxxstd_to_flag(spec.variants['cxxstd'].value) + if flag: + cxxflags.append(flag) + # clang is not officially supported for pre-compiled headers # and at least in clang 3.9 still fails to build # http://www.boost.org/build/doc/html/bbv2/reference/precompiled_headers.html @@ -306,10 +342,13 @@ class Boost(Package): if spec.satisfies('%clang'): options.extend(['pch=off']) if '+clanglibcpp' in spec: + cxxflags.append('-stdlib=libc++') options.extend(['toolset=clang', - 'cxxflags="-stdlib=libc++"', 'linkflags="-stdlib=libc++"']) + if cxxflags: + options.append('cxxflags="{0}"'.format(' '.join(cxxflags))) + return threadingOpts def add_buildopt_symlinks(self, prefix): diff --git a/var/spack/repos/builtin/packages/clingo/package.py b/var/spack/repos/builtin/packages/clingo/package.py index cf45630e12..c014e14cf2 100644 --- a/var/spack/repos/builtin/packages/clingo/package.py +++ b/var/spack/repos/builtin/packages/clingo/package.py @@ -44,7 +44,9 @@ class Clingo(CMakePackage): depends_on('python') def cmake_args(self): - if not self.compiler.cxx14_flag: + try: + self.compiler.cxx14_flag + except UnsupportedCompilerFlag: InstallError('clingo requires a C++14-compliant C++ compiler') args = ['-DCLINGO_BUILD_WITH_PYTHON=ON', |