summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris White <white238@llnl.gov>2020-06-17 10:43:47 -0700
committerGitHub <noreply@github.com>2020-06-17 12:43:47 -0500
commit506f31b7a7fa1ebabdb4ce5d1764b0a197e62989 (patch)
tree2aaf14f3dd04952a107bd7487520c39cbbe6ff83
parent03880f54139ff97e144833378842034c0f2d2a3b (diff)
downloadspack-506f31b7a7fa1ebabdb4ce5d1764b0a197e62989.tar.gz
spack-506f31b7a7fa1ebabdb4ce5d1764b0a197e62989.tar.bz2
spack-506f31b7a7fa1ebabdb4ce5d1764b0a197e62989.tar.xz
spack-506f31b7a7fa1ebabdb4ce5d1764b0a197e62989.zip
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
-rw-r--r--var/spack/repos/builtin/packages/axom/package.py58
-rw-r--r--var/spack/repos/builtin/packages/conduit/package.py36
-rw-r--r--var/spack/repos/builtin/packages/mfem/package.py15
3 files changed, 91 insertions, 18 deletions
diff --git a/var/spack/repos/builtin/packages/axom/package.py b/var/spack/repos/builtin/packages/axom/package.py
index 46b411b4e7..2eb3ae226c 100644
--- a/var/spack/repos/builtin/packages/axom/package.py
+++ b/var/spack/repos/builtin/packages/axom/package.py
@@ -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 @@ class Axom(CMakePackage, CudaPackage):
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 @@ class Axom(CMakePackage, CudaPackage):
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 @@ class Axom(CMakePackage, CudaPackage):
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)
diff --git a/var/spack/repos/builtin/packages/conduit/package.py b/var/spack/repos/builtin/packages/conduit/package.py
index 2e6ec09409..9928884e92 100644
--- a/var/spack/repos/builtin/packages/conduit/package.py
+++ b/var/spack/repos/builtin/packages/conduit/package.py
@@ -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 @@ class Conduit(Package):
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 @@ class Conduit(Package):
# 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))
diff --git a/var/spack/repos/builtin/packages/mfem/package.py b/var/spack/repos/builtin/packages/mfem/package.py
index 5f6d8b5c0a..3a4abab49b 100644
--- a/var/spack/repos/builtin/packages/mfem/package.py
+++ b/var/spack/repos/builtin/packages/mfem/package.py
@@ -366,6 +366,21 @@ class Mfem(Package):
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 += [