From 1c0eac787403884172dcd76cc0638ac89c7cee55 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 2 Aug 2022 19:09:38 +0800 Subject: [PATCH] Exclude GCC formulae from RPATH modification for GCC --- Library/Homebrew/extend/os/linux/keg_relocate.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/extend/os/linux/keg_relocate.rb b/Library/Homebrew/extend/os/linux/keg_relocate.rb index 11a33e3cf5..7cc2f27be2 100644 --- a/Library/Homebrew/extend/os/linux/keg_relocate.rb +++ b/Library/Homebrew/extend/os/linux/keg_relocate.rb @@ -35,10 +35,15 @@ class Keg # 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+$}) } + if !name.match?(Version.formula_optionally_versioned_regex(:gcc)) && + rpath.any? { |rp| rp.match?(%r{lib/gcc/\d+$}) } + # TODO: Replace with + # rpath.map! { |path| path = path.sub(%r{lib/gcc/\d+$}, "lib/gcc/current") } + # when + # 1. Homebrew/homebrew-core#106755 is merged + # 2. No formula has a runtime dependency on a versioned GCC (see `envoy.rb`) + rpath.prepend HOMEBREW_PREFIX/"opt/gcc/lib/gcc/current" + end rpath.join(":") end