summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarmen Stoppels <me@harmenstoppels.nl>2024-07-03 10:46:07 +0200
committerGitHub <noreply@github.com>2024-07-03 10:46:07 +0200
commitf022b93249d52663697c29d8b28309e2ed787046 (patch)
tree1cb797709678a5f61871cee667b33a0b4fdc73ce
parent60b5e9818226b610ddc5ffa8850c50aef26b2a0d (diff)
downloadspack-f022b93249d52663697c29d8b28309e2ed787046.tar.gz
spack-f022b93249d52663697c29d8b28309e2ed787046.tar.bz2
spack-f022b93249d52663697c29d8b28309e2ed787046.tar.xz
spack-f022b93249d52663697c29d8b28309e2ed787046.zip
cmake: add patch to allow static linking with -DCMAKE_INSTALL_RPATH set (#44900)
-rw-r--r--var/spack/repos/builtin/packages/cmake/mr-9623.patch67
-rw-r--r--var/spack/repos/builtin/packages/cmake/package.py4
2 files changed, 71 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/cmake/mr-9623.patch b/var/spack/repos/builtin/packages/cmake/mr-9623.patch
new file mode 100644
index 0000000000..c36e22c59f
--- /dev/null
+++ b/var/spack/repos/builtin/packages/cmake/mr-9623.patch
@@ -0,0 +1,67 @@
+diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
+index a71e5f1280..003f47b439 100644
+--- a/Source/cmELF.cxx
++++ b/Source/cmELF.cxx
+@@ -112,6 +112,9 @@ public:
+ virtual bool IsMips() const = 0;
+ virtual void PrintInfo(std::ostream& os) const = 0;
+
++ /** Returns true if the ELF file has a dynamic section **/
++ bool HasDynamicSection() const { return this->DynamicSectionIndex >= 0; }
++
+ // Lookup the SONAME in the DYNAMIC section.
+ StringEntry const* GetSOName()
+ {
+@@ -461,7 +464,7 @@ template <class Types>
+ bool cmELFInternalImpl<Types>::LoadDynamicSection()
+ {
+ // If there is no dynamic section we are done.
+- if (this->DynamicSectionIndex < 0) {
++ if (!this->HasDynamicSection()) {
+ return false;
+ }
+
+@@ -772,6 +775,11 @@ std::vector<char> cmELF::EncodeDynamicEntries(
+ return std::vector<char>();
+ }
+
++bool cmELF::HasDynamicSection() const
++{
++ return this->Valid() && this->Internal->HasDynamicSection();
++}
++
+ bool cmELF::GetSOName(std::string& soname)
+ {
+ if (StringEntry const* se = this->GetSOName()) {
+diff --git a/Source/cmELF.h b/Source/cmELF.h
+index ce8bd7fb92..dd37c65302 100644
+--- a/Source/cmELF.h
++++ b/Source/cmELF.h
+@@ -88,6 +88,9 @@ public:
+ std::vector<char> EncodeDynamicEntries(
+ const DynamicEntryList& entries) const;
+
++ /** Returns true if the ELF file has a dynamic section **/
++ bool HasDynamicSection() const;
++
+ /** Get the SONAME field if any. */
+ bool GetSOName(std::string& soname);
+ StringEntry const* GetSOName();
+diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
+index 093a18b82b..3affef0394 100644
+--- a/Source/cmSystemTools.cxx
++++ b/Source/cmSystemTools.cxx
+@@ -2817,6 +2817,10 @@ cm::optional<bool> AdjustRPathELF(std::string const& file,
+ return cm::nullopt; // Not a valid ELF file.
+ }
+
++ if (!elf.HasDynamicSection()) {
++ return true; // No dynamic section to update.
++ }
++
+ // Get the RPATH and RUNPATH entries from it.
+ int se_count = 0;
+ cmELF::StringEntry const* se[2] = { nullptr, nullptr };
+--
+2.40.1
+
diff --git a/var/spack/repos/builtin/packages/cmake/package.py b/var/spack/repos/builtin/packages/cmake/package.py
index 6c4db1d1c8..2497dfa832 100644
--- a/var/spack/repos/builtin/packages/cmake/package.py
+++ b/var/spack/repos/builtin/packages/cmake/package.py
@@ -124,6 +124,10 @@ class Cmake(Package):
when="@3.15.5",
)
+ # Statically linked binaries error on install when CMAKE_INSTALL_RPATH is set
+ # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9623
+ patch("mr-9623.patch", when="@3.22.0:3.30")
+
depends_on("ninja", when="platform=windows")
depends_on("gmake", when="platform=linux")
depends_on("gmake", when="platform=darwin")