keg_relocate: fix new GCC lib directory

Also add comment explaining what this line does, along with a TODO
suggesting a replacement once we've shipped the GCC PR.
This commit is contained in:
Carlo Cabrera 2022-08-02 13:29:14 +08:00
parent 53fdb64113
commit 532460c098
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -32,7 +32,13 @@ class Keg
lib_path = "#{new_prefix}/lib"
rpath << lib_path unless rpath.include? lib_path
rpath.prepend HOMEBREW_PREFIX/"opt/gcc/lib/current" if rpath.any? { |rp| rp.match?(%r{lib/gcc/\d+$}) }
# Add GCC's lib directory (as of GCC 12+) to RPATH when there is existing linkage.
# This fixes linkage for newly-poured bottles.
# TODO: Replace with
# rpath.map! { |path| path = path.sub(%r{lib/gcc/\d+$}, "lib/gcc/current") }
# when Homebrew/homebrew-core#106755 is merged.
rpath.prepend HOMEBREW_PREFIX/"opt/gcc/lib/gcc/current" if rpath.any? { |rp| rp.match?(%r{lib/gcc/\d+$}) }
rpath.join(":")
end