update compiler config with bootstrapped compiler when already installed (#16221)

Update compiler config with bootstrapped compiler when it was already installed and added config defaults to code so mutable_config test fixture works.
This commit is contained in:
Greg Becker 2020-04-22 14:26:29 -07:00 committed by GitHub
parent 46e90692e8
commit ec23e4ffe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 4 deletions

View File

@ -415,7 +415,7 @@ def _set_variables_for_single_module(pkg, module):
if getattr(module, marker, False):
return
jobs = spack.config.get('config:build_jobs') if pkg.parallel else 1
jobs = spack.config.get('config:build_jobs', 16) if pkg.parallel else 1
jobs = min(jobs, multiprocessing.cpu_count())
assert jobs is not None, "no default set for config:build_jobs"

View File

@ -111,7 +111,7 @@ def __call__(self, parser, namespace, jobs, option_string):
def default(self):
# This default is coded as a property so that look-up
# of this value is done only on demand
return min(spack.config.get('config:build_jobs'),
return min(spack.config.get('config:build_jobs', 16),
multiprocessing.cpu_count())
@default.setter

View File

@ -336,7 +336,7 @@ def _fetch_from_url(self, url):
else:
curl_args.append('-sS') # just errors when not.
connect_timeout = spack.config.get('config:connect_timeout')
connect_timeout = spack.config.get('config:connect_timeout', 10)
if self.extra_options:
cookie = self.extra_options.get('cookie')

View File

@ -1466,6 +1466,12 @@ def install(self, **kwargs):
if lock is not None:
self._update_installed(task)
_print_installed_pkg(pkg.prefix)
# It's an already installed compiler, add it to the config
if task.compiler:
spack.compilers.add_compilers_to_config(
spack.compilers.find_compilers([pkg.spec.prefix]))
else:
# At this point we've failed to get a write or a read
# lock, which means another process has taken a write

View File

@ -15,11 +15,12 @@
import llnl.util.filesystem as fs
import spack.config
import spack.compilers as compilers
import spack.hash_types as ht
import spack.package
import spack.cmd.install
from spack.error import SpackError
from spack.spec import Spec
from spack.spec import Spec, CompilerSpec
from spack.main import SpackCommand
import spack.environment as ev
@ -718,3 +719,30 @@ def test_cdash_auth_token(tmpdir, install_mockery, capfd):
'--log-format=cdash',
'a')
assert 'Using CDash auth token from environment' in out
def test_compiler_bootstrap(
install_mockery, mock_packages, mock_fetch, mock_archive,
mutable_config, monkeypatch):
monkeypatch.setattr(spack.concretize.Concretizer,
'check_for_compiler_existence', False)
spack.config.set('config:install_missing_compilers', True)
assert CompilerSpec('gcc@2.0') not in compilers.all_compiler_specs()
# Test succeeds if it does not raise an error
install('a%gcc@2.0')
@pytest.mark.regression('16221')
def test_compiler_bootstrap_already_installed(
install_mockery, mock_packages, mock_fetch, mock_archive,
mutable_config, monkeypatch):
monkeypatch.setattr(spack.concretize.Concretizer,
'check_for_compiler_existence', False)
spack.config.set('config:install_missing_compilers', True)
assert CompilerSpec('gcc@2.0') not in compilers.all_compiler_specs()
# Test succeeds if it does not raise an error
install('gcc@2.0')
install('a%gcc@2.0')

View File

@ -0,0 +1,23 @@
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class Gcc(Package):
"""Simple compiler package."""
homepage = "http://www.example.com"
url = "http://www.example.com/gcc-1.0.tar.gz"
version('1.0', '0123456789abcdef0123456789abcdef')
version('2.0', '2.0_a_hash')
def install(self, spec, prefix):
# Create the minimal compiler that will fool `spack compiler find`
mkdirp(prefix.bin)
with open(prefix.bin.gcc, 'w') as f:
f.write('#!/bin/bash\necho "%s"' % str(spec.version))
set_executable(prefix.bin.gcc)