diff --git a/easybuild/easyblocks/n/nvhpc.py b/easybuild/easyblocks/n/nvhpc.py index 6efc018a93..e4ad7bf544 100644 --- a/easybuild/easyblocks/n/nvhpc.py +++ b/easybuild/easyblocks/n/nvhpc.py @@ -38,6 +38,7 @@ import re import stat import sys +import tempfile import platform from easybuild.tools import LooseVersion @@ -68,6 +69,14 @@ append LDLIBARGS=-L/usr/lib/x86_64-linux-gnu; """ +# contents for minimal example compiled in sanity check, used to catch issue +# seen in: https://github.com/easybuilders/easybuild-easyblocks/pull/3240 +NVHPC_MINIMAL_EXAMPLE = """ +#include + +int main(){ return 0; } +""" + class EB_NVHPC(PackedBinary): """ @@ -165,7 +174,8 @@ def install_step(self): sys.stdout.write(line) if LooseVersion(self.version) >= LooseVersion('22.9'): - cmd = "%s -x %s" % (makelocalrc_filename, compilers_subdir) + bin_subdir = os.path.join(compilers_subdir, "bin") + cmd = "%s -x %s" % (makelocalrc_filename, bin_subdir) else: cmd = "%s -x %s -g77 /" % (makelocalrc_filename, compilers_subdir) run_cmd(cmd, log_all=True, simple=True) @@ -202,7 +212,18 @@ def sanity_check_step(self): 'dirs': [os.path.join(prefix, 'compilers', 'bin'), os.path.join(prefix, 'compilers', 'lib'), os.path.join(prefix, 'compilers', 'include'), os.path.join(prefix, 'compilers', 'man')] } + custom_commands = ["%s -v" % compiler for compiler in compiler_names] + + if LooseVersion(self.version) >= LooseVersion('21'): + # compile minimal example using -std=c++20 to catch issue where it picks up the wrong GCC + # (as long as system gcc is < 9.0) + # see: https://github.com/easybuilders/easybuild-easyblocks/pull/3240 + tmpdir = tempfile.mkdtemp() + write_file(os.path.join(tmpdir, 'minimal.cpp'), NVHPC_MINIMAL_EXAMPLE) + minimal_compiler_cmd = "cd %s && nvc++ -std=c++20 minimal.cpp -o minimal" % tmpdir + custom_commands.append(minimal_compiler_cmd) + super(EB_NVHPC, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands) def _nvhpc_extended_components(self, dirs, basepath, env_vars_dirs):