Skip to content

Commit

Permalink
Merge pull request #13914 from carlocab/linux-keg_relocate
Browse files Browse the repository at this point in the history
linux/keg_relocate: clean up GCC RPATH fix.
  • Loading branch information
carlocab committed Sep 22, 2022
2 parents 0b602f6 + 8a9ed2c commit cad6f1c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Library/Homebrew/extend/os/linux/keg_relocate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ def change_rpath(file, old_prefix, new_prefix)
lib_path = "#{new_prefix}/lib"
rpath << lib_path unless rpath.include? lib_path

# Add GCC's lib directory (as of GCC 12+) to RPATH when there is existing linkage.
# This fixes linkage for newly-poured bottles.
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"
# Add GCC's lib directory (as of GCC 12+) to RPATH when there is existing versioned linkage.
# This prevents broken linkage when pouring bottles built with an old GCC formula.
unless name.match?(Version.formula_optionally_versioned_regex(:gcc))
rpath.map! { |rp| rp.sub(%r{lib/gcc/\d+$}, "lib/gcc/current") }
end

rpath.join(":")
Expand Down

0 comments on commit cad6f1c

Please sign in to comment.