summaryrefslogtreecommitdiff
path: root/lib/spack/llnl/util
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2022-11-04 00:34:00 +0100
committerGitHub <noreply@github.com>2022-11-03 17:34:00 -0600
commitb52be759788cf20f1458c80e6e005744f5856c73 (patch)
treea53db50ae7ca4ea9e779be099faee6581fc24eda /lib/spack/llnl/util
parent7fc49c42ee27bcd2629e3ac112e63da460d9a26c (diff)
downloadspack-b52be759788cf20f1458c80e6e005744f5856c73.tar.gz
spack-b52be759788cf20f1458c80e6e005744f5856c73.tar.bz2
spack-b52be759788cf20f1458c80e6e005744f5856c73.tar.xz
spack-b52be759788cf20f1458c80e6e005744f5856c73.zip
Experimental binding of shared ELF libraries (#31948)
Adds another post install hook that loops over the install prefix, looking for shared libraries type of ELF files, and sets the soname to their own absolute paths. The idea being, whenever somebody links against those libraries, the linker copies the soname (which is the absolute path to the library) as a "needed" library, so that at runtime the dynamic loader realizes the needed library is a path which should be loaded directly without searching. As a result: 1. rpaths are not used for the fixed/static list of needed libraries in the dynamic section (only for _actually_ dynamically loaded libraries through `dlopen`), which largely solves the issue that Spack's rpaths are a heuristic (`<prefix>/lib` and `<prefix>/lib64` might not be where libraries really are...) 2. improved startup times (no library search required)
Diffstat (limited to 'lib/spack/llnl/util')
-rw-r--r--lib/spack/llnl/util/lang.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index f1a0b7ba31..51bd710ddb 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -1022,6 +1022,14 @@ def stable_partition(
return true_items, false_items
+def ensure_last(lst, *elements):
+ """Performs a stable partition of lst, ensuring that ``elements``
+ occur at the end of ``lst`` in specified order. Mutates ``lst``.
+ Raises ``ValueError`` if any ``elements`` are not already in ``lst``."""
+ for elt in elements:
+ lst.append(lst.pop(lst.index(elt)))
+
+
class TypedMutableSequence(MutableSequence):
"""Base class that behaves like a list, just with a different type.