We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
spack find : always prompt 0 installed packages
On a clean `develop` checkout : 

```
$ git clone https://github.com/LLNL/spack.git
Cloning into 'spack'...
remote: Counting objects: 25613, done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 25613 (delta 12), reused 3 (delta 3), pack-reused 25557
Receiving objects: 100% (25613/25613), 6.65 MiB | 6.46 MiB/s, done.
Resolving deltas: 100% (13031/13031), done.
Checking connectivity... done.

$ cd spack
$ . share/spack/setup-env.sh 
$ spack compilers
==> Available compilers
-- gcc ----------------------------------------------------------
gcc@4.8

$ spack install zlib
==> Installing zlib
==> Trying to fetch from file:///home/mculpo/production/spack-mirror/zlib/zlib-1.2.8.tar.gz
######################################################################## 100,0%
==> Staging archive: /home/mculpo/tmp/spack/var/spack/stage/zlib-1.2.8-d6pdl6xvnvap6ihrqcqtgvweghbszmix/zlib-1.2.8.tar.gz
==> Created stage in /home/mculpo/tmp/spack/var/spack/stage/zlib-1.2.8-d6pdl6xvnvap6ihrqcqtgvweghbszmix
==> No patches needed for zlib
==> Building zlib
==> Successfully installed zlib
  Fetch: 0.01s.  Build: 3.69s.  Total: 3.70s.
[+] /home/mculpo/tmp/spack/opt/spack/linux-x86_64/gcc-4.8/zlib-1.2.8-d6pdl6xvnvap6ihrqcqtgvweghbszmix

$ spack find
==> 0 installed packages.

$ spack install szip
==> Installing szip
==> Trying to fetch from file:///home/mculpo/production/spack-mirror/szip/szip-2.1.tar.gz
######################################################################## 100,0%
==> Staging archive: /home/mculpo/tmp/spack/var/spack/stage/szip-2.1-esfmhl54wbdb7nnnip6y6jbxlbmxs2jq/szip-2.1.tar.gz
==> Created stage in /home/mculpo/tmp/spack/var/spack/stage/szip-2.1-esfmhl54wbdb7nnnip6y6jbxlbmxs2jq
==> No patches needed for szip
==> Building szip
==> Successfully installed szip
  Fetch: 0.01s.  Build: 8.09s.  Total: 8.10s.
[+] /home/mculpo/tmp/spack/opt/spack/linux-x86_64/gcc-4.8/szip-2.1-esfmhl54wbdb7nnnip6y6jbxlbmxs2jq

$ spack find 
==> 0 installed packages.
```

The db seems to be written correctly : 

```
database:
  installs:
    d6pdl6xvnvap6ihrqcqtgvweghbszmix:
      explicit: true
      installed: true
      path: /home/mculpo/tmp/spack/opt/spack/linux-x86_64/gcc-4.8/zlib-1.2.8-d6pdl6xvnvap6ihrqcqtgvweghbszmix
      ref_count: 0
      spec:
        zlib:
          arch: linux-x86_64
          compiler:
            name: gcc
            version: '4.8'
          dependencies: {}
          namespace: builtin
          parameters:
            cflags: []
            cppflags: []
            cxxflags: []
            fflags: []
            ldflags: []
            ldlibs: []
          version: 1.2.8
    esfmhl54wbdb7nnnip6y6jbxlbmxs2jq:
      explicit: true
      installed: true
      path: /home/mculpo/tmp/spack/opt/spack/linux-x86_64/gcc-4.8/szip-2.1-esfmhl54wbdb7nnnip6y6jbxlbmxs2jq
      ref_count: 0
      spec:
        szip:
          arch: linux-x86_64
          compiler:
            name: gcc
            version: '4.8'
          dependencies: {}
          namespace: builtin
          parameters:
            cflags: []
            cppflags: []
            cxxflags: []
            fflags: []
            ldflags: []
            ldlibs: []
          version: '2.1'
  version: 0.9.1
```


--- 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/openblas/package.py`
Content:
```
1 ##############################################################################
2 # Copyright (c) 2013-2017, 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/spack/spack
10 # Please also see the NOTICE and LICENSE files 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 import os
26 
27 from spack import *
28 from spack.package_test import compare_output_file, compile_c_and_execute
29 import spack.architecture
30 
31 
32 class Openblas(MakefilePackage):
33     """OpenBLAS: An optimized BLAS library"""
34     homepage = 'http://www.openblas.net'
35     url = 'http://github.com/xianyi/OpenBLAS/archive/v0.2.19.tar.gz'
36 
37     version('0.2.20', '48637eb29f5b492b91459175dcc574b1')
38     version('0.2.19', '28c998054fd377279741c6f0b9ea7941')
39     version('0.2.18', '805e7f660877d588ea7e3792cda2ee65')
40     version('0.2.17', '664a12807f2a2a7cda4781e3ab2ae0e1')
41     version('0.2.16', 'fef46ab92463bdbb1479dcec594ef6dc')
42     version('0.2.15', 'b1190f3d3471685f17cfd1ec1d252ac9')
43     version('develop', git='https://github.com/xianyi/OpenBLAS.git', branch='develop')
44 
45     variant(
46         'shared',
47         default=True,
48         description='Build shared libraries as well as static libs.'
49     )
50     variant('ilp64', default=False, description='64 bit integers')
51     variant('pic', default=True, description='Build position independent code')
52 
53     variant('cpu_target', default='',
54                     description='Set CPU target architecture (leave empty for '
55                         'autodetection; GENERIC, SSE_GENERIC, NEHALEM, ...)')
56 
57     variant(
58         'threads', default='none',
59         description='Multithreading support',
60         values=('pthreads', 'openmp', 'none'),
61         multi=False
62     )
63 
64     # virtual dependency
65     provides('blas')
66     provides('lapack')
67 
68     patch('make.patch', when='@0.2.16:')
69     #  This patch is in a pull request to OpenBLAS that has not been handled
70     #  https://github.com/xianyi/OpenBLAS/pull/915
71     #  UPD: the patch has been merged starting version 0.2.20
72     patch('openblas_icc.patch', when='@:0.2.19%intel')
73     patch('openblas_icc_openmp.patch', when='%intel@16.0:')
74     patch('openblas_icc_fortran.patch', when='%intel@16.0:')
75 
76     # Fixes compilation error on POWER8 with GCC 7
77     # https://github.com/xianyi/OpenBLAS/pull/1098
78     patch('power8.patch', when='@0.2.18:0.2.19 %gcc@7.1.0: target=ppc64')
79 
80     # Change file comments to work around clang 3.9 assembler bug
81     # https://github.com/xianyi/OpenBLAS/pull/982
82     patch('openblas0.2.19.diff', when='@0.2.19')
83 
84     parallel = False
85 
86     conflicts('%intel@16', when='@0.2.15:0.2.19')
87 
88     @run_before('edit')
89     def check_compilers(self):
90         # As of 06/2016 there is no mechanism to specify that packages which
91         # depends on Blas/Lapack need C or/and Fortran symbols. For now
92         # require both.
93         if self.compiler.f77 is None:
94             raise InstallError(
95                 'OpenBLAS requires both C and Fortran compilers!'
96             )
97         # Add support for OpenMP
98         if (self.spec.satisfies('threads=openmp') and
99             self.spec.satisfies('%clang')):
100             if str(self.spec.compiler.version).endswith('-apple'):
101                 raise InstallError("Apple's clang does not support OpenMP")
102             if '@:0.2.19' in self.spec:
103                 # Openblas (as of 0.2.19) hardcoded that OpenMP cannot
104                 # be used with any (!) compiler named clang, bummer.
105                 raise InstallError(
106                     'OpenBLAS @:0.2.19 does not support OpenMP with clang!'
107                 )
108 
109     @property
110     def make_defs(self):
111         # Configure fails to pick up fortran from FC=/abs/path/to/f77, but
112         # works fine with FC=/abs/path/to/gfortran.
113         # When mixing compilers make sure that
114         # $SPACK_ROOT/lib/spack/env/<compiler> have symlinks with reasonable
115         # names and hack them inside lib/spack/spack/compilers/<compiler>.py
116 
117         make_defs = [
118             'CC={0}'.format(spack_cc),
119             'FC={0}'.format(spack_f77),
120             'MAKE_NO_J=1'
121         ]
122         if self.spec.variants['cpu_target'].value:
123             make_defs += [
124                 'TARGET={0}'.format(self.spec.variants['cpu_target'].value)
125             ]
126         # invoke make with the correct TARGET for aarch64
127         elif 'aarch64' in spack.architecture.sys_type():
128             make_defs += [
129                 'TARGET=PILEDRIVER',
130                 'TARGET=ARMV8'
131             ]
132         if self.spec.satisfies('%gcc@:4.8.4'):
133             make_defs += ['NO_AVX2=1']
134         if '~shared' in self.spec:
135             if '+pic' in self.spec:
136                 make_defs.extend([
137                     'CFLAGS={0}'.format(self.compiler.pic_flag),
138                     'FFLAGS={0}'.format(self.compiler.pic_flag)
139                 ])
140             make_defs += ['NO_SHARED=1']
141         # fix missing _dggsvd_ and _sggsvd_
142         if self.spec.satisfies('@0.2.16'):
143             make_defs += ['BUILD_LAPACK_DEPRECATED=1']
144 
145         # Add support for multithreading
146         if self.spec.satisfies('threads=openmp'):
147             make_defs += ['USE_OPENMP=1', 'USE_THREAD=1']
148         elif self.spec.satisfies('threads=pthreads'):
149             make_defs += ['USE_OPENMP=0', 'USE_THREAD=1']
150         else:
151             make_defs += ['USE_OPENMP=0', 'USE_THREAD=0']
152 
153         # 64bit ints
154         if '+ilp64' in self.spec:
155             make_defs += ['INTERFACE64=1']
156 
157         return make_defs
158 
159     @property
160     def build_targets(self):
161         targets = ['libs', 'netlib']
162 
163         # Build shared if variant is set.
164         if '+shared' in self.spec:
165             targets += ['shared']
166 
167         return self.make_defs + targets
168 
169     @run_after('build')
170     @on_package_attributes(run_tests=True)
171     def check_build(self):
172         make('tests', *self.make_defs)
173 
174     @property
175     def install_targets(self):
176         make_args = [
177             'install',
178             'PREFIX={0}'.format(self.prefix),
179         ]
180         return make_args + self.make_defs
181 
182     @run_after('install')
183     @on_package_attributes(run_tests=True)
184     def check_install(self):
185         spec = self.spec
186         # Openblas may pass its own test but still fail to compile Lapack
187         # symbols. To make sure we get working Blas and Lapack, do a small
188         # test.
189         source_file = join_path(os.path.dirname(self.module.__file__),
190                                 'test_cblas_dgemm.c')
191         blessed_file = join_path(os.path.dirname(self.module.__file__),
192                                  'test_cblas_dgemm.output')
193 
194         include_flags = spec['openblas'].headers.cpp_flags
195         link_flags = spec['openblas'].libs.ld_flags
196         if self.compiler.name == 'intel':
197             link_flags += ' -lifcore'
198         if self.spec.satisfies('threads=pthreads'):
199             link_flags += ' -lpthread'
200         if spec.satisfies('threads=openmp'):
201             link_flags += ' -lpthread ' + self.compiler.openmp_flag
202 
203         output = compile_c_and_execute(
204             source_file, [include_flags], link_flags.split()
205         )
206         compare_output_file(output, blessed_file)
207
```
--- 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/openblas/package.py b/var/spack/repos/builtin/packages/openblas/package.py
--- a/var/spack/repos/builtin/packages/openblas/package.py
+++ b/var/spack/repos/builtin/packages/openblas/package.py
@@ -40,7 +40,8 @@
     version('0.2.17', '664a12807f2a2a7cda4781e3ab2ae0e1')
     version('0.2.16', 'fef46ab92463bdbb1479dcec594ef6dc')
     version('0.2.15', 'b1190f3d3471685f17cfd1ec1d252ac9')
-    version('develop', git='https://github.com/xianyi/OpenBLAS.git', branch='develop')
+    version('develop', git='https://github.com/xianyi/OpenBLAS.git',
+            branch='develop')
 
     variant(
         'shared',
@@ -61,6 +62,12 @@
         multi=False
     )
 
+    variant(
+        'virtual_machine',
+        default=False,
+        description="Adding options to build openblas on Linux virtual machine"
+    )
+
     # virtual dependency
     provides('blas')
     provides('lapack')
@@ -119,6 +126,13 @@
             'FC={0}'.format(spack_f77),
             'MAKE_NO_J=1'
         ]
+
+        if self.spec.variants['virtual_machine'].value:
+            make_defs += [
+                'DYNAMIC_ARCH=1',
+                'NO_AVX2=1'
+            ]
+
         if self.spec.variants['cpu_target'].value:
             make_defs += [
                 'TARGET={0}'.format(self.spec.variants['cpu_target'].value)

{"golden_diff": "diff --git a/var/spack/repos/builtin/packages/openblas/package.py b/var/spack/repos/builtin/packages/openblas/package.py\n--- a/var/spack/repos/builtin/packages/openblas/package.py\n+++ b/var/spack/repos/builtin/packages/openblas/package.py\n@@ -40,7 +40,8 @@\n     version('0.2.17', '664a12807f2a2a7cda4781e3ab2ae0e1')\n     version('0.2.16', 'fef46ab92463bdbb1479dcec594ef6dc')\n     version('0.2.15', 'b1190f3d3471685f17cfd1ec1d252ac9')\n-    version('develop', git='https://github.com/xianyi/OpenBLAS.git', branch='develop')\n+    version('develop', git='https://github.com/xianyi/OpenBLAS.git',\n+            branch='develop')\n \n     variant(\n         'shared',\n@@ -61,6 +62,12 @@\n         multi=False\n     )\n \n+    variant(\n+        'virtual_machine',\n+        default=False,\n+        description=\"Adding options to build openblas on Linux virtual machine\"\n+    )\n+\n     # virtual dependency\n     provides('blas')\n     provides('lapack')\n@@ -119,6 +126,13 @@\n             'FC={0}'.format(spack_f77),\n             'MAKE_NO_J=1'\n         ]\n+\n+        if self.spec.variants['virtual_machine'].value:\n+            make_defs += [\n+                'DYNAMIC_ARCH=1',\n+                'NO_AVX2=1'\n+            ]\n+\n         if self.spec.variants['cpu_target'].value:\n             make_defs += [\n                 'TARGET={0}'.format(self.spec.variants['cpu_target'].value)\n", "issue": "spack find : always prompt 0 installed packages\nOn a clean `develop` checkout : \n\n```\n$ git clone https://github.com/LLNL/spack.git\nCloning into 'spack'...\nremote: Counting objects: 25613, done.\nremote: Compressing objects: 100% (42/42), done.\nremote: Total 25613 (delta 12), reused 3 (delta 3), pack-reused 25557\nReceiving objects: 100% (25613/25613), 6.65 MiB | 6.46 MiB/s, done.\nResolving deltas: 100% (13031/13031), done.\nChecking connectivity... done.\n\n$ cd spack\n$ . share/spack/setup-env.sh \n$ spack compilers\n==> Available compilers\n-- gcc ----------------------------------------------------------\ngcc@4.8\n\n$ spack install zlib\n==> Installing zlib\n==> Trying to fetch from file:///home/mculpo/production/spack-mirror/zlib/zlib-1.2.8.tar.gz\n######################################################################## 100,0%\n==> Staging archive: /home/mculpo/tmp/spack/var/spack/stage/zlib-1.2.8-d6pdl6xvnvap6ihrqcqtgvweghbszmix/zlib-1.2.8.tar.gz\n==> Created stage in /home/mculpo/tmp/spack/var/spack/stage/zlib-1.2.8-d6pdl6xvnvap6ihrqcqtgvweghbszmix\n==> No patches needed for zlib\n==> Building zlib\n==> Successfully installed zlib\n  Fetch: 0.01s.  Build: 3.69s.  Total: 3.70s.\n[+] /home/mculpo/tmp/spack/opt/spack/linux-x86_64/gcc-4.8/zlib-1.2.8-d6pdl6xvnvap6ihrqcqtgvweghbszmix\n\n$ spack find\n==> 0 installed packages.\n\n$ spack install szip\n==> Installing szip\n==> Trying to fetch from file:///home/mculpo/production/spack-mirror/szip/szip-2.1.tar.gz\n######################################################################## 100,0%\n==> Staging archive: /home/mculpo/tmp/spack/var/spack/stage/szip-2.1-esfmhl54wbdb7nnnip6y6jbxlbmxs2jq/szip-2.1.tar.gz\n==> Created stage in /home/mculpo/tmp/spack/var/spack/stage/szip-2.1-esfmhl54wbdb7nnnip6y6jbxlbmxs2jq\n==> No patches needed for szip\n==> Building szip\n==> Successfully installed szip\n  Fetch: 0.01s.  Build: 8.09s.  Total: 8.10s.\n[+] /home/mculpo/tmp/spack/opt/spack/linux-x86_64/gcc-4.8/szip-2.1-esfmhl54wbdb7nnnip6y6jbxlbmxs2jq\n\n$ spack find \n==> 0 installed packages.\n```\n\nThe db seems to be written correctly : \n\n```\ndatabase:\n  installs:\n    d6pdl6xvnvap6ihrqcqtgvweghbszmix:\n      explicit: true\n      installed: true\n      path: /home/mculpo/tmp/spack/opt/spack/linux-x86_64/gcc-4.8/zlib-1.2.8-d6pdl6xvnvap6ihrqcqtgvweghbszmix\n      ref_count: 0\n      spec:\n        zlib:\n          arch: linux-x86_64\n          compiler:\n            name: gcc\n            version: '4.8'\n          dependencies: {}\n          namespace: builtin\n          parameters:\n            cflags: []\n            cppflags: []\n            cxxflags: []\n            fflags: []\n            ldflags: []\n            ldlibs: []\n          version: 1.2.8\n    esfmhl54wbdb7nnnip6y6jbxlbmxs2jq:\n      explicit: true\n      installed: true\n      path: /home/mculpo/tmp/spack/opt/spack/linux-x86_64/gcc-4.8/szip-2.1-esfmhl54wbdb7nnnip6y6jbxlbmxs2jq\n      ref_count: 0\n      spec:\n        szip:\n          arch: linux-x86_64\n          compiler:\n            name: gcc\n            version: '4.8'\n          dependencies: {}\n          namespace: builtin\n          parameters:\n            cflags: []\n            cppflags: []\n            cxxflags: []\n            fflags: []\n            ldflags: []\n            ldlibs: []\n          version: '2.1'\n  version: 0.9.1\n```\n\n", "before_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2017, 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/spack/spack\n# Please also see the NOTICE and LICENSE files 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##############################################################################\nimport os\n\nfrom spack import *\nfrom spack.package_test import compare_output_file, compile_c_and_execute\nimport spack.architecture\n\n\nclass Openblas(MakefilePackage):\n    \"\"\"OpenBLAS: An optimized BLAS library\"\"\"\n    homepage = 'http://www.openblas.net'\n    url = 'http://github.com/xianyi/OpenBLAS/archive/v0.2.19.tar.gz'\n\n    version('0.2.20', '48637eb29f5b492b91459175dcc574b1')\n    version('0.2.19', '28c998054fd377279741c6f0b9ea7941')\n    version('0.2.18', '805e7f660877d588ea7e3792cda2ee65')\n    version('0.2.17', '664a12807f2a2a7cda4781e3ab2ae0e1')\n    version('0.2.16', 'fef46ab92463bdbb1479dcec594ef6dc')\n    version('0.2.15', 'b1190f3d3471685f17cfd1ec1d252ac9')\n    version('develop', git='https://github.com/xianyi/OpenBLAS.git', branch='develop')\n\n    variant(\n        'shared',\n        default=True,\n        description='Build shared libraries as well as static libs.'\n    )\n    variant('ilp64', default=False, description='64 bit integers')\n    variant('pic', default=True, description='Build position independent code')\n\n    variant('cpu_target', default='',\n                    description='Set CPU target architecture (leave empty for '\n                        'autodetection; GENERIC, SSE_GENERIC, NEHALEM, ...)')\n\n    variant(\n        'threads', default='none',\n        description='Multithreading support',\n        values=('pthreads', 'openmp', 'none'),\n        multi=False\n    )\n\n    # virtual dependency\n    provides('blas')\n    provides('lapack')\n\n    patch('make.patch', when='@0.2.16:')\n    #  This patch is in a pull request to OpenBLAS that has not been handled\n    #  https://github.com/xianyi/OpenBLAS/pull/915\n    #  UPD: the patch has been merged starting version 0.2.20\n    patch('openblas_icc.patch', when='@:0.2.19%intel')\n    patch('openblas_icc_openmp.patch', when='%intel@16.0:')\n    patch('openblas_icc_fortran.patch', when='%intel@16.0:')\n\n    # Fixes compilation error on POWER8 with GCC 7\n    # https://github.com/xianyi/OpenBLAS/pull/1098\n    patch('power8.patch', when='@0.2.18:0.2.19 %gcc@7.1.0: target=ppc64')\n\n    # Change file comments to work around clang 3.9 assembler bug\n    # https://github.com/xianyi/OpenBLAS/pull/982\n    patch('openblas0.2.19.diff', when='@0.2.19')\n\n    parallel = False\n\n    conflicts('%intel@16', when='@0.2.15:0.2.19')\n\n    @run_before('edit')\n    def check_compilers(self):\n        # As of 06/2016 there is no mechanism to specify that packages which\n        # depends on Blas/Lapack need C or/and Fortran symbols. For now\n        # require both.\n        if self.compiler.f77 is None:\n            raise InstallError(\n                'OpenBLAS requires both C and Fortran compilers!'\n            )\n        # Add support for OpenMP\n        if (self.spec.satisfies('threads=openmp') and\n            self.spec.satisfies('%clang')):\n            if str(self.spec.compiler.version).endswith('-apple'):\n                raise InstallError(\"Apple's clang does not support OpenMP\")\n            if '@:0.2.19' in self.spec:\n                # Openblas (as of 0.2.19) hardcoded that OpenMP cannot\n                # be used with any (!) compiler named clang, bummer.\n                raise InstallError(\n                    'OpenBLAS @:0.2.19 does not support OpenMP with clang!'\n                )\n\n    @property\n    def make_defs(self):\n        # Configure fails to pick up fortran from FC=/abs/path/to/f77, but\n        # works fine with FC=/abs/path/to/gfortran.\n        # When mixing compilers make sure that\n        # $SPACK_ROOT/lib/spack/env/<compiler> have symlinks with reasonable\n        # names and hack them inside lib/spack/spack/compilers/<compiler>.py\n\n        make_defs = [\n            'CC={0}'.format(spack_cc),\n            'FC={0}'.format(spack_f77),\n            'MAKE_NO_J=1'\n        ]\n        if self.spec.variants['cpu_target'].value:\n            make_defs += [\n                'TARGET={0}'.format(self.spec.variants['cpu_target'].value)\n            ]\n        # invoke make with the correct TARGET for aarch64\n        elif 'aarch64' in spack.architecture.sys_type():\n            make_defs += [\n                'TARGET=PILEDRIVER',\n                'TARGET=ARMV8'\n            ]\n        if self.spec.satisfies('%gcc@:4.8.4'):\n            make_defs += ['NO_AVX2=1']\n        if '~shared' in self.spec:\n            if '+pic' in self.spec:\n                make_defs.extend([\n                    'CFLAGS={0}'.format(self.compiler.pic_flag),\n                    'FFLAGS={0}'.format(self.compiler.pic_flag)\n                ])\n            make_defs += ['NO_SHARED=1']\n        # fix missing _dggsvd_ and _sggsvd_\n        if self.spec.satisfies('@0.2.16'):\n            make_defs += ['BUILD_LAPACK_DEPRECATED=1']\n\n        # Add support for multithreading\n        if self.spec.satisfies('threads=openmp'):\n            make_defs += ['USE_OPENMP=1', 'USE_THREAD=1']\n        elif self.spec.satisfies('threads=pthreads'):\n            make_defs += ['USE_OPENMP=0', 'USE_THREAD=1']\n        else:\n            make_defs += ['USE_OPENMP=0', 'USE_THREAD=0']\n\n        # 64bit ints\n        if '+ilp64' in self.spec:\n            make_defs += ['INTERFACE64=1']\n\n        return make_defs\n\n    @property\n    def build_targets(self):\n        targets = ['libs', 'netlib']\n\n        # Build shared if variant is set.\n        if '+shared' in self.spec:\n            targets += ['shared']\n\n        return self.make_defs + targets\n\n    @run_after('build')\n    @on_package_attributes(run_tests=True)\n    def check_build(self):\n        make('tests', *self.make_defs)\n\n    @property\n    def install_targets(self):\n        make_args = [\n            'install',\n            'PREFIX={0}'.format(self.prefix),\n        ]\n        return make_args + self.make_defs\n\n    @run_after('install')\n    @on_package_attributes(run_tests=True)\n    def check_install(self):\n        spec = self.spec\n        # Openblas may pass its own test but still fail to compile Lapack\n        # symbols. To make sure we get working Blas and Lapack, do a small\n        # test.\n        source_file = join_path(os.path.dirname(self.module.__file__),\n                                'test_cblas_dgemm.c')\n        blessed_file = join_path(os.path.dirname(self.module.__file__),\n                                 'test_cblas_dgemm.output')\n\n        include_flags = spec['openblas'].headers.cpp_flags\n        link_flags = spec['openblas'].libs.ld_flags\n        if self.compiler.name == 'intel':\n            link_flags += ' -lifcore'\n        if self.spec.satisfies('threads=pthreads'):\n            link_flags += ' -lpthread'\n        if spec.satisfies('threads=openmp'):\n            link_flags += ' -lpthread ' + self.compiler.openmp_flag\n\n        output = compile_c_and_execute(\n            source_file, [include_flags], link_flags.split()\n        )\n        compare_output_file(output, blessed_file)\n", "path": "var/spack/repos/builtin/packages/openblas/package.py"}], "after_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2017, 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/spack/spack\n# Please also see the NOTICE and LICENSE files 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##############################################################################\nimport os\n\nfrom spack import *\nfrom spack.package_test import compare_output_file, compile_c_and_execute\nimport spack.architecture\n\n\nclass Openblas(MakefilePackage):\n    \"\"\"OpenBLAS: An optimized BLAS library\"\"\"\n    homepage = 'http://www.openblas.net'\n    url = 'http://github.com/xianyi/OpenBLAS/archive/v0.2.19.tar.gz'\n\n    version('0.2.20', '48637eb29f5b492b91459175dcc574b1')\n    version('0.2.19', '28c998054fd377279741c6f0b9ea7941')\n    version('0.2.18', '805e7f660877d588ea7e3792cda2ee65')\n    version('0.2.17', '664a12807f2a2a7cda4781e3ab2ae0e1')\n    version('0.2.16', 'fef46ab92463bdbb1479dcec594ef6dc')\n    version('0.2.15', 'b1190f3d3471685f17cfd1ec1d252ac9')\n    version('develop', git='https://github.com/xianyi/OpenBLAS.git',\n            branch='develop')\n\n    variant(\n        'shared',\n        default=True,\n        description='Build shared libraries as well as static libs.'\n    )\n    variant('ilp64', default=False, description='64 bit integers')\n    variant('pic', default=True, description='Build position independent code')\n\n    variant('cpu_target', default='',\n                    description='Set CPU target architecture (leave empty for '\n                        'autodetection; GENERIC, SSE_GENERIC, NEHALEM, ...)')\n\n    variant(\n        'threads', default='none',\n        description='Multithreading support',\n        values=('pthreads', 'openmp', 'none'),\n        multi=False\n    )\n\n    variant(\n        'virtual_machine',\n        default=False,\n        description=\"Adding options to build openblas on Linux virtual machine\"\n    )\n\n    # virtual dependency\n    provides('blas')\n    provides('lapack')\n\n    patch('make.patch', when='@0.2.16:')\n    #  This patch is in a pull request to OpenBLAS that has not been handled\n    #  https://github.com/xianyi/OpenBLAS/pull/915\n    #  UPD: the patch has been merged starting version 0.2.20\n    patch('openblas_icc.patch', when='@:0.2.19%intel')\n    patch('openblas_icc_openmp.patch', when='%intel@16.0:')\n    patch('openblas_icc_fortran.patch', when='%intel@16.0:')\n\n    # Fixes compilation error on POWER8 with GCC 7\n    # https://github.com/xianyi/OpenBLAS/pull/1098\n    patch('power8.patch', when='@0.2.18:0.2.19 %gcc@7.1.0: target=ppc64')\n\n    # Change file comments to work around clang 3.9 assembler bug\n    # https://github.com/xianyi/OpenBLAS/pull/982\n    patch('openblas0.2.19.diff', when='@0.2.19')\n\n    parallel = False\n\n    conflicts('%intel@16', when='@0.2.15:0.2.19')\n\n    @run_before('edit')\n    def check_compilers(self):\n        # As of 06/2016 there is no mechanism to specify that packages which\n        # depends on Blas/Lapack need C or/and Fortran symbols. For now\n        # require both.\n        if self.compiler.f77 is None:\n            raise InstallError(\n                'OpenBLAS requires both C and Fortran compilers!'\n            )\n        # Add support for OpenMP\n        if (self.spec.satisfies('threads=openmp') and\n            self.spec.satisfies('%clang')):\n            if str(self.spec.compiler.version).endswith('-apple'):\n                raise InstallError(\"Apple's clang does not support OpenMP\")\n            if '@:0.2.19' in self.spec:\n                # Openblas (as of 0.2.19) hardcoded that OpenMP cannot\n                # be used with any (!) compiler named clang, bummer.\n                raise InstallError(\n                    'OpenBLAS @:0.2.19 does not support OpenMP with clang!'\n                )\n\n    @property\n    def make_defs(self):\n        # Configure fails to pick up fortran from FC=/abs/path/to/f77, but\n        # works fine with FC=/abs/path/to/gfortran.\n        # When mixing compilers make sure that\n        # $SPACK_ROOT/lib/spack/env/<compiler> have symlinks with reasonable\n        # names and hack them inside lib/spack/spack/compilers/<compiler>.py\n\n        make_defs = [\n            'CC={0}'.format(spack_cc),\n            'FC={0}'.format(spack_f77),\n            'MAKE_NO_J=1'\n        ]\n\n        if self.spec.variants['virtual_machine'].value:\n            make_defs += [\n                'DYNAMIC_ARCH=1',\n                'NO_AVX2=1'\n            ]\n\n        if self.spec.variants['cpu_target'].value:\n            make_defs += [\n                'TARGET={0}'.format(self.spec.variants['cpu_target'].value)\n            ]\n        # invoke make with the correct TARGET for aarch64\n        elif 'aarch64' in spack.architecture.sys_type():\n            make_defs += [\n                'TARGET=PILEDRIVER',\n                'TARGET=ARMV8'\n            ]\n        if self.spec.satisfies('%gcc@:4.8.4'):\n            make_defs += ['NO_AVX2=1']\n        if '~shared' in self.spec:\n            if '+pic' in self.spec:\n                make_defs.extend([\n                    'CFLAGS={0}'.format(self.compiler.pic_flag),\n                    'FFLAGS={0}'.format(self.compiler.pic_flag)\n                ])\n            make_defs += ['NO_SHARED=1']\n        # fix missing _dggsvd_ and _sggsvd_\n        if self.spec.satisfies('@0.2.16'):\n            make_defs += ['BUILD_LAPACK_DEPRECATED=1']\n\n        # Add support for multithreading\n        if self.spec.satisfies('threads=openmp'):\n            make_defs += ['USE_OPENMP=1', 'USE_THREAD=1']\n        elif self.spec.satisfies('threads=pthreads'):\n            make_defs += ['USE_OPENMP=0', 'USE_THREAD=1']\n        else:\n            make_defs += ['USE_OPENMP=0', 'USE_THREAD=0']\n\n        # 64bit ints\n        if '+ilp64' in self.spec:\n            make_defs += ['INTERFACE64=1']\n\n        return make_defs\n\n    @property\n    def build_targets(self):\n        targets = ['libs', 'netlib']\n\n        # Build shared if variant is set.\n        if '+shared' in self.spec:\n            targets += ['shared']\n\n        return self.make_defs + targets\n\n    @run_after('build')\n    @on_package_attributes(run_tests=True)\n    def check_build(self):\n        make('tests', *self.make_defs)\n\n    @property\n    def install_targets(self):\n        make_args = [\n            'install',\n            'PREFIX={0}'.format(self.prefix),\n        ]\n        return make_args + self.make_defs\n\n    @run_after('install')\n    @on_package_attributes(run_tests=True)\n    def check_install(self):\n        spec = self.spec\n        # Openblas may pass its own test but still fail to compile Lapack\n        # symbols. To make sure we get working Blas and Lapack, do a small\n        # test.\n        source_file = join_path(os.path.dirname(self.module.__file__),\n                                'test_cblas_dgemm.c')\n        blessed_file = join_path(os.path.dirname(self.module.__file__),\n                                 'test_cblas_dgemm.output')\n\n        include_flags = spec['openblas'].headers.cpp_flags\n        link_flags = spec['openblas'].libs.ld_flags\n        if self.compiler.name == 'intel':\n            link_flags += ' -lifcore'\n        if self.spec.satisfies('threads=pthreads'):\n            link_flags += ' -lpthread'\n        if spec.satisfies('threads=openmp'):\n            link_flags += ' -lpthread ' + self.compiler.openmp_flag\n\n        output = compile_c_and_execute(\n            source_file, [include_flags], link_flags.split()\n        )\n        compare_output_file(output, blessed_file)\n", "path": "var/spack/repos/builtin/packages/openblas/package.py"}]}