Skip to content

Commit b55efbf

Browse files
committed
add pre_single_extension_scipy hook to replace -mcpu=native with -march=armv8.4-a when building scipy 1.10.1 on aarch64/neoverse_v1
1 parent f6ee972 commit b55efbf

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

eb_hooks.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,6 @@ def pre_single_extension_hook(ext, *args, **kwargs):
384384
PRE_SINGLE_EXTENSION_HOOKS[ext.name](ext, *args, **kwargs)
385385

386386

387-
def pre_single_extension_testthat(ext, *args, **kwargs):
388-
"""
389-
Pre-extension hook for testthat R package, to fix build on top of recent glibc.
390-
"""
391-
if ext.name == 'testthat' and LooseVersion(ext.version) < LooseVersion('3.1.0'):
392-
# use constant value instead of SIGSTKSZ for stack size,
393-
# cfr. https://github.com/r-lib/testthat/issues/1373 + https://github.com/r-lib/testthat/pull/1403
394-
ext.cfg['preinstallopts'] = "sed -i 's/SIGSTKSZ/32768/g' inst/include/testthat/vendor/catch.h && "
395-
396-
397387
def pre_single_extension_isoband(ext, *args, **kwargs):
398388
"""
399389
Pre-extension hook for isoband R package, to fix build on top of recent glibc.
@@ -404,6 +394,33 @@ def pre_single_extension_isoband(ext, *args, **kwargs):
404394
ext.cfg['preinstallopts'] = "sed -i 's/SIGSTKSZ/32768/g' src/testthat/vendor/catch.h && "
405395

406396

397+
def pre_single_extension_scipy(ext, *args, **kwargs):
398+
"""
399+
Pre-extension hook for scipy, to change -march=native to -march=armv8.4-a for scipy 1.10.x when buidling for
400+
aarch64/neoverse_v1 CPU target.
401+
"""
402+
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')
403+
if ext.name == 'scipy' and ext.version == '1.10.1' and cpu_target == CPU_TARGET_NEOVERSE_V1:
404+
cflags = os.getenv('CFLAGS')
405+
if '-mcpu=native' in cflags:
406+
cflags = cflags.replace('-mcpu=native', '-march=armv8.4-a')
407+
ext.cfg.update('configopts', ' '.join([
408+
"-Dc_args='%s'" % cflags,
409+
"-Dcpp_args='%s'" % cflags,
410+
"-Dfortran_args='%s'" % cflags,
411+
]))
412+
413+
414+
def pre_single_extension_testthat(ext, *args, **kwargs):
415+
"""
416+
Pre-extension hook for testthat R package, to fix build on top of recent glibc.
417+
"""
418+
if ext.name == 'testthat' and LooseVersion(ext.version) < LooseVersion('3.1.0'):
419+
# use constant value instead of SIGSTKSZ for stack size,
420+
# cfr. https://github.com/r-lib/testthat/issues/1373 + https://github.com/r-lib/testthat/pull/1403
421+
ext.cfg['preinstallopts'] = "sed -i 's/SIGSTKSZ/32768/g' inst/include/testthat/vendor/catch.h && "
422+
423+
407424
def post_sanitycheck_hook(self, *args, **kwargs):
408425
"""Main post-sanity-check hook: trigger custom functions based on software name."""
409426
if self.name in POST_SANITYCHECK_HOOKS:
@@ -531,6 +548,7 @@ def inject_gpu_property(ec):
531548

532549
PRE_SINGLE_EXTENSION_HOOKS = {
533550
'isoband': pre_single_extension_isoband,
551+
'scipy': pre_single_extension_scipy,
534552
'testthat': pre_single_extension_testthat,
535553
}
536554

0 commit comments

Comments
 (0)