Skip to content

Commit 1f3c98b

Browse files
committed
compile minimal example in sanity check
1 parent 7e30e28 commit 1f3c98b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

easybuild/easyblocks/n/nvhpc.py

+23
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
import os
3737
import fileinput
3838
import re
39+
import shutil
3940
import stat
4041
import sys
42+
import tempfile
4143
import platform
4244

4345
from easybuild.tools import LooseVersion
@@ -68,6 +70,14 @@
6870
append LDLIBARGS=-L/usr/lib/x86_64-linux-gnu;
6971
"""
7072

73+
# contents for minimal example compiled in sanity check, used to catch issue
74+
# seen in: https://github.com/easybuilders/easybuild-easyblocks/pull/3240
75+
NVHPC_MINIMAL_EXAMPLE = """
76+
#include <ranges>
77+
78+
int main(){ return 0; }
79+
"""
80+
7181

7282
class EB_NVHPC(PackedBinary):
7383
"""
@@ -206,6 +216,19 @@ def sanity_check_step(self):
206216
custom_commands = ["%s -v" % compiler for compiler in compiler_names]
207217
super(EB_NVHPC, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)
208218

219+
# compile minimal example using -std=c++20 to catch issue where it picks up the wrong GCC
220+
# (as long as system gcc is < 9.0)
221+
# see: https://github.com/easybuilders/easybuild-easyblocks/pull/3240
222+
tmpdir = tempfile.mkdtemp()
223+
write_file(os.path.join(tmpdir, 'minimal.cpp'), NVHPC_MINIMAL_EXAMPLE)
224+
os.chdir(tmpdir)
225+
cmd = "nvc++ -std=c++20 minimal.cpp -o minimal"
226+
run_cmd(cmd, log_all=True, simple=True)
227+
try:
228+
shutil.rmtree(tmpdir)
229+
except OSError as err:
230+
raise EasyBuildError("Failed to remove temporary sanity check directory %s: %s", tmpdir, err)
231+
209232
def _nvhpc_extended_components(self, dirs, basepath, env_vars_dirs):
210233
"""
211234
Extends `dirs` dict of key:environment_variables, value:list_of_directories with additional vars and dirs.

0 commit comments

Comments
 (0)