cmake build system: change default build type to Release (#36679)

This switches the default Make build type to `build_type=Release`.

This offers:
- higher optimization level, including loop vectorization on older GCC
- adds NDEBUG define, which disables assertions, which could cause speedups if assertions are in loops etc
- no `-g` means smaller install size

Downsides are:
- worse backtraces (though this does NOT strip symbols)
- perf reports may be useless
- no function arguments / local variables in debugger (could be of course)
- no file path / line numbers in debugger

The downsides can be mitigated by overriding to `build_type=RelWithDebInfo` in `packages.yaml`,
if needed.  The upside is that builds will be MUCH smaller (and faster) with this change.

---------

Co-authored-by: Gregory Becker <becker33@llnl.gov>
This commit is contained in:
Massimiliano Culpo
2023-05-04 17:33:35 +02:00
committed by GitHub
parent 600955edd4
commit 86d3bad1e0
26 changed files with 5 additions and 175 deletions

View File

@@ -90,9 +90,13 @@ class CMakePackage(spack.package_base.PackageBase):
with when("build_system=cmake"):
# https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
# See https://github.com/spack/spack/pull/36679 and related issues for a
# discussion of the trade-offs between Release and RelWithDebInfo for default
# builds. Release is chosen to maximize performance and reduce disk-space burden,
# at the cost of more difficulty in debugging.
variant(
"build_type",
default="RelWithDebInfo",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)

View File

@@ -37,14 +37,6 @@ class Adios2(CMakePackage, CudaPackage):
version("2.4.0", sha256="50ecea04b1e41c88835b4b3fd4e7bf0a0a2a3129855c9cc4ba6cf6a1575106e2")
version("2.3.1", sha256="3bf81ccc20a7f2715935349336a76ba4c8402355e1dc3848fcd6f4c3c5931893")
# General build options
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
# There's not really any consistency about how static and shared libs are
# implemented across spack. What we're trying to support is specifically three
# library build types:

View File

@@ -25,13 +25,6 @@ class Ccls(CMakePackage):
"0.20201025", sha256="1470797b2c1a466e2d8a069efd807aac6fefdef8a556e1edf2d44f370c949221"
)
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
depends_on("cmake@3.8:", type="build")
depends_on("llvm@7:")
depends_on("rapidjson")

View File

@@ -28,13 +28,6 @@ class Compadre(CMakePackage):
depends_on("kokkos-kernels@3.3.01:3.6")
depends_on("cmake@3.13:", type="build")
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("mpi", default=False, description="Enable MPI support")
depends_on("mpi", when="+mpi")

View File

@@ -24,14 +24,6 @@ class Embree(CMakePackage):
version("3.8.0", sha256="40cbc90640f63c318e109365d29aea00003e4bd14aaba8bb654fc1010ea5753a")
version("3.7.0", sha256="2b6300ebe30bb3d2c6e5f23112b4e21a25a384a49c5e3c35440aa6f3c8d9fe84")
# default to Release, as RelWithDebInfo creates a lot of overhead
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("ispc", default=True, description="Enable ISPC support")
depends_on("ispc", when="+ispc", type="build")

View File

@@ -30,13 +30,6 @@ class Enzyme(CMakePackage):
version("0.0.14", sha256="740641eeeeadaf47942ac88cc52e62ddc0e8c25767a501bed36ec241cf258b8d")
version("0.0.13", sha256="d4a53964ec1f763772db2c56e6734269b7656c8b2ecd41fa7a41315bcd896b5a")
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
depends_on("llvm@7:12", when="@0.0.13:0.0.15")
depends_on("llvm@7:14", when="@0.0.32:") # TODO actual lower bound
depends_on("llvm@7:14", when="@0.0.48:")

View File

@@ -21,13 +21,6 @@ class Fftx(CMakePackage, CudaPackage, ROCmPackage):
version("main", branch="main")
version("1.0.3", sha256="b5ff275facce4a2fbabd0aecc65dd55b744794f2e07cd8cfa91363001c664896")
variant(
"build_type",
default="Release",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
description="The build type to build",
)
depends_on("spiral-software")
depends_on("spiral-package-fftx")
depends_on("spiral-package-simt")

View File

@@ -52,12 +52,6 @@ class GpiSpace(CMakePackage):
description="GPI-2 fabric to enable",
when="+iml",
)
variant(
"build_type",
default="Release",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
description="CMake build type",
)
depends_on("cmake@3.15.0:", type="build")
depends_on("chrpath@0.13:", type=("build", "run"))

View File

@@ -44,12 +44,6 @@ class Helics(CMakePackage):
version("2.4.2", sha256="957856f06ed6d622f05dfe53df7768bba8fe2336d841252f5fac8345070fa5cb")
version("2.4.1", sha256="ac077e9efe466881ea366721cb31fb37ea0e72a881a717323ba4f3cdda338be4")
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("apps", default=True, description="Install the HELICS apps executables")
variant("apps_lib", default=True, description="Install the HELICS apps library")
variant("benchmarks", default=False, description="Install the HELICS benchmarks")

View File

@@ -21,13 +21,6 @@ class Keepassxc(CMakePackage):
version("2.6.6", sha256="3603b11ac39b289c47fac77fa150e05fd64b393d8cfdf5732dc3ef106650a4e2")
version("2.6.4", sha256="e536e2a71c90fcf264eb831fb1a8b518ee1b03829828f862eeea748d3310f82b")
variant(
"build_type",
default="Release",
description="The build type for the installation (only Debug or"
" ( Documentation indicates Release).",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("autotype", default=False, description="enable auto-type")
variant("docs", default=True, description="Build documentation")

View File

@@ -20,13 +20,6 @@ class Libristra(CMakePackage):
version("master", branch="master", submodules=False, preferred=True)
version("1.0.0", commit="33235fe0334ca7f1f99b386a90932d9f8e1e71de")
variant(
"build_type",
default="Release",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
description="The build type to build",
multi=False,
)
variant("paraview", default=False, description="Enable ParaView")
variant("shared_lua", default=False, description="Build with shared lua")

View File

@@ -89,12 +89,6 @@ class LlvmDoe(CMakePackage, CudaPackage):
description="Build all supported targets, default targets "
"<current arch>,NVPTX,AMDGPU,CppBackend",
)
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("omp_tsan", default=False, description="Build with OpenMP capable thread sanitizer")
variant(
"omp_as_runtime",

View File

@@ -34,13 +34,6 @@ class LlvmOpenmpOmpt(CMakePackage):
"libomptarget", default=True, description="Enable building libomptarget for offloading"
)
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
depends_on("cmake@2.8:", type="build")
depends_on("llvm", when="~standalone")
depends_on("ninja@1.5:", type="build")

View File

@@ -161,12 +161,6 @@ class Llvm(CMakePackage, CudaPackage):
),
multi=True,
)
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant(
"omp_tsan",
default=False,

View File

@@ -13,13 +13,6 @@ class ScalapackBase(CMakePackage):
of the library in the 'amdscalapack' package.
"""
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("shared", default=True, description="Build the shared library version")
variant("pic", default=False, description="Build position independent code")

View File

@@ -28,14 +28,6 @@ class Omnitrace(CMakePackage):
version("1.3.0", commit="4dd144a32c8b83c44e132ef53f2b44fe4b4d5569", submodules=True)
version("1.2.0", commit="f82845388aab108ed1d1fc404f433a0def391bb3", submodules=True)
# override build_type to default to Release because this has a significant
# impact on build-time and the size of the build
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant(
"rocm",
default=True,

View File

@@ -30,13 +30,6 @@ class Opencarp(CMakePackage):
variant("carputils", default=False, description="Installs the carputils framework")
variant("meshtool", default=False, description="Installs the meshtool software")
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
# Patch removing problematic steps in CMake process
patch("opencarp7.patch", when="@7.0")

View File

@@ -54,12 +54,6 @@ class PyPennylaneLightningKokkos(CMakePackage, PythonExtension, CudaPackage, ROC
# build options
extends("python")
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("cpptests", default=False, description="Build CPP tests")
variant("native", default=False, description="Build natively for given hardware")
variant("sanitize", default=False, description="Build with address sanitization")

View File

@@ -39,13 +39,6 @@ class PyPennylaneLightning(CMakePackage, PythonExtension):
variant("cpptests", default=False, description="Build CPP tests")
variant("cppbenchmarks", default=False, description="Build CPP benchmark examples")
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
extends("python")
# hard dependencies

View File

@@ -44,12 +44,6 @@ class Sleef(CMakePackage):
# See https://github.com/shibatch/sleef/issues/234
# See https://github.com/pytorch/pytorch/issues/26892
# See https://github.com/pytorch/pytorch/pull/26993
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
generator("ninja")
depends_on("cmake@3.4.3:", type="build")

View File

@@ -53,12 +53,6 @@ class Sollve(CMakePackage):
description="Build all supported targets, default targets "
"<current arch>,NVPTX,AMDGPU,CppBackend",
)
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("omp_tsan", default=False, description="Build with OpenMP capable thread sanitizer")
variant("python", default=False, description="Install python bindings")
variant("argobots", default=True, description="Use Argobots in BOLT")

View File

@@ -24,13 +24,6 @@ class SpiralSoftware(CMakePackage):
version("8.2.1", sha256="78d7bb1c22a5b2d216eac7b6ddedd20b601ba40227e64f743cbb54d4e5a7794d")
version("8.2.0", sha256="983f38d270ae2cb753c88cbce3f412e307c773807ad381acedeb9275afc0be32")
variant(
"build_type",
default="Release",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
description="Build the Release version by default",
)
extendable = True
# No dependencies.

View File

@@ -81,15 +81,6 @@ class Templight(CMakePackage):
)
patch("develop-20180720.patch", when="@2018.07.20")
# Clang debug builds can be _huge_ (20+ GB), make sure you know what you
# are doing before switching to them
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
# NOTE: LLVM has many configurable tweaks and optional tools/extensions.
# I did not think that propagating all of these to a debugging and
# performance analysis tool was worth the maintenance burden. But

View File

@@ -50,14 +50,6 @@ class VtkM(CMakePackage, CudaPackage, ROCmPackage):
version("1.2.0", sha256="607272992e05f8398d196f0acdcb4af025a4a96cd4f66614c6341f31d4561763")
version("1.1.0", sha256="78618c81ca741b1fbba0853cb5d7af12c51973b514c268fc96dfb36b853cdb18")
# use release, instead of release with debug symbols b/c vtkm libs
# can overwhelm compilers with too many symbols
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("shared", default=False, description="build shared libs")
variant("doubleprecision", default=True, description="enable double precision")

View File

@@ -37,13 +37,6 @@ class Winbison(CMakePackage):
build_directory = "spack-build"
cmake_dir = os.path.join(build_directory, "CMakeBuild")
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
@classmethod
def determine_version(cls, exe):
output = Executable(exe)("--version", output=str, error=str)

View File

@@ -35,13 +35,6 @@ class Xyce(CMakePackage):
depends_on("flex")
depends_on("bison")
variant(
"build_type",
default="Release",
description="CMake build type",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
)
variant("mpi", default=True, description="Enable MPI support")
depends_on("mpi", when="+mpi")