From a372ca61006712eb6aaac533ccf1ca2b80eff5ca Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 19 Sep 2022 04:35:40 +0100 Subject: [PATCH] extend/os/linux/development_tools: consider keg-only glibc & binutils --- .../Homebrew/extend/os/linux/development_tools.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/extend/os/linux/development_tools.rb b/Library/Homebrew/extend/os/linux/development_tools.rb index 35c83585f9..7707a9eed4 100644 --- a/Library/Homebrew/extend/os/linux/development_tools.rb +++ b/Library/Homebrew/extend/os/linux/development_tools.rb @@ -8,10 +8,15 @@ class DevelopmentTools sig { params(tool: String).returns(T.nilable(Pathname)) } def locate(tool) (@locate ||= {}).fetch(tool) do |key| - @locate[key] = if (path = HOMEBREW_PREFIX/"bin/#{tool}").executable? - path - elsif File.executable?(path = "/usr/bin/#{tool}") - Pathname.new path + @locate[key] = if build_system_too_old? && + (binutils_path = HOMEBREW_PREFIX/"opt/binutils/bin/#{tool}").executable? + binutils_path + elsif build_system_too_old? && (glibc_path = HOMEBREW_PREFIX/"opt/glibc/bin/#{tool}").executable? + glibc_path + elsif (homebrew_path = HOMEBREW_PREFIX/"bin/#{tool}").executable? + homebrew_path + elsif File.executable?(system_path = "/usr/bin/#{tool}") + Pathname.new system_path end end end @@ -30,7 +35,7 @@ class DevelopmentTools sig { returns(T::Boolean) } def system_gcc_too_old? - gcc_version("gcc") < OS::LINUX_GCC_CI_VERSION + gcc_version("/usr/bin/gcc") < OS::LINUX_GCC_CI_VERSION end sig { returns(T::Hash[String, T.nilable(String)]) }