We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
perl "remembers" spack's compiler, which does the wrong thing
Additional Perl packages (e.g. from CPAN) should (need to) be built with the same compiler that built `perl` itself.

Perl handles this detail by remembering the compiler with which it was built.  It "remembers" it by stashing a copy of it in the `Config` hash defined in `Config.pm`:

```perl
tie %Config, 'Config', {
    archlibexp => '/home/hartzelg/tmp/spack-perl-cc/opt/spack/linux-centos7-x86_64/gcc-4.8.5/perl-5.24.1-35ejv4426dmzreum4ekdibu3ddmhquvi/lib/5.24.1/x86_64-linux',
    archname => 'x86_64-linux',
    cc => 'cc',
    # [...]
```

On my system this drags `/usr/bin/cc` into the fray, resulting in sadness.

As an example, using the `cpanm` that Spack built

```
cpanm -l /path/to/library/dir XML::Simple
```

will eventually fail while trying to build `Net::HTTP` because it tries to use `cc` as its compiler.

As a quick hack/test, telling configure to use `gcc` as the C compiler results `$Config{cc}` containing `gcc` and happily the first gcc on my path is the one I used to build Perl.

```diff
diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py
index 10895f60..ed30bac5 100644
--- a/var/spack/repos/builtin/packages/perl/package.py
+++ b/var/spack/repos/builtin/packages/perl/package.py
@@ -86,7 +86,8 @@ class Perl(Package):  # Perl doesn't use Autotools, it should subclass Package
             '-des',
             '-Dprefix={0}'.format(prefix),
             '-Dlocincpth=' + self.spec['gdbm'].prefix.include,
-            '-Dloclibpth=' + self.spec['gdbm'].prefix.lib
+            '-Dloclibpth=' + self.spec['gdbm'].prefix.lib,
+            '-Dcc=gcc'
         ]

         # Discussion of -fPIC for Intel at:
```

This changes lets `Net::HTTP` build and install.

Spack's compiler wrappers and *etc* seem magical to me.  What's a good way to fix this?








--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `var/spack/repos/builtin/packages/perl/package.py`
Content:
```
1 ##############################################################################
2 # Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
3 # Produced at the Lawrence Livermore National Laboratory.
4 #
5 # This file is part of Spack.
6 # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7 # LLNL-CODE-647188
8 #
9 # For details, see https://github.com/llnl/spack
10 # Please also see the LICENSE file for our notice and the LGPL.
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License (as
14 # published by the Free Software Foundation) version 2.1, February 1999.
15 #
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19 # conditions of the GNU Lesser General Public License for more details.
20 #
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ##############################################################################
25 #
26 # Author: Milton Woods <milton.woods@bom.gov.au>
27 # Date: March 22, 2017
28 # Author: George Hartzell <hartzell@alerce.com>
29 # Date: July 21, 2016
30 # Author: Justin Too <justin@doubleotoo.com>
31 # Date: September 6, 2015
32 #
33 from spack import *
34 
35 
36 class Perl(Package):  # Perl doesn't use Autotools, it should subclass Package
37     """Perl 5 is a highly capable, feature-rich programming language with over
38        27 years of development."""
39 
40     homepage = "http://www.perl.org"
41     # URL must remain http:// so Spack can bootstrap curl
42     url = "http://www.cpan.org/src/5.0/perl-5.24.1.tar.gz"
43 
44     # Development releases
45     version('5.25.11', '37a398682c36cd85992b34b5c1c25dc1')
46 
47     # Maintenance releases (recommended)
48     version('5.24.1', '765ef511b5b87a164e2531403ee16b3c', preferred=True)
49     version('5.22.3', 'aa4f236dc2fc6f88b871436b8d0fda95')
50 
51     # Misc releases that people need
52     version('5.22.2', '5767e2a10dd62a46d7b57f74a90d952b')
53     version('5.22.1', '19295bbb775a3c36123161b9bf4892f1')
54 
55     # End of life releases
56     version('5.20.3', 'd647d0ea5a7a8194c34759ab9f2610cd')
57     version('5.18.4', '1f9334ff730adc05acd3dd7130d295db')
58     version('5.16.3', 'eb5c40f2575df6c155bc99e3fe0a9d82')
59 
60     extendable = True
61 
62     depends_on('gdbm')
63 
64     # Installing cpanm alongside the core makes it safe and simple for
65     # people/projects to install their own sets of perl modules.  Not
66     # having it in core increases the "energy of activation" for doing
67     # things cleanly.
68     variant('cpanm', default=True,
69             description='Optionally install cpanm with the core packages.')
70 
71     resource(
72         name="cpanm",
73         url="http://search.cpan.org/CPAN/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7042.tar.gz",
74         md5="e87f55fbcb3c13a4754500c18e89219f",
75         destination="cpanm",
76         placement="cpanm"
77     )
78 
79     phases = ['configure', 'build', 'install']
80 
81     def configure_args(self):
82         spec = self.spec
83         prefix = self.prefix
84 
85         config_args = [
86             '-des',
87             '-Dprefix={0}'.format(prefix),
88             '-Dlocincpth=' + self.spec['gdbm'].prefix.include,
89             '-Dloclibpth=' + self.spec['gdbm'].prefix.lib
90         ]
91 
92         # Discussion of -fPIC for Intel at:
93         # https://github.com/LLNL/spack/pull/3081
94         if spec.satisfies('%intel'):
95             config_args.append('-Accflags={0}'.format(self.compiler.pic_flag))
96 
97         return config_args
98 
99     def configure(self, spec, prefix):
100         configure = Executable('./Configure')
101         configure(*self.configure_args())
102 
103     def build(self, spec, prefix):
104         make()
105 
106     @run_after('build')
107     @on_package_attributes(run_tests=True)
108     def test(self):
109         make('test')
110 
111     def install(self, spec, prefix):
112         make('install')
113 
114     @run_after('install')
115     def install_cpanm(self):
116         spec = self.spec
117 
118         if '+cpanm' in spec:
119             with working_dir(join_path('cpanm', 'cpanm')):
120                 perl = spec['perl'].command
121                 perl('Makefile.PL')
122                 make()
123                 make('install')
124 
125     def setup_environment(self, spack_env, run_env):
126         """Set PERL5LIB to support activation of Perl packages"""
127         run_env.set('PERL5LIB', join_path(self.prefix, 'lib', 'perl5'))
128 
129     def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
130         """Set PATH and PERL5LIB to include the extension and
131            any other perl extensions it depends on,
132            assuming they were installed with INSTALL_BASE defined."""
133         perl_lib_dirs = []
134         perl_bin_dirs = []
135         for d in dependent_spec.traverse(
136                 deptype=('build', 'run'), deptype_query='run'):
137             if d.package.extends(self.spec):
138                 perl_lib_dirs.append(join_path(d.prefix, 'lib', 'perl5'))
139                 perl_bin_dirs.append(join_path(d.prefix, 'bin'))
140         perl_bin_path = ':'.join(perl_bin_dirs)
141         perl_lib_path = ':'.join(perl_lib_dirs)
142         spack_env.prepend_path('PATH', perl_bin_path)
143         spack_env.prepend_path('PERL5LIB', perl_lib_path)
144         run_env.prepend_path('PATH', perl_bin_path)
145         run_env.prepend_path('PERL5LIB', perl_lib_path)
146 
147     def setup_dependent_package(self, module, dependent_spec):
148         """Called before perl modules' install() methods.
149            In most cases, extensions will only need to have one line:
150            perl('Makefile.PL','INSTALL_BASE=%s' % self.prefix)
151         """
152 
153         # perl extension builds can have a global perl executable function
154         module.perl = Executable(join_path(self.spec.prefix.bin, 'perl'))
155 
156         # Add variables for library directory
157         module.perl_lib_dir = join_path(dependent_spec.prefix, 'lib', 'perl5')
158 
159         # Make the site packages directory for extensions,
160         # if it does not exist already.
161         if dependent_spec.package.is_extension:
162             mkdirp(module.perl_lib_dir)
163
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py
--- 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 @@
         # 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)

{"golden_diff": "diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py\n--- a/var/spack/repos/builtin/packages/perl/package.py\n+++ b/var/spack/repos/builtin/packages/perl/package.py\n@@ -31,6 +31,7 @@\n # Date: September 6, 2015\n #\n from spack import *\n+import os\n \n \n class Perl(Package):  # Perl doesn't use Autotools, it should subclass Package\n@@ -160,3 +161,33 @@\n         # if it does not exist already.\n         if dependent_spec.package.is_extension:\n             mkdirp(module.perl_lib_dir)\n+\n+    @run_after('install')\n+    def filter_config_dot_pm(self):\n+        \"\"\"Run after install so that Config.pm records the compiler that Spack\n+        built the package with.  If this isn't done, $Config{cc} will\n+        be set to Spack's cc wrapper script.\n+        \"\"\"\n+\n+        kwargs = {'ignore_absent': True, 'backup': False, 'string': False}\n+\n+        # Find the actual path to the installed Config.pm file.\n+        perl = Executable(join_path(prefix.bin, 'perl'))\n+        config_dot_pm = perl('-MModule::Loaded', '-MConfig', '-e',\n+                             'print is_loaded(Config)', output=str)\n+\n+        match = 'cc *=>.*'\n+        substitute = \"cc => '{cc}',\".format(cc=self.compiler.cc)\n+        filter_file(match, substitute, config_dot_pm, **kwargs)\n+\n+        # And the path Config_heavy.pl\n+        d = os.path.dirname(config_dot_pm)\n+        config_heavy = join_path(d, 'Config_heavy.pl')\n+\n+        match = '^cc=.*'\n+        substitute = \"cc='{cc}'\".format(cc=self.compiler.cc)\n+        filter_file(match, substitute, config_heavy, **kwargs)\n+\n+        match = '^ld=.*'\n+        substitute = \"ld='{ld}'\".format(ld=self.compiler.cc)\n+        filter_file(match, substitute, config_heavy, **kwargs)\n", "issue": "perl \"remembers\" spack's compiler, which does the wrong thing\nAdditional Perl packages (e.g. from CPAN) should (need to) be built with the same compiler that built `perl` itself.\r\n\r\nPerl handles this detail by remembering the compiler with which it was built.  It \"remembers\" it by stashing a copy of it in the `Config` hash defined in `Config.pm`:\r\n\r\n```perl\r\ntie %Config, 'Config', {\r\n    archlibexp => '/home/hartzelg/tmp/spack-perl-cc/opt/spack/linux-centos7-x86_64/gcc-4.8.5/perl-5.24.1-35ejv4426dmzreum4ekdibu3ddmhquvi/lib/5.24.1/x86_64-linux',\r\n    archname => 'x86_64-linux',\r\n    cc => 'cc',\r\n    # [...]\r\n```\r\n\r\nOn my system this drags `/usr/bin/cc` into the fray, resulting in sadness.\r\n\r\nAs an example, using the `cpanm` that Spack built\r\n\r\n```\r\ncpanm -l /path/to/library/dir XML::Simple\r\n```\r\n\r\nwill eventually fail while trying to build `Net::HTTP` because it tries to use `cc` as its compiler.\r\n\r\nAs a quick hack/test, telling configure to use `gcc` as the C compiler results `$Config{cc}` containing `gcc` and happily the first gcc on my path is the one I used to build Perl.\r\n\r\n```diff\r\ndiff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py\r\nindex 10895f60..ed30bac5 100644\r\n--- a/var/spack/repos/builtin/packages/perl/package.py\r\n+++ b/var/spack/repos/builtin/packages/perl/package.py\r\n@@ -86,7 +86,8 @@ class Perl(Package):  # Perl doesn't use Autotools, it should subclass Package\r\n             '-des',\r\n             '-Dprefix={0}'.format(prefix),\r\n             '-Dlocincpth=' + self.spec['gdbm'].prefix.include,\r\n-            '-Dloclibpth=' + self.spec['gdbm'].prefix.lib\r\n+            '-Dloclibpth=' + self.spec['gdbm'].prefix.lib,\r\n+            '-Dcc=gcc'\r\n         ]\r\n\r\n         # Discussion of -fPIC for Intel at:\r\n```\r\n\r\nThis changes lets `Net::HTTP` build and install.\r\n\r\nSpack's compiler wrappers and *etc* seem magical to me.  What's a good way to fix this?\r\n\r\n\r\n\r\n\r\n\r\n\r\n\n", "before_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\n#\n# Author: Milton Woods <milton.woods@bom.gov.au>\n# Date: March 22, 2017\n# Author: George Hartzell <hartzell@alerce.com>\n# Date: July 21, 2016\n# Author: Justin Too <justin@doubleotoo.com>\n# Date: September 6, 2015\n#\nfrom spack import *\n\n\nclass Perl(Package):  # Perl doesn't use Autotools, it should subclass Package\n    \"\"\"Perl 5 is a highly capable, feature-rich programming language with over\n       27 years of development.\"\"\"\n\n    homepage = \"http://www.perl.org\"\n    # URL must remain http:// so Spack can bootstrap curl\n    url = \"http://www.cpan.org/src/5.0/perl-5.24.1.tar.gz\"\n\n    # Development releases\n    version('5.25.11', '37a398682c36cd85992b34b5c1c25dc1')\n\n    # Maintenance releases (recommended)\n    version('5.24.1', '765ef511b5b87a164e2531403ee16b3c', preferred=True)\n    version('5.22.3', 'aa4f236dc2fc6f88b871436b8d0fda95')\n\n    # Misc releases that people need\n    version('5.22.2', '5767e2a10dd62a46d7b57f74a90d952b')\n    version('5.22.1', '19295bbb775a3c36123161b9bf4892f1')\n\n    # End of life releases\n    version('5.20.3', 'd647d0ea5a7a8194c34759ab9f2610cd')\n    version('5.18.4', '1f9334ff730adc05acd3dd7130d295db')\n    version('5.16.3', 'eb5c40f2575df6c155bc99e3fe0a9d82')\n\n    extendable = True\n\n    depends_on('gdbm')\n\n    # Installing cpanm alongside the core makes it safe and simple for\n    # people/projects to install their own sets of perl modules.  Not\n    # having it in core increases the \"energy of activation\" for doing\n    # things cleanly.\n    variant('cpanm', default=True,\n            description='Optionally install cpanm with the core packages.')\n\n    resource(\n        name=\"cpanm\",\n        url=\"http://search.cpan.org/CPAN/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7042.tar.gz\",\n        md5=\"e87f55fbcb3c13a4754500c18e89219f\",\n        destination=\"cpanm\",\n        placement=\"cpanm\"\n    )\n\n    phases = ['configure', 'build', 'install']\n\n    def configure_args(self):\n        spec = self.spec\n        prefix = self.prefix\n\n        config_args = [\n            '-des',\n            '-Dprefix={0}'.format(prefix),\n            '-Dlocincpth=' + self.spec['gdbm'].prefix.include,\n            '-Dloclibpth=' + self.spec['gdbm'].prefix.lib\n        ]\n\n        # Discussion of -fPIC for Intel at:\n        # https://github.com/LLNL/spack/pull/3081\n        if spec.satisfies('%intel'):\n            config_args.append('-Accflags={0}'.format(self.compiler.pic_flag))\n\n        return config_args\n\n    def configure(self, spec, prefix):\n        configure = Executable('./Configure')\n        configure(*self.configure_args())\n\n    def build(self, spec, prefix):\n        make()\n\n    @run_after('build')\n    @on_package_attributes(run_tests=True)\n    def test(self):\n        make('test')\n\n    def install(self, spec, prefix):\n        make('install')\n\n    @run_after('install')\n    def install_cpanm(self):\n        spec = self.spec\n\n        if '+cpanm' in spec:\n            with working_dir(join_path('cpanm', 'cpanm')):\n                perl = spec['perl'].command\n                perl('Makefile.PL')\n                make()\n                make('install')\n\n    def setup_environment(self, spack_env, run_env):\n        \"\"\"Set PERL5LIB to support activation of Perl packages\"\"\"\n        run_env.set('PERL5LIB', join_path(self.prefix, 'lib', 'perl5'))\n\n    def setup_dependent_environment(self, spack_env, run_env, dependent_spec):\n        \"\"\"Set PATH and PERL5LIB to include the extension and\n           any other perl extensions it depends on,\n           assuming they were installed with INSTALL_BASE defined.\"\"\"\n        perl_lib_dirs = []\n        perl_bin_dirs = []\n        for d in dependent_spec.traverse(\n                deptype=('build', 'run'), deptype_query='run'):\n            if d.package.extends(self.spec):\n                perl_lib_dirs.append(join_path(d.prefix, 'lib', 'perl5'))\n                perl_bin_dirs.append(join_path(d.prefix, 'bin'))\n        perl_bin_path = ':'.join(perl_bin_dirs)\n        perl_lib_path = ':'.join(perl_lib_dirs)\n        spack_env.prepend_path('PATH', perl_bin_path)\n        spack_env.prepend_path('PERL5LIB', perl_lib_path)\n        run_env.prepend_path('PATH', perl_bin_path)\n        run_env.prepend_path('PERL5LIB', perl_lib_path)\n\n    def setup_dependent_package(self, module, dependent_spec):\n        \"\"\"Called before perl modules' install() methods.\n           In most cases, extensions will only need to have one line:\n           perl('Makefile.PL','INSTALL_BASE=%s' % self.prefix)\n        \"\"\"\n\n        # perl extension builds can have a global perl executable function\n        module.perl = Executable(join_path(self.spec.prefix.bin, 'perl'))\n\n        # Add variables for library directory\n        module.perl_lib_dir = join_path(dependent_spec.prefix, 'lib', 'perl5')\n\n        # Make the site packages directory for extensions,\n        # if it does not exist already.\n        if dependent_spec.package.is_extension:\n            mkdirp(module.perl_lib_dir)\n", "path": "var/spack/repos/builtin/packages/perl/package.py"}], "after_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\n#\n# Author: Milton Woods <milton.woods@bom.gov.au>\n# Date: March 22, 2017\n# Author: George Hartzell <hartzell@alerce.com>\n# Date: July 21, 2016\n# Author: Justin Too <justin@doubleotoo.com>\n# Date: September 6, 2015\n#\nfrom spack import *\nimport os\n\n\nclass Perl(Package):  # Perl doesn't use Autotools, it should subclass Package\n    \"\"\"Perl 5 is a highly capable, feature-rich programming language with over\n       27 years of development.\"\"\"\n\n    homepage = \"http://www.perl.org\"\n    # URL must remain http:// so Spack can bootstrap curl\n    url = \"http://www.cpan.org/src/5.0/perl-5.24.1.tar.gz\"\n\n    # Development releases\n    version('5.25.11', '37a398682c36cd85992b34b5c1c25dc1')\n\n    # Maintenance releases (recommended)\n    version('5.24.1', '765ef511b5b87a164e2531403ee16b3c', preferred=True)\n    version('5.22.3', 'aa4f236dc2fc6f88b871436b8d0fda95')\n\n    # Misc releases that people need\n    version('5.22.2', '5767e2a10dd62a46d7b57f74a90d952b')\n    version('5.22.1', '19295bbb775a3c36123161b9bf4892f1')\n\n    # End of life releases\n    version('5.20.3', 'd647d0ea5a7a8194c34759ab9f2610cd')\n    version('5.18.4', '1f9334ff730adc05acd3dd7130d295db')\n    version('5.16.3', 'eb5c40f2575df6c155bc99e3fe0a9d82')\n\n    extendable = True\n\n    depends_on('gdbm')\n\n    # Installing cpanm alongside the core makes it safe and simple for\n    # people/projects to install their own sets of perl modules.  Not\n    # having it in core increases the \"energy of activation\" for doing\n    # things cleanly.\n    variant('cpanm', default=True,\n            description='Optionally install cpanm with the core packages.')\n\n    resource(\n        name=\"cpanm\",\n        url=\"http://search.cpan.org/CPAN/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7042.tar.gz\",\n        md5=\"e87f55fbcb3c13a4754500c18e89219f\",\n        destination=\"cpanm\",\n        placement=\"cpanm\"\n    )\n\n    phases = ['configure', 'build', 'install']\n\n    def configure_args(self):\n        spec = self.spec\n        prefix = self.prefix\n\n        config_args = [\n            '-des',\n            '-Dprefix={0}'.format(prefix),\n            '-Dlocincpth=' + self.spec['gdbm'].prefix.include,\n            '-Dloclibpth=' + self.spec['gdbm'].prefix.lib\n        ]\n\n        # Discussion of -fPIC for Intel at:\n        # https://github.com/LLNL/spack/pull/3081\n        if spec.satisfies('%intel'):\n            config_args.append('-Accflags={0}'.format(self.compiler.pic_flag))\n\n        return config_args\n\n    def configure(self, spec, prefix):\n        configure = Executable('./Configure')\n        configure(*self.configure_args())\n\n    def build(self, spec, prefix):\n        make()\n\n    @run_after('build')\n    @on_package_attributes(run_tests=True)\n    def test(self):\n        make('test')\n\n    def install(self, spec, prefix):\n        make('install')\n\n    @run_after('install')\n    def install_cpanm(self):\n        spec = self.spec\n\n        if '+cpanm' in spec:\n            with working_dir(join_path('cpanm', 'cpanm')):\n                perl = spec['perl'].command\n                perl('Makefile.PL')\n                make()\n                make('install')\n\n    def setup_environment(self, spack_env, run_env):\n        \"\"\"Set PERL5LIB to support activation of Perl packages\"\"\"\n        run_env.set('PERL5LIB', join_path(self.prefix, 'lib', 'perl5'))\n\n    def setup_dependent_environment(self, spack_env, run_env, dependent_spec):\n        \"\"\"Set PATH and PERL5LIB to include the extension and\n           any other perl extensions it depends on,\n           assuming they were installed with INSTALL_BASE defined.\"\"\"\n        perl_lib_dirs = []\n        perl_bin_dirs = []\n        for d in dependent_spec.traverse(\n                deptype=('build', 'run'), deptype_query='run'):\n            if d.package.extends(self.spec):\n                perl_lib_dirs.append(join_path(d.prefix, 'lib', 'perl5'))\n                perl_bin_dirs.append(join_path(d.prefix, 'bin'))\n        perl_bin_path = ':'.join(perl_bin_dirs)\n        perl_lib_path = ':'.join(perl_lib_dirs)\n        spack_env.prepend_path('PATH', perl_bin_path)\n        spack_env.prepend_path('PERL5LIB', perl_lib_path)\n        run_env.prepend_path('PATH', perl_bin_path)\n        run_env.prepend_path('PERL5LIB', perl_lib_path)\n\n    def setup_dependent_package(self, module, dependent_spec):\n        \"\"\"Called before perl modules' install() methods.\n           In most cases, extensions will only need to have one line:\n           perl('Makefile.PL','INSTALL_BASE=%s' % self.prefix)\n        \"\"\"\n\n        # perl extension builds can have a global perl executable function\n        module.perl = Executable(join_path(self.spec.prefix.bin, 'perl'))\n\n        # Add variables for library directory\n        module.perl_lib_dir = join_path(dependent_spec.prefix, 'lib', 'perl5')\n\n        # Make the site packages directory for extensions,\n        # if it does not exist already.\n        if dependent_spec.package.is_extension:\n            mkdirp(module.perl_lib_dir)\n\n    @run_after('install')\n    def filter_config_dot_pm(self):\n        \"\"\"Run after install so that Config.pm records the compiler that Spack\n        built the package with.  If this isn't done, $Config{cc} will\n        be set to Spack's cc wrapper script.\n        \"\"\"\n\n        kwargs = {'ignore_absent': True, 'backup': False, 'string': False}\n\n        # Find the actual path to the installed Config.pm file.\n        perl = Executable(join_path(prefix.bin, 'perl'))\n        config_dot_pm = perl('-MModule::Loaded', '-MConfig', '-e',\n                             'print is_loaded(Config)', output=str)\n\n        match = 'cc *=>.*'\n        substitute = \"cc => '{cc}',\".format(cc=self.compiler.cc)\n        filter_file(match, substitute, config_dot_pm, **kwargs)\n\n        # And the path Config_heavy.pl\n        d = os.path.dirname(config_dot_pm)\n        config_heavy = join_path(d, 'Config_heavy.pl')\n\n        match = '^cc=.*'\n        substitute = \"cc='{cc}'\".format(cc=self.compiler.cc)\n        filter_file(match, substitute, config_heavy, **kwargs)\n\n        match = '^ld=.*'\n        substitute = \"ld='{ld}'\".format(ld=self.compiler.cc)\n        filter_file(match, substitute, config_heavy, **kwargs)\n", "path": "var/spack/repos/builtin/packages/perl/package.py"}]}