summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorHarmen Stoppels <me@harmenstoppels.nl>2024-10-14 12:35:50 +0200
committerGitHub <noreply@github.com>2024-10-14 12:35:50 +0200
commit8b3d3ac2de3809479f1594e4afec7587abfe8e55 (patch)
treee770981c0108b8cec60680ee7b1615d04c5c9dd6 /var
parentb5610cdb8b27515ae9d75873802ff8c02aeff212 (diff)
downloadspack-8b3d3ac2de3809479f1594e4afec7587abfe8e55.tar.gz
spack-8b3d3ac2de3809479f1594e4afec7587abfe8e55.tar.bz2
spack-8b3d3ac2de3809479f1594e4afec7587abfe8e55.tar.xz
spack-8b3d3ac2de3809479f1594e4afec7587abfe8e55.zip
cmake: remove custom CMAKE_INSTALL_RPATH (#46685)
The CMake builder in Spack actually adds incorrect rpaths. They are unfiltered and incorrectly ordered compared to what the compiler wrapper adds. There is no need to specify paths to dependencies in `CMAKE_INSTALL_RPATH` because of two reasons: 1. CMake preserves "toolchain" rpaths, which includes the rpaths injected by our compiler wrapper. 2. We use `CMAKE_INSTALL_RPATH_USE_LINK_PATH=ON`, so libraries we link to are rpath'ed automatically. However, CMake does not create install rpaths to directories in the package's own install prefix, so we set `CMAKE_INSTALL_RPATH` to the educated guess `<prefix>/{lib,lib64}`, but omit dependencies.
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/cmake/package.py21
-rw-r--r--var/spack/repos/builtin/packages/llvm-doe/package.py4
-rw-r--r--var/spack/repos/builtin/packages/llvm/package.py4
3 files changed, 15 insertions, 14 deletions
diff --git a/var/spack/repos/builtin/packages/cmake/package.py b/var/spack/repos/builtin/packages/cmake/package.py
index f7d5636cde..7daade48e7 100644
--- a/var/spack/repos/builtin/packages/cmake/package.py
+++ b/var/spack/repos/builtin/packages/cmake/package.py
@@ -4,10 +4,12 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+import pathlib
import re
import sys
import spack.build_environment
+from spack.build_systems.cmake import get_cmake_prefix_path
from spack.package import *
@@ -332,6 +334,13 @@ class Cmake(Package):
else:
args.append("-DCMAKE_INSTALL_PREFIX=%s" % self.prefix)
+ # Make CMake find its own dependencies.
+ prefixes = get_cmake_prefix_path(self)
+ rpaths = [
+ pathlib.Path(self.prefix, "lib").as_posix(),
+ pathlib.Path(self.prefix, "lib64").as_posix(),
+ ]
+
args.extend(
[
f"-DCMAKE_BUILD_TYPE={self.spec.variants['build_type'].value}",
@@ -340,17 +349,9 @@ class Cmake(Package):
"-DCMake_TEST_INSTALL=OFF",
f"-DBUILD_CursesDialog={'ON' if '+ncurses' in spec else 'OFF'}",
f"-DBUILD_QtDialog={'ON' if spec.satisfies('+qtgui') else 'OFF'}",
- ]
- )
-
- # Make CMake find its own dependencies.
- rpaths = spack.build_environment.get_rpaths(self)
- prefixes = spack.build_environment.get_cmake_prefix_path(self)
- args.extend(
- [
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON",
- "-DCMAKE_INSTALL_RPATH={0}".format(";".join(str(v) for v in rpaths)),
- "-DCMAKE_PREFIX_PATH={0}".format(";".join(str(v) for v in prefixes)),
+ f"-DCMAKE_INSTALL_RPATH={';'.join(rpaths)}",
+ f"-DCMAKE_PREFIX_PATH={';'.join(str(v) for v in prefixes)}",
]
)
diff --git a/var/spack/repos/builtin/packages/llvm-doe/package.py b/var/spack/repos/builtin/packages/llvm-doe/package.py
index 6effe2c057..6bf4f67e50 100644
--- a/var/spack/repos/builtin/packages/llvm-doe/package.py
+++ b/var/spack/repos/builtin/packages/llvm-doe/package.py
@@ -9,8 +9,8 @@ import sys
import llnl.util.tty as tty
-import spack.build_environment
import spack.util.executable
+from spack.build_systems.cmake import get_cmake_prefix_path
from spack.package import *
@@ -573,7 +573,7 @@ class LlvmDoe(CMakePackage, CudaPackage):
# unnecessary if we build openmp via LLVM_ENABLE_RUNTIMES
if self.spec.satisfies("+cuda ~omp_as_runtime"):
ompdir = "build-bootstrapped-omp"
- prefix_paths = spack.build_environment.get_cmake_prefix_path(self)
+ prefix_paths = 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):
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
index 09388cb5ab..8c9ccb1790 100644
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -10,8 +10,8 @@ import sys
import llnl.util.tty as tty
from llnl.util.lang import classproperty
-import spack.build_environment
import spack.util.executable
+from spack.build_systems.cmake import get_cmake_prefix_path
from spack.package import *
from spack.package_base import PackageBase
@@ -1072,7 +1072,7 @@ class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage):
# unnecessary if we build openmp via LLVM_ENABLE_RUNTIMES
if self.spec.satisfies("+cuda openmp=project"):
ompdir = "build-bootstrapped-omp"
- prefix_paths = spack.build_environment.get_cmake_prefix_path(self)
+ prefix_paths = 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):