summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorMikael Simberg <mikael.simberg@iki.fi>2022-04-20 09:40:03 +0200
committerGitHub <noreply@github.com>2022-04-20 09:40:03 +0200
commit943d463a2d4b604c3eac0ab3c4fb8f9938370ebe (patch)
tree0f699a8ac3f975d798ee575c2d2d0556a344e7d0 /var
parent53eb044b2833dcbb00b4619f20c8183c37905fe2 (diff)
downloadspack-943d463a2d4b604c3eac0ab3c4fb8f9938370ebe.tar.gz
spack-943d463a2d4b604c3eac0ab3c4fb8f9938370ebe.tar.bz2
spack-943d463a2d4b604c3eac0ab3c4fb8f9938370ebe.tar.xz
spack-943d463a2d4b604c3eac0ab3c4fb8f9938370ebe.zip
Configure nvhpc GCC from Spack variables (#29769)
Alter the `install_components/install` script to pass the `-gcc $SPACK_CC`, `-gpp $SPACK_CXX`, and `-g77 $SPACK_F77` flags to `makelocalrc`. This ensures that nvhpc is configured to use the spack gcc spec, rather than whatever gcc is found on the path. Co-authored-by: Mikael Simberg <simberg@cscs.ch> Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/nvhpc/package.py47
1 files changed, 33 insertions, 14 deletions
diff --git a/var/spack/repos/builtin/packages/nvhpc/package.py b/var/spack/repos/builtin/packages/nvhpc/package.py
index 6ae56786c1..44c429817a 100644
--- a/var/spack/repos/builtin/packages/nvhpc/package.py
+++ b/var/spack/repos/builtin/packages/nvhpc/package.py
@@ -5,7 +5,6 @@
#
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
-import os
import platform
from spack import *
@@ -123,22 +122,42 @@ class Nvhpc(Package):
conflicts('%intel')
conflicts('%xl')
- def install(self, spec, prefix):
- # Enable the silent installation feature
- os.environ['NVHPC_SILENT'] = "true"
- os.environ['NVHPC_ACCEPT_EULA'] = "accept"
- os.environ['NVHPC_INSTALL_DIR'] = prefix
-
- if spec.variants['install_type'].value == 'network':
- os.environ['NVHPC_INSTALL_TYPE'] = "network"
- os.environ['NVHPC_INSTALL_LOCAL_DIR'] = \
- "%s/%s/%s/share_objects" % \
- (prefix, 'Linux_%s' % spec.target.family, self.version)
+ def _version_prefix(self):
+ return join_path(
+ self.prefix, 'Linux_%s' % self.spec.target.family, self.version)
+
+ def setup_build_environment(self, env):
+ env.set('NVHPC_SILENT', 'true')
+ env.set('NVHPC_ACCEPT_EULA', 'accept')
+ env.set('NVHPC_INSTALL_DIR', self.prefix)
+
+ if self.spec.variants['install_type'].value == 'network':
+ local_dir = join_path(self._version_prefix(), 'share_objects')
+ env.set('NVHPC_INSTALL_TYPE', 'network')
+ env.set('NVHPC_INSTALL_LOCAL_DIR', local_dir)
else:
- os.environ['NVHPC_INSTALL_TYPE'] = "single"
+ env.set('NVHPC_INSTALL_TYPE', 'single')
+
+ def install(self, spec, prefix):
+ compilers_bin = join_path(self._version_prefix(), 'compilers', 'bin')
+ install = Executable('./install')
+ makelocalrc = Executable(join_path(compilers_bin, 'makelocalrc'))
+
+ makelocalrc_args = [
+ '-gcc', self.compiler.cc,
+ '-gpp', self.compiler.cxx,
+ '-g77', self.compiler.f77,
+ '-x', compilers_bin
+ ]
+ if self.spec.variants['install_type'].value == 'network':
+ local_dir = join_path(self._version_prefix(), 'share_objects')
+ makelocalrc_args.extend(['-net', local_dir])
# Run install script
- os.system("./install")
+ install()
+
+ # Update localrc to use Spack gcc
+ makelocalrc(*makelocalrc_args)
def setup_run_environment(self, env):
prefix = Prefix(join_path(self.prefix,