Skip to content

Commit

Permalink
Ensure Config.pm has correct setting for cc (#4345)
Browse files Browse the repository at this point in the history
* 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...
  • Loading branch information
hartzell authored and adamjstewart committed May 29, 2017
1 parent e31f809 commit e3eaba8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions var/spack/repos/builtin/packages/perl/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit e3eaba8

Please sign in to comment.