Allow packages to control handling of compiler flags (#4421)
* Initial work on flag trapping using functions called <flag>_handler and default_flag_handler * Update packages so they do not obliterate flags * Added append to EnvironmentModifications class * changed EnvironmentModifications to have append_flags method * changed flag_val to be a tuple * Increased test coverage * added documentation of flag handling
This commit is contained in:
@@ -78,12 +78,18 @@ def cmake_args(self):
|
||||
cmake_args = []
|
||||
|
||||
if '+cxx11' in spec:
|
||||
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
||||
if 'CXXFLAGS' in env and env['CXXFLAGS']:
|
||||
env['CXXFLAGS'] += ' ' + self.compiler.cxx11_flag
|
||||
else:
|
||||
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
||||
cmake_args.append('-DCLHEP_BUILD_CXXSTD=' +
|
||||
self.compiler.cxx11_flag)
|
||||
|
||||
if '+cxx14' in spec:
|
||||
env['CXXFLAGS'] = self.compiler.cxx14_flag
|
||||
if 'CXXFLAGS' in env and env['CXXFLAGS']:
|
||||
env['CXXFLAGS'] += ' ' + self.compiler.cxx14_flag
|
||||
else:
|
||||
env['CXXFLAGS'] = self.compiler.cxx14_flag
|
||||
cmake_args.append('-DCLHEP_BUILD_CXXSTD=' +
|
||||
self.compiler.cxx14_flag)
|
||||
|
||||
|
@@ -71,8 +71,8 @@ def setup_environment(self, spack_env, run_env):
|
||||
spack_env.set('FC', spec['mpi'].mpifc)
|
||||
spack_env.set('CXX', spec['mpi'].mpicxx)
|
||||
|
||||
spack_env.set('LDFLAGS', spec['lapack'].libs.search_flags)
|
||||
spack_env.set('LIBS', spec['lapack'].libs.link_flags)
|
||||
spack_env.append_flags('LDFLAGS', spec['lapack'].libs.search_flags)
|
||||
spack_env.append_flags('LIBS', spec['lapack'].libs.link_flags)
|
||||
spack_env.set('SCALAPACK_LDFLAGS', spec['scalapack'].libs.joined())
|
||||
|
||||
def configure_args(self):
|
||||
|
@@ -98,7 +98,12 @@ def install(self, spec, prefix):
|
||||
ln('-sf',
|
||||
libz_prefix + '/lib',
|
||||
libz_prefix + '/lib64')
|
||||
os.environ['LDFLAGS'] = '-lquadmath'
|
||||
|
||||
if 'LDFLAGS' in env and env['LDFLAGS']:
|
||||
env['LDFLAGS'] += ' ' + '-lquadmath'
|
||||
else:
|
||||
env['LDFLAGS'] = '-lquadmath'
|
||||
|
||||
with working_dir('FERRET', create=False):
|
||||
os.environ['LD_X11'] = '-L/usr/lib/X11 -lX11'
|
||||
os.environ['HOSTTYPE'] = 'x86_64-linux'
|
||||
|
@@ -155,7 +155,7 @@ class Git(AutotoolsPackage):
|
||||
depends_on('m4', type='build')
|
||||
|
||||
def setup_environment(self, spack_env, run_env):
|
||||
spack_env.set('LDFLAGS', '-L{0} -lintl'.format(
|
||||
spack_env.append_flags('LDFLAGS', '-L{0} -lintl'.format(
|
||||
self.spec['gettext'].prefix.lib))
|
||||
|
||||
def configure_args(self):
|
||||
|
@@ -85,6 +85,7 @@ def setup_environment(self, build_env, run_env):
|
||||
def configure_args(self):
|
||||
|
||||
config_args = ['--enable-shared']
|
||||
|
||||
optflags = self.optflags
|
||||
|
||||
# Optimization flag names have changed in libint 2
|
||||
|
@@ -71,8 +71,15 @@ def install(self, spec, prefix):
|
||||
if which('xiar'):
|
||||
env['AR'] = 'xiar'
|
||||
|
||||
env['CFLAGS'] = optflags
|
||||
env['FCFLAGS'] = optflags
|
||||
if 'CFLAGS' in env and env['CFLAGS']:
|
||||
env['CFLAGS'] += ' ' + optflags
|
||||
else:
|
||||
env['CFLAGS'] = optflags
|
||||
|
||||
if 'FCFLAGS' in env and env['FCFLAGS']:
|
||||
env['FCFLAGS'] += ' ' + optflags
|
||||
else:
|
||||
env['FCFLAGS'] = optflags
|
||||
|
||||
configure('--prefix={0}'.format(prefix),
|
||||
'--enable-shared')
|
||||
|
@@ -46,5 +46,5 @@ class Libxpm(AutotoolsPackage):
|
||||
depends_on('util-macros', type='build')
|
||||
|
||||
def setup_environment(self, spack_env, run_env):
|
||||
spack_env.set('LDFLAGS', '-L{0} -lintl'.format(
|
||||
spack_env.append_flags('LDFLAGS', '-L{0} -lintl'.format(
|
||||
self.spec['gettext'].prefix.lib))
|
||||
|
@@ -38,7 +38,10 @@ class LlvmLld(Package):
|
||||
depends_on('cmake', type='build')
|
||||
|
||||
def install(self, spec, prefix):
|
||||
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
||||
if 'CXXFLAGS' in env and env['CXXFLAGS']:
|
||||
env['CXXFLAGS'] += ' ' + self.compiler.cxx11_flag
|
||||
else:
|
||||
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
||||
|
||||
with working_dir('spack-build', create=True):
|
||||
cmake('..',
|
||||
|
@@ -325,7 +325,7 @@ class Llvm(CMakePackage):
|
||||
conflicts('+lldb', when='~clang')
|
||||
|
||||
def setup_environment(self, spack_env, run_env):
|
||||
spack_env.set('CXXFLAGS', self.compiler.cxx11_flag)
|
||||
spack_env.append_flags('CXXFLAGS', self.compiler.cxx11_flag)
|
||||
|
||||
def build_type(self):
|
||||
if '+debug' in self.spec:
|
||||
|
@@ -57,7 +57,7 @@ def libs(self):
|
||||
|
||||
def setup_environment(self, spack_env, run_env):
|
||||
if '+pic' in self.spec:
|
||||
spack_env.set('CFLAGS', self.compiler.pic_flag)
|
||||
spack_env.append_flags('CFLAGS', self.compiler.pic_flag)
|
||||
|
||||
def install(self, spec, prefix):
|
||||
config_args = []
|
||||
|
Reference in New Issue
Block a user