axom conduit mfem build fixes (#17121)
* honor global compiler flags * Honor debug variant when using global compiler flags * Add cppflags to c/cxx flags, clarify flag handling
This commit is contained in:
parent
03880f5413
commit
506f31b7a7
3 changed files with 91 additions and 18 deletions
|
@ -65,10 +65,10 @@ class Axom(CMakePackage, CudaPackage):
|
|||
# -----------------------------------------------------------------------
|
||||
# Variants
|
||||
# -----------------------------------------------------------------------
|
||||
variant('debug', default=False,
|
||||
variant('debug', default=False,
|
||||
description='Build debug instead of optimized version')
|
||||
|
||||
variant('fortran', default=True, description="Build with Fortran support")
|
||||
variant('fortran', default=True, description="Build with Fortran support")
|
||||
|
||||
variant("python", default=False, description="Build python support")
|
||||
|
||||
|
@ -77,16 +77,16 @@ class Axom(CMakePackage, CudaPackage):
|
|||
|
||||
variant("mfem", default=False, description="Build with mfem")
|
||||
variant("hdf5", default=True, description="Build with hdf5")
|
||||
variant("lua", default=False, description="Build with Lua")
|
||||
variant("lua", default=True, description="Build with Lua")
|
||||
variant("scr", default=False, description="Build with SCR")
|
||||
variant("umpire", default=True, description="Build with umpire")
|
||||
|
||||
variant("raja", default=True, description="Build with raja")
|
||||
variant("cub", default=True,
|
||||
variant("cub", default=True,
|
||||
description="Build with RAJA's internal CUB support")
|
||||
|
||||
varmsg = "Build development tools (such as Sphinx, Uncrustify, etc...)"
|
||||
variant("devtools", default=False, description=varmsg)
|
||||
variant("devtools", default=False, description=varmsg)
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Dependencies
|
||||
|
@ -124,7 +124,7 @@ class Axom(CMakePackage, CudaPackage):
|
|||
depends_on('umpire cuda_arch={0}'.format(sm_),
|
||||
when='+umpire cuda_arch={0}'.format(sm_))
|
||||
|
||||
depends_on("mfem~mpi~hypre~metis~gzstream", when="+mfem")
|
||||
depends_on("mfem~mpi~hypre~metis~zlib", when="+mfem")
|
||||
|
||||
depends_on("python", when="+python")
|
||||
|
||||
|
@ -137,6 +137,12 @@ class Axom(CMakePackage, CudaPackage):
|
|||
depends_on("py-shroud", when="+devtools")
|
||||
depends_on("uncrustify@0.61", when="+devtools")
|
||||
|
||||
def flag_handler(self, name, flags):
|
||||
if name in ('cflags', 'cxxflags', 'fflags'):
|
||||
# the package manages these flags in another way
|
||||
return (None, None, None)
|
||||
return (flags, None, None)
|
||||
|
||||
def _get_sys_type(self, spec):
|
||||
sys_type = spec.architecture
|
||||
# if on llnl systems, we can use the SYS_TYPE
|
||||
|
@ -210,6 +216,33 @@ def hostconfig(self, spec, prefix):
|
|||
else:
|
||||
cfg.write(cmake_cache_option("ENABLE_FORTRAN", False))
|
||||
|
||||
# use global spack compiler flags
|
||||
cppflags = ' '.join(spec.compiler_flags['cppflags'])
|
||||
if cppflags:
|
||||
# avoid always ending up with ' ' with no flags defined
|
||||
cppflags += ' '
|
||||
cflags = cppflags + ' '.join(spec.compiler_flags['cflags'])
|
||||
if cflags:
|
||||
cfg.write(cmake_cache_entry("CMAKE_C_FLAGS", cflags))
|
||||
cxxflags = cppflags + ' '.join(spec.compiler_flags['cxxflags'])
|
||||
if cxxflags:
|
||||
cfg.write(cmake_cache_entry("CMAKE_CXX_FLAGS", cxxflags))
|
||||
fflags = ' '.join(spec.compiler_flags['fflags'])
|
||||
if fflags:
|
||||
cfg.write(cmake_cache_entry("CMAKE_Fortran_FLAGS", fflags))
|
||||
|
||||
if ("gfortran" in f_compiler) and ("clang" in cpp_compiler):
|
||||
libdir = pjoin(os.path.dirname(
|
||||
os.path.dirname(cpp_compiler)), "lib")
|
||||
flags = ""
|
||||
for _libpath in [libdir, libdir + "64"]:
|
||||
if os.path.exists(_libpath):
|
||||
flags += " -Wl,-rpath,{0}".format(_libpath)
|
||||
description = ("Adds a missing libstdc++ rpath")
|
||||
if flags:
|
||||
cfg.write(cmake_cache_entry("BLT_EXE_LINKER_FLAGS", flags,
|
||||
description))
|
||||
|
||||
# TPL locations
|
||||
cfg.write("#------------------{0}\n".format("-" * 60))
|
||||
cfg.write("# TPLs\n")
|
||||
|
@ -433,9 +466,9 @@ def hostconfig(self, spec, prefix):
|
|||
os.path.dirname(f_compiler)), "lib")
|
||||
description = ("Adds a missing rpath for libraries "
|
||||
"associated with the fortran compiler")
|
||||
linker_flags = "${BLT_EXE_LINKER_FLAGS} -Wl,-rpath," + libdir
|
||||
cfg.write(cmake_cache_entry("BLT_EXE_LINKER_FLAGS",
|
||||
"-Wl,-rpath," + libdir,
|
||||
description))
|
||||
linker_flags, description))
|
||||
|
||||
if "+cuda" in spec:
|
||||
cfg.write("#------------------{0}\n".format("-" * 60))
|
||||
|
@ -485,15 +518,6 @@ def hostconfig(self, spec, prefix):
|
|||
cfg.write("# nvcc does not like gtest's 'pthreads' flag\n")
|
||||
cfg.write(cmake_cache_option("gtest_disable_pthreads", True))
|
||||
|
||||
if ("gfortran" in f_compiler) and ("clang" in cpp_compiler):
|
||||
clanglibdir = pjoin(os.path.dirname(
|
||||
os.path.dirname(cpp_compiler)), "lib")
|
||||
flags = "-Wl,-rpath,{0}".format(clanglibdir)
|
||||
description = ("Adds a missing rpath for libraries "
|
||||
"associated with the fortran compiler")
|
||||
cfg.write(cmake_cache_entry("BLT_EXE_LINKER_FLAGS", flags,
|
||||
description))
|
||||
|
||||
cfg.write("\n")
|
||||
cfg.close()
|
||||
tty.info("Spack generated Axom host-config file: " + host_config_path)
|
||||
|
|
|
@ -147,6 +147,12 @@ class Conduit(Package):
|
|||
# build phases used by this package
|
||||
phases = ["configure", "build", "install"]
|
||||
|
||||
def flag_handler(self, name, flags):
|
||||
if name in ('cflags', 'cxxflags', 'fflags'):
|
||||
# the package manages these flags in another way
|
||||
return (None, None, None)
|
||||
return (flags, None, None)
|
||||
|
||||
def setup_build_environment(self, env):
|
||||
env.set('CTEST_OUTPUT_ON_FAILURE', '1')
|
||||
|
||||
|
@ -350,6 +356,33 @@ def create_host_config(self, spec, prefix, py_site_pkgs_dir=None):
|
|||
else:
|
||||
cfg.write(cmake_cache_entry("BUILD_SHARED_LIBS", "OFF"))
|
||||
|
||||
# use global spack compiler flags
|
||||
cppflags = ' '.join(spec.compiler_flags['cppflags'])
|
||||
if cppflags:
|
||||
# avoid always ending up with ' ' with no flags defined
|
||||
cppflags += ' '
|
||||
cflags = cppflags + ' '.join(spec.compiler_flags['cflags'])
|
||||
if cflags:
|
||||
cfg.write(cmake_cache_entry("CMAKE_C_FLAGS", cflags))
|
||||
cxxflags = cppflags + ' '.join(spec.compiler_flags['cxxflags'])
|
||||
if cxxflags:
|
||||
cfg.write(cmake_cache_entry("CMAKE_CXX_FLAGS", cxxflags))
|
||||
fflags = ' '.join(spec.compiler_flags['fflags'])
|
||||
if fflags:
|
||||
cfg.write(cmake_cache_entry("CMAKE_Fortran_FLAGS", fflags))
|
||||
|
||||
if ("gfortran" in f_compiler) and ("clang" in cpp_compiler):
|
||||
libdir = os.path.join(os.path.dirname(
|
||||
os.path.dirname(f_compiler)), "lib")
|
||||
flags = ""
|
||||
for _libpath in [libdir, libdir + "64"]:
|
||||
if os.path.exists(_libpath):
|
||||
flags += " -Wl,-rpath,{0}".format(_libpath)
|
||||
description = ("Adds a missing libstdc++ rpath")
|
||||
if flags:
|
||||
cfg.write(cmake_cache_entry("BLT_EXE_LINKER_FLAGS", flags,
|
||||
description))
|
||||
|
||||
#######################
|
||||
# Unit Tests
|
||||
#######################
|
||||
|
@ -380,7 +413,8 @@ def create_host_config(self, spec, prefix, py_site_pkgs_dir=None):
|
|||
# Grab lib directory for the current fortran compiler
|
||||
libdir = os.path.join(os.path.dirname(
|
||||
os.path.dirname(f_compiler)), "lib")
|
||||
flags = "-lstdc++ -Wl,-rpath," + libdir
|
||||
flags = "${BLT_EXE_LINKER_FLAGS} -lstdc++ "
|
||||
flags += "-Wl,-rpath,{0} -Wl,-rpath,{0}64".format(libdir)
|
||||
cfg.write(cmake_cache_entry("BLT_EXE_LINKER_FLAGS",
|
||||
flags))
|
||||
|
||||
|
|
|
@ -366,6 +366,21 @@ def find_optional_library(name, prefix):
|
|||
cxxflags = spec.compiler_flags['cxxflags']
|
||||
|
||||
if cxxflags:
|
||||
# Add opt/debug flags if they are not present in global cxx flags
|
||||
opt_flag_found = any(f in self.compiler.opt_flags
|
||||
for f in cxxflags)
|
||||
debug_flag_found = any(f in self.compiler.debug_flags
|
||||
for f in cxxflags)
|
||||
|
||||
if '+debug' in spec:
|
||||
if not debug_flag_found:
|
||||
cxxflags.append('-g')
|
||||
if not opt_flag_found:
|
||||
cxxflags.append('-O0')
|
||||
else:
|
||||
if not opt_flag_found:
|
||||
cxxflags.append('-O2')
|
||||
|
||||
cxxflags = [(xcompiler + flag) for flag in cxxflags]
|
||||
if '+cuda' in spec:
|
||||
cxxflags += [
|
||||
|
|
Loading…
Reference in a new issue