From e3eaba80b1b48788e0c80e581650c33a3f729836 Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Mon, 29 May 2017 14:59:30 -0700 Subject: 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... --- var/spack/repos/builtin/packages/perl/package.py | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py index 10895f6089..ef1c11289f 100644 --- a/var/spack/repos/builtin/packages/perl/package.py +++ b/var/spack/repos/builtin/packages/perl/package.py @@ -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 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package # 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) -- cgit v1.2.3-70-g09d2