llvm: use ninja by default (#27521)

* llvm: use ninja by default

* Use ninja for omp when it's not a runtime
This commit is contained in:
Harmen Stoppels 2021-11-24 01:28:17 +01:00 committed by GitHub
parent 0f1c04ed7e
commit dfc95cdf1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@
import llnl.util.tty as tty import llnl.util.tty as tty
import spack.build_environment
import spack.util.executable import spack.util.executable
@ -27,6 +28,8 @@ class Llvm(CMakePackage, CudaPackage):
tags = ['e4s'] tags = ['e4s']
generator = 'Ninja'
family = "compiler" # Used by lmod family = "compiler" # Used by lmod
# fmt: off # fmt: off
@ -165,6 +168,7 @@ class Llvm(CMakePackage, CudaPackage):
# Build dependency # Build dependency
depends_on("cmake@3.4.3:", type="build") 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@2.7:2.8", when="@:4 ~python", type="build")
depends_on("python", when="@5: ~python", type="build") depends_on("python", when="@5: ~python", type="build")
depends_on("pkgconfig", type="build") depends_on("pkgconfig", type="build")
@ -626,27 +630,31 @@ def post_install(self):
define = CMakePackage.define define = CMakePackage.define
# unnecessary if we build openmp via LLVM_ENABLE_RUNTIMES # 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" 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 # rebuild libomptarget to get bytecode runtime library files
with working_dir(ompdir, create=True): with working_dir(ompdir, create=True):
cmake_args = [ 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_C_COMPILER", spec.prefix.bin + "/clang"),
define("CMAKE_CXX_COMPILER", spec.prefix.bin + "/clang++"), define("CMAKE_CXX_COMPILER", spec.prefix.bin + "/clang++"),
define("CMAKE_INSTALL_PREFIX", spec.prefix), define("CMAKE_INSTALL_PREFIX", spec.prefix),
define('CMAKE_PREFIX_PATH', prefix_paths)
] ]
cmake_args.extend(self.cmake_args()) cmake_args.extend(self.cmake_args())
cmake_args.append(define("LIBOMPTARGET_NVPTX_ENABLE_BCLIB", cmake_args.extend([
True)) define("LIBOMPTARGET_NVPTX_ENABLE_BCLIB", True),
define("LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR",
# work around bad libelf detection in libomptarget spec["libelf"].prefix.include),
cmake_args.append(define("LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR", self.stage.source_path + "/openmp",
spec["libelf"].prefix.include)) ])
cmake(*cmake_args) cmake(*cmake_args)
make() ninja()
make("install") ninja("install")
if "+python" in self.spec: if "+python" in self.spec:
install_tree("llvm/bindings/python", site_packages_dir) install_tree("llvm/bindings/python", site_packages_dir)