conduit package: Honor compiler extra_rpaths + extras (#46046)
- Honor compiler extra_rpaths (this build bypasses spack wrappers, so the RPATHs are added explicitly as CMake options) - Use root_cmakelists_dir instead of adding it to the command line - Add BLT as a dependency, allowing different versions outside of what is in the tarball - Put a copy of host-config in the stage directory: this allows examination of the host-config when a build fails (before, the host-config was just stored in the install directory, which is deleted by default on a failed build)
This commit is contained in:
parent
cade66d842
commit
3589edcc6d
@ -14,7 +14,7 @@
|
|||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
def cmake_cache_entry(name, value, vtype=None):
|
def cmake_cache_entry(name, value, vtype=None, force=False):
|
||||||
"""
|
"""
|
||||||
Helper that creates CMake cache entry strings used in
|
Helper that creates CMake cache entry strings used in
|
||||||
'host-config' files.
|
'host-config' files.
|
||||||
@ -24,7 +24,8 @@ def cmake_cache_entry(name, value, vtype=None):
|
|||||||
vtype = "BOOL"
|
vtype = "BOOL"
|
||||||
else:
|
else:
|
||||||
vtype = "PATH"
|
vtype = "PATH"
|
||||||
return 'set({0} "{1}" CACHE {2} "")\n\n'.format(name, value, vtype)
|
force_str = " FORCE" if force else ""
|
||||||
|
return 'set({0} "{1}" CACHE {2} ""{3})\n\n'.format(name, value, vtype, force_str)
|
||||||
|
|
||||||
|
|
||||||
class Conduit(CMakePackage):
|
class Conduit(CMakePackage):
|
||||||
@ -76,6 +77,8 @@ class Conduit(CMakePackage):
|
|||||||
|
|
||||||
maintainers("cyrush")
|
maintainers("cyrush")
|
||||||
|
|
||||||
|
root_cmakelists_dir = "src"
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# package variants
|
# package variants
|
||||||
###########################################################################
|
###########################################################################
|
||||||
@ -121,6 +124,12 @@ class Conduit(CMakePackage):
|
|||||||
# package dependencies
|
# package dependencies
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# BLT
|
||||||
|
#######################
|
||||||
|
depends_on("blt", type="build")
|
||||||
|
depends_on("blt@0.6.2:", type="build", when="@0.9:")
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# CMake
|
# CMake
|
||||||
#######################
|
#######################
|
||||||
@ -245,7 +254,7 @@ def url_for_version(self, version):
|
|||||||
def cmake_args(self):
|
def cmake_args(self):
|
||||||
host_config = self._get_host_config_path(self.spec)
|
host_config = self._get_host_config_path(self.spec)
|
||||||
options = []
|
options = []
|
||||||
options.extend(["-C", host_config, "../spack-src/src/"])
|
options.extend(["-C", host_config])
|
||||||
return options
|
return options
|
||||||
|
|
||||||
@run_after("build")
|
@run_after("build")
|
||||||
@ -255,6 +264,13 @@ def build_test(self):
|
|||||||
print("Running Conduit Unit Tests...")
|
print("Running Conduit Unit Tests...")
|
||||||
make("test")
|
make("test")
|
||||||
|
|
||||||
|
# Copy the generated host-config to install directory for downstream use
|
||||||
|
@run_before("install")
|
||||||
|
def copy_host_config(self):
|
||||||
|
src = self._get_host_config_path(self.spec)
|
||||||
|
dst = join_path(self.spec.prefix, os.path.basename(src))
|
||||||
|
copy(src, dst)
|
||||||
|
|
||||||
@run_after("install")
|
@run_after("install")
|
||||||
@on_package_attributes(run_tests=True)
|
@on_package_attributes(run_tests=True)
|
||||||
def check_install(self):
|
def check_install(self):
|
||||||
@ -291,7 +307,8 @@ def _get_host_config_path(self, spec):
|
|||||||
host_config_path = "{0}-{1}-{2}-conduit-{3}.cmake".format(
|
host_config_path = "{0}-{1}-{2}-conduit-{3}.cmake".format(
|
||||||
socket.gethostname(), sys_type, spec.compiler, spec.dag_hash()
|
socket.gethostname(), sys_type, spec.compiler, spec.dag_hash()
|
||||||
)
|
)
|
||||||
dest_dir = spec.prefix
|
|
||||||
|
dest_dir = self.stage.source_path
|
||||||
host_config_path = os.path.abspath(join_path(dest_dir, host_config_path))
|
host_config_path = os.path.abspath(join_path(dest_dir, host_config_path))
|
||||||
return host_config_path
|
return host_config_path
|
||||||
|
|
||||||
@ -392,15 +409,31 @@ def hostconfig(self):
|
|||||||
if fflags:
|
if fflags:
|
||||||
cfg.write(cmake_cache_entry("CMAKE_Fortran_FLAGS", fflags))
|
cfg.write(cmake_cache_entry("CMAKE_Fortran_FLAGS", fflags))
|
||||||
|
|
||||||
|
# Add various rpath linker flags
|
||||||
|
rpaths = []
|
||||||
|
if self.compiler.extra_rpaths:
|
||||||
|
rpaths += self.compiler.extra_rpaths
|
||||||
|
|
||||||
|
# Note: This is not needed if we add `extra_rpaths` to this compiler spec case
|
||||||
if (f_compiler is not None) and ("gfortran" in f_compiler) and ("clang" in cpp_compiler):
|
if (f_compiler is not None) and ("gfortran" in f_compiler) and ("clang" in cpp_compiler):
|
||||||
libdir = os.path.join(os.path.dirname(os.path.dirname(f_compiler)), "lib")
|
libdir = os.path.join(os.path.dirname(os.path.dirname(f_compiler)), "lib")
|
||||||
flags = ""
|
|
||||||
for _libpath in [libdir, libdir + "64"]:
|
for _libpath in [libdir, libdir + "64"]:
|
||||||
if os.path.exists(_libpath):
|
if os.path.exists(_libpath):
|
||||||
flags += " -Wl,-rpath,{0}".format(_libpath)
|
rpaths.append(_libpath)
|
||||||
description = "Adds a missing libstdc++ rpath"
|
|
||||||
if flags:
|
linkerflags = ""
|
||||||
cfg.write(cmake_cache_entry("BLT_EXE_LINKER_FLAGS", flags, description))
|
for rpath in rpaths:
|
||||||
|
linkerflags += "-Wl,-rpath,{} ".format(rpath)
|
||||||
|
cfg.write(cmake_cache_entry("CMAKE_EXE_LINKER_FLAGS", linkerflags))
|
||||||
|
if spec.satisfies("+shared"):
|
||||||
|
cfg.write(cmake_cache_entry("CMAKE_SHARED_LINKER_FLAGS", linkerflags))
|
||||||
|
else:
|
||||||
|
cfg.write(cmake_cache_entry("CMAKE_STATIC_LINKER_FLAGS", linkerflags))
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# BLT
|
||||||
|
#######################
|
||||||
|
cfg.write(cmake_cache_entry("BLT_SOURCE_DIR", spec["blt"].prefix))
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Examples/Utilities
|
# Examples/Utilities
|
||||||
@ -436,7 +469,7 @@ def hostconfig(self):
|
|||||||
cfg.write(cmake_cache_entry("BLT_EXE_LINKER_FLAGS", flags))
|
cfg.write(cmake_cache_entry("BLT_EXE_LINKER_FLAGS", flags))
|
||||||
if spec.satisfies("+shared"):
|
if spec.satisfies("+shared"):
|
||||||
flags = "${CMAKE_SHARED_LINKER_FLAGS} " + rpaths
|
flags = "${CMAKE_SHARED_LINKER_FLAGS} " + rpaths
|
||||||
cfg.write(cmake_cache_entry("CMAKE_SHARED_LINKER_FLAGS", flags))
|
cfg.write(cmake_cache_entry("CMAKE_SHARED_LINKER_FLAGS", flags, force=True))
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Python
|
# Python
|
||||||
|
Loading…
Reference in New Issue
Block a user