Skip to content

Commit

Permalink
use source toolchain version when passing only --try-toolchain
Browse files Browse the repository at this point in the history
`process_software_build_specs` ialways adds a `toolchain` key
even when only the name of the toolchain is available.
This makes the code in `tweak` ignore the code path in using
`toolchain_name` and/or `toolchain_version` with the fallback to using
the values of the source toolchain.
This in turn leads to failures further down when a value of `None` is
used where an actual version is expected.

Fix by only adding the `toolchain` key when we have both the name and
version and hence a complete, valid toolchain spec.
  • Loading branch information
Flamefire committed Dec 5, 2023
1 parent ea8433d commit c42c747
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 8 deletions.
6 changes: 4 additions & 2 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,11 +1735,13 @@ def process_software_build_specs(options):
})

# provide both toolchain and toolchain_name/toolchain_version keys
if 'toolchain_name' in build_specs:
try:
build_specs['toolchain'] = {
'name': build_specs['toolchain_name'],
'version': build_specs.get('toolchain_version', None),
'version': build_specs['toolchain_version'],
}
except KeyError:
pass # Don't set toolchain key if we don't have both keys

# process --amend and --try-amend
if options.amend or options.try_amend:
Expand Down
20 changes: 20 additions & 0 deletions test/framework/easyconfigs/test_ecs/i/iimpi/iimpi-2018a.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This is an easyconfig file for EasyBuild, see http://easybuilders.github.io/easybuild
easyblock = 'Toolchain'

name = 'iimpi'
version = '2018a'

homepage = 'https://software.intel.com/parallel-studio-xe'
description = """Intel C/C++ and Fortran compilers, alongside Intel MPI."""

toolchain = SYSTEM

local_compver = '2016.1.150'
local_suff = '-GCC-4.9.3-2.25'
dependencies = [
('icc', local_compver, local_suff),
('ifort', local_compver, local_suff),
('impi', '5.1.2.150', '', ('iccifort', '%s%s' % (local_compver, local_suff))),
]

moduleclass = 'toolchain'
15 changes: 9 additions & 6 deletions test/framework/easyconfigs/test_ecs/i/intel/intel-2018a.eb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ description = """Intel Cluster Toolkit Compiler Edition provides Intel C/C++ and

toolchain = SYSTEM

local_compver = '2016.1.150'
local_gccver = '4.9.3'
local_binutilsver = '2.25'
local_gccsuff = '-GCC-%s-%s' % (local_gccver, local_binutilsver)
# fake intel toolchain easyconfig, no dependencies (good enough for testing)
local_fake_dependencies = [
('GCCcore', '6.4.0'),
('binutils', '2.28', '-GCCcore-6.4.0'),
('icc', '2018.1.163', '-GCCcore-6.4.0'),
('ifort', '2018.1.163', '-GCCcore-6.4.0'),
('impi', '2018.1.163', '', ('iccifort', '2018.1.163-GCCcore-6.4.0')),
('imkl', '2018.1.163', '', ('iimpi', version)),
('GCCcore', local_gccver),
('binutils', local_binutilsver, '-GCCcore-%s' % local_gccver),
('icc', local_compver, local_gccsuff),
('ifort', local_compver, local_gccsuff),
('impi', '5.1.2.150', '', ('iccifort', '%s%s' % (local_compver, local_gccsuff))),
]

moduleclass = 'toolchain'
33 changes: 33 additions & 0 deletions test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-foss-2018a.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name = 'toy'
version = '0.0'

homepage = 'https://easybuilders.github.io/easybuild'
description = "Toy C program, 100% toy."

toolchain = {'name': 'foss', 'version': '2018a'}
toolchainopts = {'pic': True, 'opt': True, 'optarch': True}

sources = [SOURCE_TAR_GZ]
checksums = [[
'be662daa971a640e40be5c804d9d7d10', # default (MD5)
'44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc', # default (SHA256)
('adler32', '0x998410035'),
('crc32', '0x1553842328'),
('md5', 'be662daa971a640e40be5c804d9d7d10'),
('sha1', 'f618096c52244539d0e89867405f573fdb0b55b0'),
('size', 273),
]]
patches = [
'toy-0.0_fix-silly-typo-in-printf-statement.patch',
('toy-extra.txt', 'toy-0.0'),
]

sanity_check_paths = {
'files': [('bin/yot', 'bin/toy')],
'dirs': ['bin'],
}

postinstallcmds = ["echo TOY > %(installdir)s/README"]

moduleclass = 'tools'
# trailing comment, leave this here, it may trigger bugs with extract_comments()
13 changes: 13 additions & 0 deletions test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,19 @@ def test_try(self):
allargs = args + ['--software-version=1.2.3', '--toolchain=gompi,2018a']
self.assertErrorRegex(EasyBuildError, "version .* not available", self.eb_main, allargs, raise_error=True)

# Try changing only name or version of toolchain
args.pop(0) # Remove EC filename
test_cases = [
(['toy-0.0-gompi-2018a.eb', '--try-toolchain-name=intel'], 'toy/0.0-iimpi-2018a'),
(['toy-0.0-foss-2018a.eb', '--try-toolchain-name=intel'], 'toy/0.0-intel-2018a'),
(['toy-0.0-gompi-2018a.eb', '--try-toolchain-version=2018b'], 'toy/0.0-gompi-2018b'),
]
for extra_args, mod in test_cases:
outtxt = self.eb_main(args + extra_args, verbose=True, raise_error=True)
mod_regex = re.compile(r"\(module: %s\)$" % mod, re.M)
self.assertTrue(mod_regex.search(outtxt), "Pattern %s found in %s" % (mod_regex.pattern, outtxt))


def test_try_with_copy(self):
"""Test whether --try options are taken into account."""
ecs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
Expand Down

0 comments on commit c42c747

Please sign in to comment.