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 <harmenstoppels@gmail.com>

* fix syntax

---------

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Co-authored-by: Satish Balay <balay@mcs.anl.gov>
This commit is contained in:
Pat McCormick 2023-08-30 22:22:33 -06:00 committed by GitHub
parent 1ee7c735ec
commit c1756257c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -756,7 +756,6 @@ def cmake_args(self):
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 @@ def cmake_args(self):
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))