Skip to content

Commit 339a71e

Browse files
authored
Merge pull request EESSI#793 from boegel/2023.06-software.eessi.io_rebuild_OpenBLAS_aarch64-generic
use `TARGET=ARMV8` when building OpenBLAS for `aarch64/generic`
2 parents d53bf54 + 188938a commit 339a71e

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 2024.10.17
2+
# TARGET=ARMV8 must be used when building OpenBLAS for aarch64/generic,
3+
# since otherwise "Illegal instruction" errors may happen in the driver part of OpenBLAS
4+
# on systems that only support a minimal instruction set like Arm v8 (like Raspberry Pi SBCs);
5+
# see also https://github.com/OpenMathLib/OpenBLAS/issues/4945
6+
easyconfigs:
7+
- OpenBLAS-0.3.21-GCC-12.2.0.eb:
8+
options:
9+
# see https://github.com/easybuilders/easybuild-easyblocks/pull/3492
10+
include-easyblocks-from-commit: d06d9617d9bfb63d338b6879eab9da81c8a312d8
11+
- OpenBLAS-0.3.23-GCC-12.3.0.eb:
12+
options:
13+
# see https://github.com/easybuilders/easybuild-easyblocks/pull/3492
14+
include-easyblocks-from-commit: d06d9617d9bfb63d338b6879eab9da81c8a312d8
15+
- OpenBLAS-0.3.24-GCC-13.2.0.eb:
16+
options:
17+
# see https://github.com/easybuilders/easybuild-easyblocks/pull/3492
18+
include-easyblocks-from-commit: d06d9617d9bfb63d338b6879eab9da81c8a312d8

eb_hooks.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,17 +486,33 @@ def pre_configure_hook_openblas_optarch_generic(self, *args, **kwargs):
486486
"""
487487
Pre-configure hook for OpenBLAS: add DYNAMIC_ARCH=1 to build/test/install options when using --optarch=GENERIC
488488
"""
489+
# note: OpenBLAS easyblock was updated in https://github.com/easybuilders/easybuild-easyblocks/pull/3492
490+
# to take care of this already, so at some point this hook can be removed...
489491
if self.name == 'OpenBLAS':
490492
if build_option('optarch') == OPTARCH_GENERIC:
493+
dynamic_arch = 'DYNAMIC_ARCH=1'
491494
for step in ('build', 'test', 'install'):
492-
self.cfg.update(f'{step}opts', "DYNAMIC_ARCH=1")
495+
if dynamic_arch not in self.cfg[f'{step}opts']:
496+
self.cfg.update(f'{step}opts', dynamic_arch)
493497

494-
# use -mtune=generic rather than -mcpu=generic in $CFLAGS on aarch64,
495-
# because -mcpu=generic implies a particular -march=armv* which clashes with those used by OpenBLAS
496-
# when building with DYNAMIC_ARCH=1
497498
if get_cpu_architecture() == AARCH64:
498-
cflags = os.getenv('CFLAGS').replace('-mcpu=generic', '-mtune=generic')
499-
env.setvar('CFLAGS', cflags)
499+
# when building for aarch64/generic, we also need to set TARGET=ARMV8 to make sure
500+
# that the driver parts of OpenBLAS are compiled generically;
501+
# see also https://github.com/OpenMathLib/OpenBLAS/issues/4945
502+
target_armv8 = 'TARGET=ARMV8'
503+
for step in ('build', 'test', 'install'):
504+
if target_armv8 not in self.cfg[f'{step}opts']:
505+
self.cfg.update(f'{step}opts', target_armv8)
506+
507+
# use -mtune=generic rather than -mcpu=generic in $CFLAGS for aarch64/generic,
508+
# because -mcpu=generic implies a particular -march=armv* which clashes with those used by OpenBLAS
509+
# when building with DYNAMIC_ARCH=1
510+
mcpu_generic = '-mcpu=generic'
511+
cflags = os.getenv('CFLAGS')
512+
if mcpu_generic in cflags:
513+
cflags = cflags.replace(mcpu_generic, '-mtune=generic')
514+
self.log.info("Replaced -mcpu=generic with -mtune=generic in $CFLAGS")
515+
env.setvar('CFLAGS', cflags)
500516
else:
501517
raise EasyBuildError("OpenBLAS-specific hook triggered for non-OpenBLAS easyconfig?!")
502518

0 commit comments

Comments
 (0)