From 432c3390b5027fe8baeacb61cf804df1740ec04e Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Mon, 16 Nov 2026 21:41:06 +0100 Subject: [PATCH 1/3] Change or set -DTARGET_CPU to 'rv64gc -mabi=lp64d' for our RISCV generic target for IDG builds. Note that the IDG build system passes this as argument to -march, so we effectively get -march=rv64gc -mabi=lp64d this way. --- eb_hooks.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/eb_hooks.py b/eb_hooks.py index 33e39388..e9f15db3 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -57,6 +57,9 @@ CPU_TARGET_ZEN4 = 'x86_64/amd/zen4' CPU_TARGET_ZEN5 = 'x86_64/amd/zen5' +# RISCV64 targets +CPU_TARGET_RISCV_GENERIC = 'riscv64/generic' + EESSI_RPATH_OVERRIDE_ATTR = 'orig_rpath_override_dirs' EESSI_MODULE_ONLY_ATTR = 'orig_module_only' EESSI_FORCE_ATTR = 'orig_force' @@ -1838,6 +1841,33 @@ def pre_configure_hook_cmake_system(self, *args, **kwargs): raise EasyBuildError("CMake-specific hook triggered for non-CMake easyconfig?!") +def pre_configure_hook_IDG_riscv_target_cpu(self, *args, **kwargs): + """ + pre-configure hook for IDG: + - set TARGET_CPU for the generic RISC-V target, replacing any existing -DTARGET_CPU + """ + if self.name == 'IDG': + cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') + if cpu_target == CPU_TARGET_RISCV_GENERIC: + # the value contains a space, so it has to stay quoted in the shell command + target_cpu_opt = '-DTARGET_CPU="rv64gc -mabi=lp64d"' + + if '-DTARGET_CPU' in self.cfg['configopts']: + # existing value may be double-quoted, single-quoted or unquoted + # We use a non-capturing group (?:) with two ORs (|) to match those three scenarios + # We use a lambda function as replacement so backslashes/quotes aren't interpreted + self.cfg['configopts'] = re.sub( + r"""-DTARGET_CPU=(?:"[^"]*"|'[^']*'|\S*)""", + lambda _: target_cpu_opt, + self.cfg['configopts'], + ) + else: + self.cfg.update('configopts', target_cpu_opt) + print_msg("Using custom configure options for %s: %s", self.name, self.cfg['configopts']) + else: + raise EasyBuildError("IDG-specific hook triggered for non-IDG easyconfig?!") + + def pre_configure_hook_visit(self, *args, **kwargs): """ Pre-configure hook for Visit @@ -2784,6 +2814,7 @@ def post_easyblock_hook(self, *args, **kwargs): 'GObject-Introspection': pre_configure_hook_gobject_introspection, 'Graphviz': pre_configure_hook_graphviz, 'GRASS': pre_configure_hook_grass, + 'IDG': pre_configure_hook_IDG_riscv_target_cpu, 'LAMMPS': pre_configure_hook_LAMMPS_zen4_and_aarch64_cuda, 'libfabric': pre_configure_hook_libfabric_disable_psm3_x86_64_generic, 'LLVM': pre_configure_hook_llvm, From 3c90888c957405994dff80e97afc809dccfee215 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen <33718780+casparvl@users.noreply.github.com> Date: Thu, 19 Nov 2026 11:03:11 +0100 Subject: [PATCH 2/3] Apply suggestion from @casparvl --- eb_hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eb_hooks.py b/eb_hooks.py index e9f15db3..b7566511 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -1850,7 +1850,7 @@ def pre_configure_hook_IDG_riscv_target_cpu(self, *args, **kwargs): cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') if cpu_target == CPU_TARGET_RISCV_GENERIC: # the value contains a space, so it has to stay quoted in the shell command - target_cpu_opt = '-DTARGET_CPU="rv64gc -mabi=lp64d"' + target_cpu_opt = '-DTARGET_CPU=rv64gc' if '-DTARGET_CPU' in self.cfg['configopts']: # existing value may be double-quoted, single-quoted or unquoted From d2dca41960e7e5dd1d407dc9c9fa2164c0b4baa8 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Thu, 19 Nov 2026 11:10:21 +0100 Subject: [PATCH 3/3] Simplify the sub, we can be sure there are no spaces in TARGET_CPU since that would break the builds anyway --- eb_hooks.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/eb_hooks.py b/eb_hooks.py index b7566511..7f4e58a2 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -1849,19 +1849,17 @@ def pre_configure_hook_IDG_riscv_target_cpu(self, *args, **kwargs): if self.name == 'IDG': cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR') if cpu_target == CPU_TARGET_RISCV_GENERIC: - # the value contains a space, so it has to stay quoted in the shell command target_cpu_opt = '-DTARGET_CPU=rv64gc' if '-DTARGET_CPU' in self.cfg['configopts']: - # existing value may be double-quoted, single-quoted or unquoted - # We use a non-capturing group (?:) with two ORs (|) to match those three scenarios - # We use a lambda function as replacement so backslashes/quotes aren't interpreted + # replace the existing value self.cfg['configopts'] = re.sub( - r"""-DTARGET_CPU=(?:"[^"]*"|'[^']*'|\S*)""", - lambda _: target_cpu_opt, + r'-DTARGET_CPU=\S*', + target_cpu_opt, self.cfg['configopts'], ) else: + # -DTARGET_CPU wasn't set before, just append it self.cfg.update('configopts', target_cpu_opt) print_msg("Using custom configure options for %s: %s", self.name, self.cfg['configopts']) else: