Ensure Config.pm has correct setting for cc (#4345)

* Ensure Config.pm has correct setting for cc

Run a filter after install so that Config.pm records the compiler that
Spack built the package with.  If this isn't done, $Config{cc} will be
set to Spack's cc wrapper script.

* Also patch compilers Config_heavy.pl

This patch sets ld=gcc, which appears to work.  I'm not sure if
there's a good way to get at the ld that Spack uses.

* Clean up quoting

* Fix pattern for Config.pm

Does not start at beginning of line...
This commit is contained in:
George Hartzell 2017-05-29 14:59:30 -07:00 committed by Adam J. Stewart
parent e31f80988c
commit e3eaba80b1

View file

@ -31,6 +31,7 @@
# Date: September 6, 2015
#
from spack import *
import os
class Perl(Package): # Perl doesn't use Autotools, it should subclass Package
@ -160,3 +161,33 @@ def setup_dependent_package(self, module, dependent_spec):
# if it does not exist already.
if dependent_spec.package.is_extension:
mkdirp(module.perl_lib_dir)
@run_after('install')
def filter_config_dot_pm(self):
"""Run after install so that Config.pm records the compiler that Spack
built the package with. If this isn't done, $Config{cc} will
be set to Spack's cc wrapper script.
"""
kwargs = {'ignore_absent': True, 'backup': False, 'string': False}
# Find the actual path to the installed Config.pm file.
perl = Executable(join_path(prefix.bin, 'perl'))
config_dot_pm = perl('-MModule::Loaded', '-MConfig', '-e',
'print is_loaded(Config)', output=str)
match = 'cc *=>.*'
substitute = "cc => '{cc}',".format(cc=self.compiler.cc)
filter_file(match, substitute, config_dot_pm, **kwargs)
# And the path Config_heavy.pl
d = os.path.dirname(config_dot_pm)
config_heavy = join_path(d, 'Config_heavy.pl')
match = '^cc=.*'
substitute = "cc='{cc}'".format(cc=self.compiler.cc)
filter_file(match, substitute, config_heavy, **kwargs)
match = '^ld=.*'
substitute = "ld='{ld}'".format(ld=self.compiler.cc)
filter_file(match, substitute, config_heavy, **kwargs)