From 309504a32cf3b70d8b84dd9801caad386d46b68f Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Mon, 19 Apr 2021 09:23:33 +0100 Subject: [PATCH] formula: add rpath helper method About 40 formulae set `CMAKE_INSTALL_RPATH` to `lib` or `opt_lib`, but this breaks bottle relocatability. The correct solution is to use `@loader_path/../lib`, but this is macOS specific, so it requires some OS-specific logic. Rather than replicating this logic over many formulae, we may as well define a helper method for it. See https://github.com/Homebrew/homebrew-core/issues/75458. --- Library/Homebrew/extend/os/linux/formula.rb | 5 +++++ Library/Homebrew/formula.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Library/Homebrew/extend/os/linux/formula.rb b/Library/Homebrew/extend/os/linux/formula.rb index c603694cc6..fde9216664 100644 --- a/Library/Homebrew/extend/os/linux/formula.rb +++ b/Library/Homebrew/extend/os/linux/formula.rb @@ -3,6 +3,7 @@ class Formula undef shared_library + undef rpath def shared_library(name, version = nil) suffix = if version == "*" || (name == "*" && version.blank?) @@ -13,6 +14,10 @@ class Formula "#{name}.so#{suffix}" end + def rpath + "'$ORIGIN/../lib'" + end + class << self undef ignore_missing_libraries diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index ab8ab2f05a..71ddf5f128 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1523,6 +1523,12 @@ class Formula "#{name}#{infix}.dylib" end + # Executable/Library RPATH according to platform conventions. + sig { returns(String) } + def rpath + "@loader_path/../lib" + end + # an array of all core {Formula} names # @private def self.core_names