From dfc95cdf1c07ad7cde2becc14db5692cd8d7f0dc Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 24 Nov 2021 01:28:17 +0100 Subject: llvm: use ninja by default (#27521) * llvm: use ninja by default * Use ninja for omp when it's not a runtime --- var/spack/repos/builtin/packages/llvm/package.py | 28 +++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py index cbfddc13e9..36c3984dc1 100644 --- a/var/spack/repos/builtin/packages/llvm/package.py +++ b/var/spack/repos/builtin/packages/llvm/package.py @@ -8,6 +8,7 @@ import sys import llnl.util.tty as tty +import spack.build_environment import spack.util.executable @@ -27,6 +28,8 @@ class Llvm(CMakePackage, CudaPackage): tags = ['e4s'] + generator = 'Ninja' + family = "compiler" # Used by lmod # fmt: off @@ -165,6 +168,7 @@ class Llvm(CMakePackage, CudaPackage): # Build dependency depends_on("cmake@3.4.3:", type="build") + depends_on("ninja", type="build") depends_on("python@2.7:2.8", when="@:4 ~python", type="build") depends_on("python", when="@5: ~python", type="build") depends_on("pkgconfig", type="build") @@ -626,27 +630,31 @@ class Llvm(CMakePackage, CudaPackage): define = CMakePackage.define # unnecessary if we build openmp via LLVM_ENABLE_RUNTIMES - if "+cuda" in self.spec and "+omp_as_runtime" not in self.spec: + if "+cuda ~omp_as_runtime" in self.spec: ompdir = "build-bootstrapped-omp" + prefix_paths = spack.build_environment.get_cmake_prefix_path(self) + prefix_paths.append(str(spec.prefix)) # rebuild libomptarget to get bytecode runtime library files with working_dir(ompdir, create=True): cmake_args = [ - self.stage.source_path + "/openmp", + '-G', 'Ninja', + define('CMAKE_BUILD_TYPE', spec.variants['build_type'].value), define("CMAKE_C_COMPILER", spec.prefix.bin + "/clang"), define("CMAKE_CXX_COMPILER", spec.prefix.bin + "/clang++"), define("CMAKE_INSTALL_PREFIX", spec.prefix), + define('CMAKE_PREFIX_PATH', prefix_paths) ] cmake_args.extend(self.cmake_args()) - cmake_args.append(define("LIBOMPTARGET_NVPTX_ENABLE_BCLIB", - True)) - - # work around bad libelf detection in libomptarget - cmake_args.append(define("LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR", - spec["libelf"].prefix.include)) + cmake_args.extend([ + define("LIBOMPTARGET_NVPTX_ENABLE_BCLIB", True), + define("LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR", + spec["libelf"].prefix.include), + self.stage.source_path + "/openmp", + ]) cmake(*cmake_args) - make() - make("install") + ninja() + ninja("install") if "+python" in self.spec: install_tree("llvm/bindings/python", site_packages_dir) -- cgit v1.2.3-70-g09d2