From c1756257c241334719f0f08a80c6e88eaac180e6 Mon Sep 17 00:00:00 2001 From: Pat McCormick <651611+pmccormick@users.noreply.github.com> Date: Wed, 30 Aug 2023 22:22:33 -0600 Subject: llvm: fix for Flang variant due to exception handling (#36171) * The flang project does not support exceptions enabled in the core llvm library (and developer guidelines explicitly state they should not be used). For this reason, when the flang variant is selected, LLVM_ENABLE_EH needs to be disabled. In the current main branch of llvm (and thus future releases), enabling flang and setting LLVM_ENABLE_EH will cause the overall build to fail. * Update var/spack/repos/builtin/packages/llvm/package.py Co-authored-by: Harmen Stoppels * fix syntax --------- Co-authored-by: Harmen Stoppels Co-authored-by: Satish Balay --- var/spack/repos/builtin/packages/llvm/package.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'var/spack/repos/builtin/packages/llvm/package.py') diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py index 16ab6177f7..a4a89f17bc 100644 --- a/var/spack/repos/builtin/packages/llvm/package.py +++ b/var/spack/repos/builtin/packages/llvm/package.py @@ -756,7 +756,6 @@ class Llvm(CMakePackage, CudaPackage): cmake_args = [ define("LLVM_REQUIRES_RTTI", True), define("LLVM_ENABLE_RTTI", True), - define("LLVM_ENABLE_EH", True), define("LLVM_ENABLE_LIBXML2", False), define("CLANG_DEFAULT_OPENMP_RUNTIME", "libomp"), define("PYTHON_EXECUTABLE", python.command.path), @@ -765,6 +764,16 @@ class Llvm(CMakePackage, CudaPackage): from_variant("LLVM_ENABLE_ZSTD", "zstd"), ] + # Flang does not support exceptions from core llvm. + # LLVM_ENABLE_EH=True when building flang will soon + # fail (with changes at the llvm-project level). + # Only enable exceptions in LLVM if we are *not* + # building flang. FYI: LLVM <= 16.x will build flang + # successfully but the executable will suffer from + # link errors looking for C++ EH support. + if "+flang" not in spec: + cmake_args.append(define("LLVM_ENABLE_EH", True)) + version_suffix = spec.variants["version_suffix"].value if version_suffix != "none": cmake_args.append(define("LLVM_VERSION_SUFFIX", version_suffix)) -- cgit v1.2.3-60-g2f50