Skip to content

Commit 81d2779

Browse files
authored
Merge pull request #97 from bedroge/a64fx_llvm_optarch
add `{pre,post}_prepare_hook` for LLVM to solve A64FX build issue by changing `optarch`
2 parents 38ca6af + c7eb036 commit 81d2779

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

eb_hooks.py

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
HOST_INJECTIONS_LOCATION = "/cvmfs/software.eessi.io/host_injections/"
5151

5252
# Make sure a single environment variable name is used for this throughout the hooks
53-
EESSI_IGNORE_A64FX_RUST1650_ENVVAR="EESSI_IGNORE_LMOD_ERROR_A64FX_RUST1650"
5453
EESSI_IGNORE_ZEN4_GCC1220_ENVVAR="EESSI_IGNORE_LMOD_ERROR_ZEN4_GCC1220"
5554

5655
STACK_REPROD_SUBDIR = 'reprod'
@@ -156,9 +155,6 @@ def parse_hook(ec, *args, **kwargs):
156155
if cpu_target == CPU_TARGET_ZEN4:
157156
parse_hook_zen4_module_only(ec, eprefix)
158157

159-
# All A64FX builds for the 2022b toolchain should use a newer Rust version, as the original one does not work
160-
parse_hook_bump_rust_version_in_2022b_for_a64fx(ec, eprefix)
161-
162158
# inject the GPU property (if required)
163159
ec = inject_gpu_property(ec)
164160

@@ -453,33 +449,6 @@ def parse_hook_openblas_relax_lapack_tests_num_errors(ec, eprefix):
453449
raise EasyBuildError("OpenBLAS-specific hook triggered for non-OpenBLAS easyconfig?!")
454450

455451

456-
def parse_hook_bump_rust_version_in_2022b_for_a64fx(ec, eprefix):
457-
"""
458-
Replace Rust 1.65.0 build dependency by version 1.75.0 for A64FX builds,
459-
because version 1.65.0 has build issues.
460-
"""
461-
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')
462-
463-
if cpu_target == CPU_TARGET_A64FX:
464-
# For Rust 1.65.0 itself we inject an error message in the module file
465-
if ec['name'] == 'Rust' and ec['version'] == '1.65.0':
466-
errmsg = "Rust 1.65.0 is not supported on A64FX. Please use version 1.75.0 instead."
467-
ec['modluafooter'] = 'if (not os.getenv("%s")) then LmodError("%s") end' % (EESSI_IGNORE_A64FX_RUST1650_ENVVAR, errmsg)
468-
469-
# For any builds that have a build dependency on Rust 1.65.0, we bump the version to 1.75.0
470-
if is_gcccore_1220_based(ecname=ec['name'], ecversion=ec['version'],
471-
tcname=ec['toolchain']['name'], tcversion=ec['toolchain']['version']):
472-
473-
build_deps = ec['builddependencies']
474-
rust_name = 'Rust'
475-
rust_original_version = '1.65.0'
476-
rust_new_version = '1.75.0'
477-
for idx, build_dep in enumerate(build_deps):
478-
if build_dep[0] == rust_name and build_dep[1] == rust_original_version:
479-
build_deps[idx] = (rust_name, rust_new_version)
480-
break
481-
482-
483452
def parse_hook_pybind11_replace_catch2(ec, eprefix):
484453
"""
485454
Replace Catch2 build dependency in pybind11 easyconfigs with one that doesn't use system toolchain.
@@ -605,8 +574,6 @@ def is_unsupported_module(ec):
605574
"""
606575
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')
607576

608-
if cpu_target == CPU_TARGET_A64FX and ec.name == 'Rust' and ec.version == '1.65.0':
609-
return EESSI_IGNORE_A64FX_RUST1650_ENVVAR
610577
if cpu_target == CPU_TARGET_ZEN4 and is_gcccore_1220_based(ecname=ec.name, ecversion=ec.version, tcname=ec.toolchain.name, tcversion=ec.toolchain.version):
611578
return EESSI_IGNORE_ZEN4_GCC1220_ENVVAR
612579
return False
@@ -736,6 +703,29 @@ def post_prepare_hook_highway_handle_test_compilation_issues(self, *args, **kwar
736703
update_build_option('optarch', self.orig_optarch)
737704

738705

706+
def pre_prepare_hook_llvm15_a64fx(self, *args, **kwargs):
707+
"""
708+
Solve issues with compiling LLVM 15.0.5 on A64FX by changing the optarch build option.
709+
Rust 1.65.0 also includes LLVM 15, so we do the same for that application.
710+
cfr. https://github.com/EESSI/software-layer/issues/1213
711+
"""
712+
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')
713+
if cpu_target == CPU_TARGET_A64FX:
714+
if (self.name == 'LLVM' and self.version == '15.0.5') or (self.name == 'Rust' and self.version == '1.65.0'):
715+
self.orig_optarch = build_option('optarch')
716+
update_build_option('optarch', 'march=armv8.2-a')
717+
718+
719+
def post_prepare_hook_llvm15_a64fx(self, *args, **kwargs):
720+
"""
721+
Post-prepare hook for LLVM 15 to reset optarch build option.
722+
"""
723+
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')
724+
if cpu_target == CPU_TARGET_A64FX:
725+
if (self.name == 'LLVM' and self.version == '15.0.5') or (self.name == 'Rust' and self.version == '1.65.0'):
726+
update_build_option('optarch', self.orig_optarch)
727+
728+
739729
def pre_configure_hook(self, *args, **kwargs):
740730
"""Main pre-configure hook: trigger custom functions based on software name."""
741731
if self.name in PRE_CONFIGURE_HOOKS:
@@ -1610,11 +1600,15 @@ def post_easyblock_hook(self, *args, **kwargs):
16101600

16111601
PRE_PREPARE_HOOKS = {
16121602
'Highway': pre_prepare_hook_highway_handle_test_compilation_issues,
1603+
'LLVM': pre_prepare_hook_llvm15_a64fx,
1604+
'Rust': pre_prepare_hook_llvm15_a64fx,
16131605
}
16141606

16151607
POST_PREPARE_HOOKS = {
16161608
'GCCcore': post_prepare_hook_gcc_prefixed_ld_rpath_wrapper,
16171609
'Highway': post_prepare_hook_highway_handle_test_compilation_issues,
1610+
'LLVM': post_prepare_hook_llvm15_a64fx,
1611+
'Rust': post_prepare_hook_llvm15_a64fx,
16181612
}
16191613

16201614
PRE_CONFIGURE_HOOKS = {

0 commit comments

Comments
 (0)