Skip to content

Commit

Permalink
Merge pull request easybuilders#4481 from Flamefire/20240308103122_ne…
Browse files Browse the repository at this point in the history
…w_pr_LYxSpINrlD

Improve logging & handling of --optarch
  • Loading branch information
boegel authored Mar 11, 2024
2 parents 035699c + 63acc8f commit 92d2968
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions easybuild/tools/toolchain/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _set_optimal_architecture(self, default_optarch=None):
optarch = build_option('optarch')

# --optarch is specified with flags to use
if optarch is not None and isinstance(optarch, dict):
if isinstance(optarch, dict):
# optarch has been validated as complex string with multiple compilers and converted to a dictionary
# first try module names, then the family in optarch
current_compiler_names = (getattr(self, 'COMPILER_MODULE_NAME', []) +
Expand All @@ -338,14 +338,12 @@ def _set_optimal_architecture(self, default_optarch=None):
self.log.info("_set_optimal_architecture: no optarch found for compiler %s. Ignoring option.",
current_compiler)

use_generic = False
if optarch is not None:
# optarch has been parsed as a simple string
if isinstance(optarch, string_type):
if optarch == OPTARCH_GENERIC:
use_generic = True
else:
raise EasyBuildError("optarch is neither an string or a dict %s. This should never happen", optarch)
if isinstance(optarch, string_type):
use_generic = (optarch == OPTARCH_GENERIC)
elif optarch is None:
use_generic = False
else:
raise EasyBuildError("optarch is neither an string or a dict %s. This should never happen", optarch)

if use_generic:
if (self.arch, self.cpu_family) in (self.COMPILER_GENERIC_OPTION or []):
Expand All @@ -360,10 +358,11 @@ def _set_optimal_architecture(self, default_optarch=None):
optarch = self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[(self.arch, self.cpu_family)]

if optarch is not None:
self.log.info("_set_optimal_architecture: using %s as optarch for %s.", optarch, self.arch)
optarch_log_str = optarch or 'no flags'
self.log.info("_set_optimal_architecture: using %s as optarch for %s/%s.",
optarch_log_str, self.arch, self.cpu_family)
self.options.options_map['optarch'] = optarch

if self.options.options_map.get('optarch', None) is None:
elif self.options.options_map.get('optarch', None) is None:
optarch_flags_str = "%soptarch flags" % ('', 'generic ')[use_generic]
error_msg = "Don't know how to set %s for %s/%s! " % (optarch_flags_str, self.arch, self.cpu_family)
error_msg += "Use --optarch='<flags>' to override (see "
Expand Down

0 comments on commit 92d2968

Please sign in to comment.