diff options
9 files changed, 304 insertions, 268 deletions
diff --git a/lib/spack/spack/test/data/unparse/llvm.txt b/lib/spack/spack/test/data/unparse/llvm.txt index 67557328d9..4a402fb58a 100644 --- a/lib/spack/spack/test/data/unparse/llvm.txt +++ b/lib/spack/spack/test/data/unparse/llvm.txt @@ -1,14 +1,7 @@ -# -*- python -*- -# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -"""This is an unparser test package. - -``llvm`` was chosen because it is one of the most complex packages in Spack and it -exercises nearly all directives. - -""" import os import os.path import re @@ -18,6 +11,7 @@ import llnl.util.tty as tty import spack.build_environment import spack.util.executable +from spack.package import * class Llvm(CMakePackage, CudaPackage): @@ -42,6 +36,14 @@ class Llvm(CMakePackage, CudaPackage): # fmt: off version('main', branch='main') + version('14.0.6', sha256='98f15f842700bdb7220a166c8d2739a03a72e775b67031205078f39dd756a055') + version('14.0.5', sha256='a4a57f029cb81f04618e05853f05fc2d21b64353c760977d8e7799bf7218a23a') + version('14.0.4', sha256='1333236f9bee38658762076be4236cb5ebf15ae9b7f2bfce6946b96ae962dc73') + version('14.0.3', sha256='0e1d049b050127ecf6286107e9a4400b0550f841d5d2288b9d31fd32ed0683d5') + version('14.0.2', sha256='ca52232b3451c8e017f00eb882277707c13e30fac1271ec97015f6d0eeb383d1') + version('14.0.1', sha256='c8be00406e872c8a24f8571cf6f5517b73ae707104724b1fd1db2f0af9544019') + version('14.0.0', sha256='87b1a068b370df5b79a892fdb2935922a8efb1fddec4cc506e30fe57b6a1d9c4') + version('13.0.1', sha256='09c50d558bd975c41157364421820228df66632802a4a6a7c9c17f86a7340802') version('13.0.0', sha256='a1131358f1f9f819df73fa6bff505f2c49d176e9eef0a3aedd1fdbce3b4630e8') version('12.0.1', sha256='66b64aa301244975a4aea489f402f205cde2f53dd722dad9e7b77a0459b4c8df') version('12.0.0', sha256='8e6c99e482bb16a450165176c2d881804976a2d770e0445af4375e78a1fbf19c') @@ -84,7 +86,7 @@ class Llvm(CMakePackage, CudaPackage): ) variant( "flang", - default=False, + default=False, when='@11: +clang', description="Build the LLVM Fortran compiler frontend " "(experimental - parser only, needs GCC)", ) @@ -93,12 +95,12 @@ class Llvm(CMakePackage, CudaPackage): default=False, description="Include debugging code in OpenMP runtime libraries", ) - variant("lldb", default=True, description="Build the LLVM debugger") + variant("lldb", default=True, when='+clang', description="Build the LLVM debugger") variant("lld", default=True, description="Build the LLVM linker") - variant("mlir", default=False, description="Build with MLIR support") + variant("mlir", default=False, when='@10:', description="Build with MLIR support") variant( "internal_unwind", - default=True, + default=True, when='+clang', description="Build the libcxxabi libunwind", ) variant( @@ -109,11 +111,11 @@ class Llvm(CMakePackage, CudaPackage): ) variant( "libcxx", - default=True, + default=True, when='+clang', description="Build the LLVM C++ standard library", ) variant( - "compiler-rt", + "compiler-rt", when='+clang', default=True, description="Build LLVM compiler runtime, including sanitizers", ) @@ -128,27 +130,24 @@ class Llvm(CMakePackage, CudaPackage): description="Build with split dwarf information", ) variant( - "shared_libs", - default=False, - description="Build all components as shared libraries, faster, " - "less memory to build, less stable", - ) - variant( "llvm_dylib", - default=False, - description="Build LLVM shared library, containing all " - "components in a single shared library", + default=True, + description="Build a combined LLVM shared library with all components", ) variant( "link_llvm_dylib", - default=False, + default=False, when='+llvm_dylib', description="Link LLVM tools against the LLVM shared library", ) variant( - "all_targets", - default=False, - description="Build all supported targets, default targets " - "<current arch>,NVPTX,AMDGPU,CppBackend", + "targets", + default="none", + description=("What targets to build. Spack's target family is always added " + "(e.g. X86 is automatically enabled when targeting znver2)."), + values=("all", "none", "aarch64", "amdgpu", "arm", "avr", "bpf", "cppbackend", + "hexagon", "lanai", "mips", "msp430", "nvptx", "powerpc", "riscv", + "sparc", "systemz", "webassembly", "x86", "xcore"), + multi=True ) variant( "build_type", @@ -158,20 +157,45 @@ class Llvm(CMakePackage, CudaPackage): ) variant( "omp_tsan", - default=False, + default=False, when='@6:', description="Build with OpenMP capable thread sanitizer", ) variant( "omp_as_runtime", default=True, + when='+clang @12:', description="Build OpenMP runtime via ENABLE_RUNTIME by just-built Clang", ) variant('code_signing', default=False, + when='+lldb platform=darwin', description="Enable code-signing on macOS") variant("python", default=False, description="Install python bindings") - variant('version_suffix', default='none', description="Add a symbol suffix") - variant('z3', default=False, description='Use Z3 for the clang static analyzer') + variant( + 'shlib_symbol_version', + default='none', + description="Add shared library symbol version", + when='@13:' + ) + variant( + 'z3', + default=False, + when='+clang @8:', + description='Use Z3 for the clang static analyzer' + ) + + provides('libllvm@14', when='@14.0.0:14') + provides('libllvm@13', when='@13.0.0:13') + provides('libllvm@12', when='@12.0.0:12') + provides('libllvm@11', when='@11.0.0:11') + provides('libllvm@10', when='@10.0.0:10') + provides('libllvm@9', when='@9.0.0:9') + provides('libllvm@8', when='@8.0.0:8') + provides('libllvm@7', when='@7.0.0:7') + provides('libllvm@6', when='@6.0.0:6') + provides('libllvm@5', when='@5.0.0:5') + provides('libllvm@4', when='@4.0.0:4') + provides('libllvm@3', when='@3.0.0:3') extends("python", when="+python") @@ -186,7 +210,9 @@ class Llvm(CMakePackage, CudaPackage): # Universal dependency depends_on("python@2.7:2.8", when="@:4+python") depends_on("python", when="@5:+python") - depends_on('z3', when='@8:+clang+z3') + + # clang and clang-tools dependencies + depends_on("z3@4.7.1:", when="+z3") # openmp dependencies depends_on("perl-data-dumper", type=("build")) @@ -194,12 +220,13 @@ class Llvm(CMakePackage, CudaPackage): depends_on("libelf", when="+cuda") # libomptarget depends_on("libffi", when="+cuda") # libomptarget - # ncurses dependency - depends_on("ncurses+termlib") + # llvm-config --system-libs libraries. + depends_on("zlib") # lldb dependencies depends_on("swig", when="+lldb") depends_on("libedit", when="+lldb") + depends_on("ncurses", when="+lldb") depends_on("py-six", when="@5.0.0: +lldb +python") # gold support, required for some features @@ -209,23 +236,13 @@ class Llvm(CMakePackage, CudaPackage): depends_on("gmp", when="@:3.6 +polly") depends_on("isl", when="@:3.6 +polly") - conflicts("+llvm_dylib", when="+shared_libs") - conflicts("+link_llvm_dylib", when="~llvm_dylib") - conflicts("+lldb", when="~clang") - conflicts("+libcxx", when="~clang") - conflicts("+internal_unwind", when="~clang") - conflicts("+compiler-rt", when="~clang") - conflicts("+flang", when="~clang") - # Introduced in version 11 as a part of LLVM and not a separate package. - conflicts("+flang", when="@:10") - - conflicts('~mlir', when='+flang', msg='Flang requires MLIR') - # Older LLVM do not build with newer compilers, and vice versa conflicts("%gcc@8:", when="@:5") conflicts("%gcc@:5.0", when="@8:") # clang/lib: a lambda parameter cannot shadow an explicitly captured entity conflicts("%clang@8:", when="@:4") + # Internal compiler error on gcc 8.4 on aarch64 https://bugzilla.redhat.com/show_bug.cgi?id=1958295 + conflicts('%gcc@8.4:8.4.9', when='@12: target=aarch64:') # When these versions are concretized, but not explicitly with +libcxx, these # conflicts will enable clingo to set ~libcxx, making the build successful: @@ -247,42 +264,19 @@ class Llvm(CMakePackage, CudaPackage): conflicts('%clang@6:', when='@:4+compiler-rt') conflicts('%apple-clang@6:', when='@:4+compiler-rt') - # OMP TSAN exists in > 5.x - conflicts("+omp_tsan", when="@:5") - - # OpenMP via ENABLE_RUNTIME restrictions - conflicts("+omp_as_runtime", when="~clang", msg="omp_as_runtime requires clang being built.") - conflicts("+omp_as_runtime", when="@:11.1", msg="omp_as_runtime works since LLVM 12.") - # cuda_arch value must be specified conflicts("cuda_arch=none", when="+cuda", msg="A value for cuda_arch must be specified.") - # MLIR exists in > 10.x - conflicts("+mlir", when="@:9") - - # code signing is only necessary on macOS", - conflicts('+code_signing', when='platform=linux') - conflicts('+code_signing', when='platform=cray') - - conflicts( - '+code_signing', - when='~lldb platform=darwin', - msg="code signing is only necessary for building the " - "in-tree debug server on macOS. Turning this variant " - "off enables a build of llvm with lldb that uses the " - "system debug server", - ) - # LLVM bug https://bugs.llvm.org/show_bug.cgi?id=48234 # CMake bug: https://gitlab.kitware.com/cmake/cmake/-/issues/21469 # Fixed in upstream versions of both - conflicts('^cmake@3.19.0', when='@6.0.0:11.0.0') + conflicts('^cmake@3.19.0', when='@6:11.0.0') # Github issue #4986 patch("llvm_gcc7.patch", when="@4.0.0:4.0.1+lldb %gcc@7.0:") # sys/ustat.h has been removed in favour of statfs from glibc-2.28. Use fixed sizes: - patch('llvm5-sanitizer-ustat.patch', when="@4:6+compiler-rt") + patch('llvm5-sanitizer-ustat.patch', when="@4:6.0.0+compiler-rt") # Fix lld templates: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230463 patch('llvm4-lld-ELF-Symbols.patch', when="@4+lld%clang@6:") @@ -295,8 +289,8 @@ class Llvm(CMakePackage, CudaPackage): patch('sanitizer-ipc_perm_mode.patch', when="@5:7+compiler-rt%clang@11:") patch('sanitizer-ipc_perm_mode.patch', when="@5:9+compiler-rt%gcc@9:") - # github.com/spack/spack/issues/24270 and MicrosoftDemangle: %gcc@10: and %clang@13: - patch('missing-includes.patch', when='@8:11') + # github.com/spack/spack/issues/24270: MicrosoftDemangle for %gcc@10: and %clang@13: + patch('missing-includes.patch', when='@8') # Backport from llvm master + additional fix # see https://bugs.llvm.org/show_bug.cgi?id=39696 @@ -310,7 +304,7 @@ class Llvm(CMakePackage, CudaPackage): patch("llvm_py37.patch", when="@4:6 ^python@3.7:") # https://bugs.llvm.org/show_bug.cgi?id=39696 - patch("thread-p9.patch", when="@develop+libcxx") + patch("thread-p9.patch", when="@:10 +libcxx") # https://github.com/spack/spack/issues/19625, # merged in llvm-11.0.0_rc2, but not found in 11.0.1 @@ -318,16 +312,31 @@ class Llvm(CMakePackage, CudaPackage): # https://github.com/spack/spack/issues/19908 # merged in llvm main prior to 12.0.0 - patch("llvm_python_path.patch", when="@11.0.0") + patch("llvm_python_path.patch", when="@:11") # Workaround for issue https://github.com/spack/spack/issues/18197 - patch('llvm7_intel.patch', when='@7 %intel@18.0.2,19.0.4') + patch('llvm7_intel.patch', when='@7 %intel@18.0.2,19.0.0:19.1.99') # Remove cyclades support to build against newer kernel headers # https://reviews.llvm.org/D102059 patch('no_cyclades.patch', when='@10:12.0.0') patch('no_cyclades9.patch', when='@6:9') + patch('llvm-gcc11.patch', when='@9:11%gcc@11:') + + # add -lpthread to build OpenMP libraries with Fujitsu compiler + patch('llvm12-thread.patch', when='@12 %fj') + patch('llvm13-thread.patch', when='@13 %fj') + + # avoid build failed with Fujitsu compiler + patch('llvm13-fujitsu.patch', when='@13 %fj') + + # patch for missing hwloc.h include for libompd + patch('llvm14-hwloc-ompd.patch', when='@14') + + # make libflags a list in openmp subproject when ~omp_as_runtime + patch('libomp-libflags-as-list.patch', when='@3.7:') + # The functions and attributes below implement external package # detection for LLVM. See: # @@ -456,6 +465,11 @@ class Llvm(CMakePackage, CudaPackage): result = os.path.join(self.spec.prefix.bin, 'flang') return result + @property + def libs(self): + return LibraryList(self.llvm_config("--libfiles", "all", + result="list")) + @run_before('cmake') def codesign_check(self): if self.spec.satisfies("+code_signing"): @@ -522,6 +536,8 @@ class Llvm(CMakePackage, CudaPackage): define("LLVM_REQUIRES_RTTI", True), define("LLVM_ENABLE_RTTI", True), define("LLVM_ENABLE_EH", True), + define("LLVM_ENABLE_TERMINFO", False), + define("LLVM_ENABLE_LIBXML2", False), define("CLANG_DEFAULT_OPENMP_RUNTIME", "libomp"), define("PYTHON_EXECUTABLE", python.command.path), define("LIBOMP_USE_HWLOC", True), @@ -532,6 +548,11 @@ class Llvm(CMakePackage, CudaPackage): if version_suffix != 'none': cmake_args.append(define('LLVM_VERSION_SUFFIX', version_suffix)) + shlib_symbol_version = spec.variants.get('shlib_symbol_version', None) + if shlib_symbol_version is not None and shlib_symbol_version.value != 'none': + cmake_args.append(define('LLVM_SHLIB_SYMBOL_VERSION', + shlib_symbol_version.value)) + if python.version >= Version("3"): cmake_args.append(define("Python3_EXECUTABLE", python.command.path)) else: @@ -567,11 +588,14 @@ class Llvm(CMakePackage, CudaPackage): cmake_args.append(from_variant("LIBOMPTARGET_ENABLE_DEBUG", "omp_debug")) if "+lldb" in spec: + projects.append("lldb") + cmake_args.append(define('LLDB_ENABLE_LIBEDIT', True)) + cmake_args.append(define('LLDB_ENABLE_NCURSES', True)) + cmake_args.append(define('LLDB_ENABLE_LIBXML2', False)) if spec.version >= Version('10'): cmake_args.append(from_variant("LLDB_ENABLE_PYTHON", 'python')) else: - cmake_args.append(define("LLDB_DISABLE_PYTHON", - '~python' in spec)) + cmake_args.append(define("LLDB_DISABLE_PYTHON", '~python' in spec)) if spec.satisfies("@5.0.0: +python"): cmake_args.append(define("LLDB_USE_SYSTEM_SIX", True)) @@ -588,17 +612,13 @@ class Llvm(CMakePackage, CudaPackage): else: projects.append("openmp") - if self.spec.satisfies("@8"): - cmake_args.append(define('CLANG_ANALYZER_ENABLE_Z3_SOLVER', - self.spec.satisfies('@8+z3'))) - if self.spec.satisfies("@9:"): - cmake_args.append(define('LLVM_ENABLE_Z3_SOLVER', - self.spec.satisfies('@9:+z3'))) + if '@8' in spec: + cmake_args.append(from_variant('CLANG_ANALYZER_ENABLE_Z3_SOLVER', 'z3')) + elif '@9:' in spec: + cmake_args.append(from_variant('LLVM_ENABLE_Z3_SOLVER', 'z3')) if "+flang" in spec: projects.append("flang") - if "+lldb" in spec: - projects.append("lldb") if "+lld" in spec: projects.append("lld") if "+compiler-rt" in spec: @@ -615,7 +635,7 @@ class Llvm(CMakePackage, CudaPackage): cmake_args.append(define("LINK_POLLY_INTO_TOOLS", True)) cmake_args.extend([ - from_variant("BUILD_SHARED_LIBS", "shared_libs"), + define("BUILD_SHARED_LIBS", False), from_variant("LLVM_BUILD_LLVM_DYLIB", "llvm_dylib"), from_variant("LLVM_LINK_LLVM_DYLIB", "link_llvm_dylib"), from_variant("LLVM_USE_SPLIT_DWARF", "split_dwarf"), @@ -625,27 +645,9 @@ class Llvm(CMakePackage, CudaPackage): define('LIBCXX_ENABLE_STATIC_ABI_LIBRARY', True) ]) - if "+all_targets" not in spec: # all is default on cmake - - targets = ["NVPTX", "AMDGPU"] - if spec.version < Version("3.9.0"): - # Starting in 3.9.0 CppBackend is no longer a target (see - # LLVM_ALL_TARGETS in llvm's top-level CMakeLists.txt for - # the complete list of targets) - targets.append("CppBackend") - - if spec.target.family in ("x86", "x86_64"): - targets.append("X86") - elif spec.target.family == "arm": - targets.append("ARM") - elif spec.target.family == "aarch64": - targets.append("AArch64") - elif spec.target.family in ("sparc", "sparc64"): - targets.append("Sparc") - elif spec.target.family in ("ppc64", "ppc64le", "ppc", "ppcle"): - targets.append("PowerPC") - - cmake_args.append(define("LLVM_TARGETS_TO_BUILD", targets)) + cmake_args.append(define( + "LLVM_TARGETS_TO_BUILD", + get_llvm_targets_to_build(spec))) cmake_args.append(from_variant("LIBOMP_TSAN_SUPPORT", "omp_tsan")) @@ -706,10 +708,68 @@ class Llvm(CMakePackage, CudaPackage): ninja() ninja("install") if "+python" in self.spec: - install_tree("llvm/bindings/python", site_packages_dir) + install_tree("llvm/bindings/python", python_platlib) if "+clang" in self.spec: - install_tree("clang/bindings/python", site_packages_dir) + install_tree("clang/bindings/python", python_platlib) with working_dir(self.build_directory): install_tree("bin", join_path(self.prefix, "libexec", "llvm")) + + def llvm_config(self, *args, **kwargs): + lc = Executable(self.prefix.bin.join('llvm-config')) + if not kwargs.get('output'): + kwargs['output'] = str + ret = lc(*args, **kwargs) + if kwargs.get('result') == "list": + return ret.split() + else: + return ret + + +def get_llvm_targets_to_build(spec): + targets = spec.variants['targets'].value + + # Build everything? + if 'all' in targets: + return 'all' + + # Convert targets variant values to CMake LLVM_TARGETS_TO_BUILD array. + spack_to_cmake = { + "aarch64": "AArch64", + "amdgpu": "AMDGPU", + "arm": "ARM", + "avr": "AVR", + "bpf": "BPF", + "cppbackend": "CppBackend", + "hexagon": "Hexagon", + "lanai": "Lanai", + "mips": "Mips", + "msp430": "MSP430", + "nvptx": "NVPTX", + "powerpc": "PowerPC", + "riscv": "RISCV", + "sparc": "Sparc", + "systemz": "SystemZ", + "webassembly": "WebAssembly", + "x86": "X86", + "xcore": "XCore" + } + + if 'none' in targets: + llvm_targets = set() + else: + llvm_targets = set(spack_to_cmake[target] for target in targets) + + if spec.target.family in ("x86", "x86_64"): + llvm_targets.add("X86") + elif spec.target.family == "arm": + llvm_targets.add("ARM") + elif spec.target.family == "aarch64": + llvm_targets.add("AArch64") + elif spec.target.family in ("sparc", "sparc64"): + llvm_targets.add("Sparc") + elif spec.target.family in ("ppc64", "ppc64le", "ppc", "ppcle"): + llvm_targets.add("PowerPC") + + return list(llvm_targets) diff --git a/lib/spack/spack/test/util/package_hash.py b/lib/spack/spack/test/util/package_hash.py index 2d4f00d5dc..f8b1bd5067 100644 --- a/lib/spack/spack/test/util/package_hash.py +++ b/lib/spack/spack/test/util/package_hash.py @@ -340,7 +340,7 @@ def test_remove_complex_package_logic_filtered(): @pytest.mark.parametrize("package_spec,expected_hash", [ ("amdfftw", "tivb752zddjgvfkogfs7cnnvp5olj6co"), ("grads", "rrlmwml3f2frdnqavmro3ias66h5b2ce"), - ("llvm", "g3hoqf4rhprd3da7byp5nzco6tcwliiy"), + ("llvm", "nufffum5dabmaf4l5tpfcblnbfjknvd3"), # has @when("@4.1.0") and raw unicode literals ("mfem", "tiiv7uq7v2xtv24vdij5ptcv76dpazrw"), ("mfem@4.0.0", "tiiv7uq7v2xtv24vdij5ptcv76dpazrw"), diff --git a/var/spack/repos/builtin/packages/llvm-doe/package.py b/var/spack/repos/builtin/packages/llvm-doe/package.py index 58b9e9dd8b..357650cd4d 100644 --- a/var/spack/repos/builtin/packages/llvm-doe/package.py +++ b/var/spack/repos/builtin/packages/llvm-doe/package.py @@ -92,12 +92,6 @@ class LlvmDoe(CMakePackage, CudaPackage): description="Build with split dwarf information", ) variant( - "shared_libs", - default=False, - description="Build all components as shared libraries, faster, " - "less memory to build, less stable", - ) - variant( "llvm_dylib", default=False, description="Build LLVM shared library, containing all " @@ -172,7 +166,6 @@ class LlvmDoe(CMakePackage, CudaPackage): # gold support, required for some features depends_on("binutils+gold+ld+plugins", when="+gold") - conflicts("+llvm_dylib", when="+shared_libs") conflicts("+link_llvm_dylib", when="~llvm_dylib") conflicts("+lldb", when="~clang") conflicts("+libcxx", when="~clang") @@ -539,7 +532,7 @@ class LlvmDoe(CMakePackage, CudaPackage): cmake_args.append(define("LINK_POLLY_INTO_TOOLS", True)) cmake_args.extend([ - from_variant("BUILD_SHARED_LIBS", "shared_libs"), + define('BUILD_SHARED_LIBS', False), from_variant("LLVM_BUILD_LLVM_DYLIB", "llvm_dylib"), from_variant("LLVM_LINK_LLVM_DYLIB", "link_llvm_dylib"), from_variant("LLVM_USE_SPLIT_DWARF", "split_dwarf"), diff --git a/var/spack/repos/builtin/packages/llvm/constexpr_longdouble.patch b/var/spack/repos/builtin/packages/llvm/constexpr_longdouble.patch index f825b14210..8b90001d63 100644 --- a/var/spack/repos/builtin/packages/llvm/constexpr_longdouble.patch +++ b/var/spack/repos/builtin/packages/llvm/constexpr_longdouble.patch @@ -1,14 +1,27 @@ +From 3bf63cf3b366d3a57cf5cbad4112a6abf6c0c3b1 Mon Sep 17 00:00:00 2001 +From: Marshall Clow <mclow.lists@gmail.com> +Date: Tue, 2 Apr 2019 14:46:36 +0000 +Subject: [PATCH] Special case some duration arithmetic for GCC and PPC because + their long double constant folding is broken. Fixes PR#39696. + +llvm-svn: 357478 +--- + libcxx/include/thread | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/libcxx/include/thread b/libcxx/include/thread +index df06ff70f8e37f22f4108be8e5e79a38052a11dd..400459ae7f32c4d7cd24b2d85c49d789500e432d 100644 --- a/libcxx/include/thread +++ b/libcxx/include/thread -@@ -435,7 +435,12 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d) +@@ -434,7 +434,12 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d) using namespace chrono; if (__d > duration<_Rep, _Period>::zero()) { -+#if ! (defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)) ++#if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__) + // GCC's long double const folding is incomplete for IBM128 long doubles. - _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); -+#else + _LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ; ++#else + _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); +#endif nanoseconds __ns; if (__d < _Max) diff --git a/var/spack/repos/builtin/packages/llvm/constexpr_longdouble_9.0.patch b/var/spack/repos/builtin/packages/llvm/constexpr_longdouble_9.0.patch index bbc5ab7385..9a62f27023 100644 --- a/var/spack/repos/builtin/packages/llvm/constexpr_longdouble_9.0.patch +++ b/var/spack/repos/builtin/packages/llvm/constexpr_longdouble_9.0.patch @@ -1,12 +1,38 @@ --- a/libcxx/include/thread +From d9a42ec98adcb1ebc0c3837715df4e5a50c7ccc0 Mon Sep 17 00:00:00 2001 +From: "Joel E. Denny" <jdenny.ornl@gmail.com> +Date: Wed, 10 Jun 2020 12:40:43 -0400 +Subject: [PATCH] [libc++] Work around gcc/Power9 bug in `include/thread` + +This fixes PR39696, which breaks the libcxx build with gcc (I tested +7.5.0) on Power9. This fix was suggested at + +https://bugs.llvm.org/show_bug.cgi?id=39696#c38 + +but never applied. It just reverts 0583d9ea8d5e, which reverses +components of the original fix in 3bf63cf3b366, which is correct. + +Fixes https://llvm.org/PR39696 + +Reviewed By: ldionne + +Differential Revision: https://reviews.llvm.org/D81438 +--- + libcxx/include/thread | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libcxx/include/thread b/libcxx/include/thread +index 22aa4f201295867cff57b7a944e6b7bd67b22ad3..6eff1800acdbef09eae4417eee977fa350c596ea 100644 +--- a/libcxx/include/thread +++ b/libcxx/include/thread -@@ -370,7 +370,7 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d) - using namespace chrono; - if (__d > duration<_Rep, _Period>::zero()) +@@ -365,9 +365,9 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d) { --#if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__) -+#if ! (defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)) + #if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__) // GCC's long double const folding is incomplete for IBM128 long doubles. - _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); - #else - +- _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); +-#else + _LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ; ++#else ++ _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); + #endif + nanoseconds __ns; + if (__d < _Max) diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py index ecff9f8ee3..d0a3f3484f 100644 --- a/var/spack/repos/builtin/packages/llvm/package.py +++ b/var/spack/repos/builtin/packages/llvm/package.py @@ -86,7 +86,7 @@ class Llvm(CMakePackage, CudaPackage): ) variant( "flang", - default=False, + default=False, when='@11: +clang', description="Build the LLVM Fortran compiler frontend " "(experimental - parser only, needs GCC)", ) @@ -95,12 +95,12 @@ class Llvm(CMakePackage, CudaPackage): default=False, description="Include debugging code in OpenMP runtime libraries", ) - variant("lldb", default=True, description="Build the LLVM debugger") + variant("lldb", default=True, when='+clang', description="Build the LLVM debugger") variant("lld", default=True, description="Build the LLVM linker") - variant("mlir", default=False, description="Build with MLIR support") + variant("mlir", default=False, when='@10:', description="Build with MLIR support") variant( "internal_unwind", - default=True, + default=True, when='+clang', description="Build the libcxxabi libunwind", ) variant( @@ -111,11 +111,11 @@ class Llvm(CMakePackage, CudaPackage): ) variant( "libcxx", - default=True, + default=True, when='+clang', description="Build the LLVM C++ standard library", ) variant( - "compiler-rt", + "compiler-rt", when='+clang', default=True, description="Build LLVM compiler runtime, including sanitizers", ) @@ -130,20 +130,13 @@ class Llvm(CMakePackage, CudaPackage): description="Build with split dwarf information", ) variant( - "shared_libs", - default=False, - description="Build all components as shared libraries, faster, " - "less memory to build, less stable", - ) - variant( "llvm_dylib", - default=False, - description="Build LLVM shared library, containing all " - "components in a single shared library", + default=True, + description="Build a combined LLVM shared library with all components", ) variant( "link_llvm_dylib", - default=False, + default=False, when='+llvm_dylib', description="Link LLVM tools against the LLVM shared library", ) variant( @@ -164,7 +157,7 @@ class Llvm(CMakePackage, CudaPackage): ) variant( "omp_tsan", - default=False, + default=False, when='@6:', description="Build with OpenMP capable thread sanitizer", ) variant( @@ -174,12 +167,22 @@ class Llvm(CMakePackage, CudaPackage): description="Build OpenMP runtime via ENABLE_RUNTIME by just-built Clang", ) variant('code_signing', default=False, + when='+lldb platform=darwin', description="Enable code-signing on macOS") variant("python", default=False, description="Install python bindings") - variant('version_suffix', default='none', description="Add a symbol suffix") - variant('shlib_symbol_version', default='none', description="Add shared library symbol version", when='@13:') - variant('z3', default=False, description='Use Z3 for the clang static analyzer') + variant( + 'shlib_symbol_version', + default='none', + description="Add shared library symbol version", + when='@13:' + ) + variant( + 'z3', + default=False, + when='+clang @8:', + description='Use Z3 for the clang static analyzer' + ) provides('libllvm@14', when='@14.0.0:14') provides('libllvm@13', when='@13.0.0:13') @@ -207,7 +210,9 @@ class Llvm(CMakePackage, CudaPackage): # Universal dependency depends_on("python@2.7:2.8", when="@:4+python") depends_on("python", when="@5:+python") - depends_on('z3', when='@8:+clang+z3') + + # clang and clang-tools dependencies + depends_on("z3@4.7.1:", when="+z3") # openmp dependencies depends_on("perl-data-dumper", type=("build")) @@ -216,9 +221,7 @@ class Llvm(CMakePackage, CudaPackage): depends_on("libffi", when="+cuda") # libomptarget # llvm-config --system-libs libraries. - depends_on("ncurses+termlib") depends_on("zlib") - depends_on("libxml2") # lldb dependencies with when("+lldb +python"): @@ -226,6 +229,7 @@ class Llvm(CMakePackage, CudaPackage): depends_on("swig@2:", when="@10:") depends_on("swig@3:", when="@12:") depends_on("libedit", when="+lldb") + depends_on("ncurses", when="+lldb") depends_on("py-six", when="@5.0.0: +lldb +python") # gold support, required for some features @@ -235,18 +239,6 @@ class Llvm(CMakePackage, CudaPackage): depends_on("gmp", when="@:3.6 +polly") depends_on("isl", when="@:3.6 +polly") - conflicts("+llvm_dylib", when="+shared_libs") - conflicts("+link_llvm_dylib", when="~llvm_dylib") - conflicts("+lldb", when="~clang") - conflicts("+libcxx", when="~clang") - conflicts("+internal_unwind", when="~clang") - conflicts("+compiler-rt", when="~clang") - conflicts("+flang", when="~clang") - # Introduced in version 11 as a part of LLVM and not a separate package. - conflicts("+flang", when="@:10") - - conflicts('~mlir', when='+flang', msg='Flang requires MLIR') - # Older LLVM do not build with newer compilers, and vice versa conflicts("%gcc@8:", when="@:5") conflicts("%gcc@:5.0", when="@8:") @@ -275,43 +267,19 @@ class Llvm(CMakePackage, CudaPackage): conflicts('%clang@6:', when='@:4+compiler-rt') conflicts('%apple-clang@6:', when='@:4+compiler-rt') - # OMP TSAN exists in > 5.x - conflicts("+omp_tsan", when="@:5") - # cuda_arch value must be specified conflicts("cuda_arch=none", when="+cuda", msg="A value for cuda_arch must be specified.") - # MLIR exists in > 10.x - conflicts("+mlir", when="@:9") - - # code signing is only necessary on macOS", - conflicts('+code_signing', when='platform=linux') - conflicts('+code_signing', when='platform=cray') - - conflicts( - '+code_signing', - when='~lldb platform=darwin', - msg="code signing is only necessary for building the " - "in-tree debug server on macOS. Turning this variant " - "off enables a build of llvm with lldb that uses the " - "system debug server", - ) - # LLVM bug https://bugs.llvm.org/show_bug.cgi?id=48234 # CMake bug: https://gitlab.kitware.com/cmake/cmake/-/issues/21469 # Fixed in upstream versions of both - conflicts('^cmake@3.19.0', when='@6.0.0:11.0.0') - - # Starting in 3.9.0 CppBackend is no longer a target (see - # LLVM_ALL_TARGETS in llvm's top-level CMakeLists.txt for - # the complete list of targets) - conflicts("targets=cppbackend", when='@3.9.0:') + conflicts('^cmake@3.19.0', when='@6:11.0.0') # Github issue #4986 patch("llvm_gcc7.patch", when="@4.0.0:4.0.1+lldb %gcc@7.0:") # sys/ustat.h has been removed in favour of statfs from glibc-2.28. Use fixed sizes: - patch('llvm5-sanitizer-ustat.patch', when="@4:6+compiler-rt") + patch('llvm5-sanitizer-ustat.patch', when="@4:6.0.0+compiler-rt") # Fix lld templates: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230463 patch('llvm4-lld-ELF-Symbols.patch', when="@4+lld%clang@6:") @@ -327,27 +295,28 @@ class Llvm(CMakePackage, CudaPackage): # github.com/spack/spack/issues/24270: MicrosoftDemangle for %gcc@10: and %clang@13: patch('missing-includes.patch', when='@8') - # Backport from llvm master + additional fix - # see https://bugs.llvm.org/show_bug.cgi?id=39696 - # for a bug report about this problem in llvm master. - patch("constexpr_longdouble.patch", when="@6:8+libcxx") - patch("constexpr_longdouble_9.0.patch", when="@9:10.0.0+libcxx") + # Backport from llvm upstream gcc ppc const expr long double issue + # see https://bugs.llvm.org/show_bug.cgi?id=39696 + # This fix was initially commited (3bf63cf3b366) for the 9.0 release + # but was then broken (0583d9ea8d5e) prior to the 9.0 release and + # eventually unbroken (d9a42ec98adc) for the 11.0 release. The first + # patch backports the original correct fix to previous releases. The + # second patch backports the un-breaking of the original fix. + patch('constexpr_longdouble.patch', when='@6:8+libcxx') + patch('constexpr_longdouble_9.0.patch', when='@9:10+libcxx') # Backport from llvm master; see # https://bugs.llvm.org/show_bug.cgi?id=38233 # for a bug report about this problem in llvm master. patch("llvm_py37.patch", when="@4:6 ^python@3.7:") - # https://bugs.llvm.org/show_bug.cgi?id=39696 - patch("thread-p9.patch", when="@develop+libcxx") - # https://github.com/spack/spack/issues/19625, # merged in llvm-11.0.0_rc2, but not found in 11.0.1 patch("lldb_external_ncurses-10.patch", when="@10.0.0:11.0.1+lldb") # https://github.com/spack/spack/issues/19908 # merged in llvm main prior to 12.0.0 - patch("llvm_python_path.patch", when="@11.0.0") + patch("llvm_python_path.patch", when="@:11") # Workaround for issue https://github.com/spack/spack/issues/18197 patch('llvm7_intel.patch', when='@7 %intel@18.0.2,19.0.0:19.1.99') @@ -576,6 +545,8 @@ class Llvm(CMakePackage, CudaPackage): define("LLVM_REQUIRES_RTTI", True), define("LLVM_ENABLE_RTTI", True), define("LLVM_ENABLE_EH", True), + define("LLVM_ENABLE_TERMINFO", False), + define("LLVM_ENABLE_LIBXML2", False), define("CLANG_DEFAULT_OPENMP_RUNTIME", "libomp"), define("PYTHON_EXECUTABLE", python.command.path), define("LIBOMP_USE_HWLOC", True), @@ -626,11 +597,14 @@ class Llvm(CMakePackage, CudaPackage): cmake_args.append(from_variant("LIBOMPTARGET_ENABLE_DEBUG", "omp_debug")) if "+lldb" in spec: + projects.append("lldb") + cmake_args.append(define('LLDB_ENABLE_LIBEDIT', True)) + cmake_args.append(define('LLDB_ENABLE_NCURSES', True)) + cmake_args.append(define('LLDB_ENABLE_LIBXML2', False)) if spec.version >= Version('10'): cmake_args.append(from_variant("LLDB_ENABLE_PYTHON", 'python')) else: - cmake_args.append(define("LLDB_DISABLE_PYTHON", - '~python' in spec)) + cmake_args.append(define("LLDB_DISABLE_PYTHON", '~python' in spec)) if spec.satisfies("@5.0.0: +python"): cmake_args.append(define("LLDB_USE_SYSTEM_SIX", True)) @@ -647,17 +621,13 @@ class Llvm(CMakePackage, CudaPackage): else: projects.append("openmp") - if self.spec.satisfies("@8"): - cmake_args.append(define('CLANG_ANALYZER_ENABLE_Z3_SOLVER', - self.spec.satisfies('@8+z3'))) - if self.spec.satisfies("@9:"): - cmake_args.append(define('LLVM_ENABLE_Z3_SOLVER', - self.spec.satisfies('@9:+z3'))) + if '@8' in spec: + cmake_args.append(from_variant('CLANG_ANALYZER_ENABLE_Z3_SOLVER', 'z3')) + elif '@9:' in spec: + cmake_args.append(from_variant('LLVM_ENABLE_Z3_SOLVER', 'z3')) if "+flang" in spec: projects.append("flang") - if "+lldb" in spec: - projects.append("lldb") if "+lld" in spec: projects.append("lld") if "+compiler-rt" in spec: @@ -674,7 +644,7 @@ class Llvm(CMakePackage, CudaPackage): cmake_args.append(define("LINK_POLLY_INTO_TOOLS", True)) cmake_args.extend([ - from_variant("BUILD_SHARED_LIBS", "shared_libs"), + define("BUILD_SHARED_LIBS", False), from_variant("LLVM_BUILD_LLVM_DYLIB", "llvm_dylib"), from_variant("LLVM_LINK_LLVM_DYLIB", "link_llvm_dylib"), from_variant("LLVM_USE_SPLIT_DWARF", "split_dwarf"), diff --git a/var/spack/repos/builtin/packages/llvm/thread-p9.patch b/var/spack/repos/builtin/packages/llvm/thread-p9.patch deleted file mode 100644 index 140473a850..0000000000 --- a/var/spack/repos/builtin/packages/llvm/thread-p9.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/libcxx/include/thread b/libcxx/include/thread -index 02da703..d1677a1 100644 ---- a/projects/libcxx/include/thread -+++ b/projects/libcxx/include/thread -@@ -368,9 +368,9 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d) - { - #if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__) - // GCC's long double const folding is incomplete for IBM128 long doubles. -- _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); --#else - _LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ; -+#else -+ _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max(); - #endif - nanoseconds __ns; - if (__d < _Max) diff --git a/var/spack/repos/builtin/packages/mesa/package.py b/var/spack/repos/builtin/packages/mesa/package.py index 4a94189fba..c42bfa9bb6 100644 --- a/var/spack/repos/builtin/packages/mesa/package.py +++ b/var/spack/repos/builtin/packages/mesa/package.py @@ -127,8 +127,7 @@ class Mesa(MesonPackage): patch('mesa_check_llvm_version_suffix.patch', when='@21.2.3:') - # 'auto' needed when shared llvm is built - @when('^llvm~shared_libs') + # Explicitly use the llvm-config tool def patch(self): filter_file( r"_llvm_method = 'auto'", diff --git a/var/spack/repos/builtin/packages/pocl/package.py b/var/spack/repos/builtin/packages/pocl/package.py index 7c4dbae147..7329fc4b10 100644 --- a/var/spack/repos/builtin/packages/pocl/package.py +++ b/var/spack/repos/builtin/packages/pocl/package.py @@ -20,6 +20,9 @@ class Pocl(CMakePackage): git = "https://github.com/pocl/pocl.git" version("master", branch="master") + version('3.0', sha256='5f6bbc391ba144bc7becc3b90888b25468460d5aa6830f63a3b066137e7bfac3') + version('1.8', sha256='0f63377ae1826e16e90038fc8e7f65029be4ff6f9b059f6907174b5c0d1f8ab2') + version('1.7', sha256='5f6bbc391ba144bc7becc3b90888b25468460d5aa6830f63a3b066137e7bfac3') version('1.6', sha256='b0a4c0c056371b6f0db726b88fbb76bbee94948fb2abd4dbc8d958f7c42f766c') version('1.5', sha256='4fcf4618171727d165fc044d465a66e3119217bb4577a97374f94fcd8aed330e') version('1.4', sha256='ec237faa83bb1c803fbdf7c6e83d8a2ad68b6f0ed1879c3aa16c0e1dcc478742') @@ -27,23 +30,15 @@ class Pocl(CMakePackage): version('1.2', sha256='0c43e68f336892f3a64cba19beb99d9212f529bedb77f7879c0331450b982d46') version('1.1', sha256='1e8dd0693a88c84937754df947b202871a40545b1b0a97ebefa370b0281c3c53') version('1.0', sha256='94bd86a2f9847c03e6c3bf8dca12af3734f8b272ffeacbc3fa8fcca58844b1d4') - version('0.14', sha256='2127bf925a91fbbe3daf2f1bac0da5c8aceb16e2a9434977a3057eade974106a') - version('0.13', sha256='a17f37d8f26819c0c8efc6de2b57f67a0c8a81514fc9cd5005434e49d67499f9') - version('0.12', sha256='5160d7a59721e6a7d0fc85868381c0afceaa7c07b9956c9be1e3b51e80c29f76') - version('0.11', sha256='24bb801fb87d104b66faaa95d1890776fdeabb37ad1b12fb977281737c7f29bb') - version('0.10', sha256='e9c38f774a77e61f66d850b705a5ba42d49356c40e75733db4c4811e091e5088') conflicts('@:1.5', when='target=a64fx', msg='a64fx is supported by pocl v1.6 and above.') - # This is Github's pocl/pocl#373 - patch("uint.patch", when="@:0.13") - patch("vecmathlib.patch", when="@:0.13") - - # Note: We should describe correctly which pocl versions provide - # which version of the OpenCL standard - # OpenCL standard versions are: 1.0, 1.1, 1.2, 2.0, 2.1, 2.2 - provides('opencl@:2.0') + # < 3.0 provided full OpenCL 1.2 support and some intermediate level of + # OpenCL 2.0 support. >= 3.0 provides full OpenCL 3.0 support when using + # llvm >= 14. + provides('opencl@2.0', when='^llvm@:13') + provides('opencl@3.0', when='@3: ^llvm@14:') depends_on("cmake @2.8.12:", type="build") depends_on("hwloc") @@ -51,23 +46,18 @@ class Pocl(CMakePackage): depends_on("libtool", type=("build", "link", "run")) depends_on("pkgconfig", type="build") - # We don't request LLVM's shared libraries because these are not - # enabled by default, and also because they fail to build for us - # (see #1616) - # These are the supported LLVM versions - depends_on("llvm +clang @6.0:11.0", when="@master") - depends_on("llvm +clang +shared_libs -flang @6.0:11.0", when="@1.6") - depends_on("llvm +clang @6.0:10.0", when="@1.5") - depends_on("llvm +clang @6.0:9.0", when="@1.4") - depends_on("llvm +clang @5.0:8.0", when="@1.3") - depends_on("llvm +clang @5.0:7.0", when="@1.2") - depends_on("llvm +clang @5.0:6.0", when="@1.1") - depends_on("llvm +clang @4.0:5.0", when="@1.0") - depends_on("llvm +clang @3.7:4.0", when="@0.14") - depends_on("llvm +clang @3.7:3.8", when="@0.13") - depends_on("llvm +clang @3.2:3.7", when="@0.12") - depends_on("llvm +clang @3.2:3.6", when="@0.11") - depends_on("llvm +clang @3.2:3.5", when="@0.10") + depends_on('llvm +clang') + depends_on("llvm @14:15", when="@master") + depends_on("llvm @13:14", when="@3.0") + depends_on("llvm @12:13", when="@1.8") + depends_on("llvm @11:12", when="@1.7") + depends_on("llvm @10:11", when="@1.6") + depends_on("llvm @9:10", when="@1.5") + depends_on("llvm @8:9", when="@1.4") + depends_on("llvm @7:8", when="@1.3") + depends_on("llvm @6:7", when="@1.2") + depends_on("llvm @5:6", when="@1.1") + depends_on("llvm @4:5", when="@1.0") variant("distro", default=False, description=("Support several CPU architectures, " @@ -87,13 +77,14 @@ class Pocl(CMakePackage): return url.format(version.up_to(2)) def cmake_args(self): - spec = self.spec - args = ["-DINSTALL_OPENCL_HEADERS=ON"] - if "~shared" in spec["llvm"]: - args += ["-DSTATIC_LLVM"] - if "+distro" in spec: - args += ["-DKERNELLIB_HOST_CPU_VARIANTS=distro"] - args += ["-DENABLE_ICD=%s" % ("ON" if "+icd" in spec else "OFF")] + args = [ + self.define("INSTALL_OPENCL_HEADERS", True), + self.define("ENABLE_LLVM", True), + self.define("STATIC_LLVM", True), + self.define_from_variant("ENABLE_ICD", "icd"), + ] + if "+distro" in self.spec: + args.append(self.define("KERNELLIB_HOST_CPU_VARIANTS", "distro")) return args @run_after('install') |