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>
This commit is contained in:
Mikael Simberg 2022-04-20 09:40:03 +02:00 committed by GitHub
parent 53eb044b28
commit 943d463a2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,6 @@
# #
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
import os
import platform import platform
from spack import * from spack import *
@ -123,22 +122,42 @@ class Nvhpc(Package):
conflicts('%intel') conflicts('%intel')
conflicts('%xl') conflicts('%xl')
def install(self, spec, prefix): def _version_prefix(self):
# Enable the silent installation feature return join_path(
os.environ['NVHPC_SILENT'] = "true" self.prefix, 'Linux_%s' % self.spec.target.family, self.version)
os.environ['NVHPC_ACCEPT_EULA'] = "accept"
os.environ['NVHPC_INSTALL_DIR'] = prefix
if spec.variants['install_type'].value == 'network': def setup_build_environment(self, env):
os.environ['NVHPC_INSTALL_TYPE'] = "network" env.set('NVHPC_SILENT', 'true')
os.environ['NVHPC_INSTALL_LOCAL_DIR'] = \ env.set('NVHPC_ACCEPT_EULA', 'accept')
"%s/%s/%s/share_objects" % \ env.set('NVHPC_INSTALL_DIR', self.prefix)
(prefix, 'Linux_%s' % spec.target.family, self.version)
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: 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 # Run install script
os.system("./install") install()
# Update localrc to use Spack gcc
makelocalrc(*makelocalrc_args)
def setup_run_environment(self, env): def setup_run_environment(self, env):
prefix = Prefix(join_path(self.prefix, prefix = Prefix(join_path(self.prefix,