Bugfix/install missing compiler from buildcache (#17536)

Ensure compilers installed from buildcache are registered.
This commit is contained in:
Scott Wittenburg 2020-07-17 12:13:36 -06:00 committed by Gregory Becker
parent 27af499b52
commit 9cbe358f84
2 changed files with 40 additions and 0 deletions

View file

@ -1057,6 +1057,9 @@ def _install_task(self, task, **kwargs):
if use_cache and \ if use_cache and \
_install_from_cache(pkg, cache_only, explicit, unsigned): _install_from_cache(pkg, cache_only, explicit, unsigned):
self._update_installed(task) self._update_installed(task)
if task.compiler:
spack.compilers.add_compilers_to_config(
spack.compilers.find_compilers([pkg.spec.prefix]))
return return
pkg.run_tests = (tests is True or tests and pkg.name in tests) pkg.run_tests = (tests is True or tests and pkg.name in tests)

View file

@ -29,6 +29,9 @@
install = SpackCommand('install') install = SpackCommand('install')
env = SpackCommand('env') env = SpackCommand('env')
add = SpackCommand('add') add = SpackCommand('add')
mirror = SpackCommand('mirror')
uninstall = SpackCommand('uninstall')
buildcache = SpackCommand('buildcache')
@pytest.fixture() @pytest.fixture()
@ -733,6 +736,40 @@ def test_compiler_bootstrap(
install('a%gcc@2.0') install('a%gcc@2.0')
def test_compiler_bootstrap_from_binary_mirror(
install_mockery_mutable_config, mock_packages, mock_fetch,
mock_archive, mutable_config, monkeypatch, tmpdir):
"""Make sure installing compiler from buildcache registers compiler"""
# Create a temp mirror directory for buildcache usage
mirror_dir = tmpdir.join('mirror_dir')
mirror_url = 'file://{0}'.format(mirror_dir.strpath)
# Install a compiler, because we want to put it in a buildcache
install('gcc@2.0')
# Put installed compiler in the buildcache
buildcache('create', '-u', '-a', '-f', '-d', mirror_dir.strpath, 'gcc@2.0')
# Now uninstall the compiler
uninstall('-y', 'gcc@2.0')
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()
# Configure the mirror where we put that buildcache w/ the compiler
mirror('add', 'test-mirror', mirror_url)
# Now make sure that when the compiler is installed from binary mirror,
# it also gets configured as a compiler. Test succeeds if it does not
# raise an error
install('--no-check-signature', '--cache-only', '--only',
'dependencies', 'b%gcc@2.0')
install('--no-cache', '--only', 'package', 'b%gcc@2.0')
@pytest.mark.regression('16221') @pytest.mark.regression('16221')
def test_compiler_bootstrap_already_installed( def test_compiler_bootstrap_already_installed(
install_mockery_mutable_config, mock_packages, mock_fetch, install_mockery_mutable_config, mock_packages, mock_fetch,