Skip to content

Commit 026503e

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 026503e

1 file changed

Lines changed: 29 additions & 10 deletions

File tree

eb_hooks.py

Lines changed: 29 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,34 @@ 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+
comp_args = ','.join(cflags.split(' '))
408+
ext.cfg.update('configopts', ' '.join([
409+
"-Dc_args='%s'" % comp_args,
410+
"-Dcpp_args='%s'" % comp_args,
411+
"-Dfortran_args='%s'" % comp_args,
412+
]))
413+
414+
415+
def pre_single_extension_testthat(ext, *args, **kwargs):
416+
"""
417+
Pre-extension hook for testthat R package, to fix build on top of recent glibc.
418+
"""
419+
if ext.name == 'testthat' and LooseVersion(ext.version) < LooseVersion('3.1.0'):
420+
# use constant value instead of SIGSTKSZ for stack size,
421+
# cfr. https://github.com/r-lib/testthat/issues/1373 + https://github.com/r-lib/testthat/pull/1403
422+
ext.cfg['preinstallopts'] = "sed -i 's/SIGSTKSZ/32768/g' inst/include/testthat/vendor/catch.h && "
423+
424+
407425
def post_sanitycheck_hook(self, *args, **kwargs):
408426
"""Main post-sanity-check hook: trigger custom functions based on software name."""
409427
if self.name in POST_SANITYCHECK_HOOKS:
@@ -531,6 +549,7 @@ def inject_gpu_property(ec):
531549

532550
PRE_SINGLE_EXTENSION_HOOKS = {
533551
'isoband': pre_single_extension_isoband,
552+
'scipy': pre_single_extension_scipy,
534553
'testthat': pre_single_extension_testthat,
535554
}
536555

0 commit comments

Comments
 (0)