diff --git a/Library/Homebrew/extend/os/linux/install.rb b/Library/Homebrew/extend/os/linux/install.rb index 6bf944c08e04b..2202386424735 100644 --- a/Library/Homebrew/extend/os/linux/install.rb +++ b/Library/Homebrew/extend/os/linux/install.rb @@ -20,9 +20,6 @@ module Install ].freeze private_constant :DYNAMIC_LINKERS - PREFERRED_GCC_RUNTIME_VERSION = OS::LINUX_PREFERRED_GCC_RUNTIME_FORMULA.split("@").last.freeze - private_constant :PREFERRED_GCC_RUNTIME_VERSION - # We link GCC runtime libraries that are not specificaly used for Fortran, # which are linked by the GCC formula. We only use the versioned shared libraries # as the other shared and static libraries are only used at build time where @@ -97,11 +94,13 @@ def setup_preferred_gcc_libs # Add gcc to ld search paths ld_gcc_conf = ld_so_conf_d/"50-homebrew-preferred-gcc.conf" - unless ld_gcc_conf.exist? - ld_gcc_conf.atomic_write <<~EOS - # This file is generated by Homebrew. Do not modify. - #{gcc_opt_prefix}/lib/gcc/#{PREFERRED_GCC_RUNTIME_VERSION} - EOS + ld_gcc_conf_content = <<~EOS + # This file is generated by Homebrew. Do not modify. + #{gcc_opt_prefix}/lib/gcc/current + EOS + + if !ld_gcc_conf.exist? || (ld_gcc_conf.read != ld_gcc_conf_content) + ld_gcc_conf.atomic_write ld_gcc_conf_content FileUtils.chmod "u=rw,go-wx", ld_gcc_conf FileUtils.rm_f HOMEBREW_PREFIX/"etc/ld.so.cache" @@ -118,7 +117,7 @@ def setup_preferred_gcc_libs # Remove legacy symlinks FileUtils.rm gcc_library_symlink if gcc_library_symlink.symlink? else - gcc_library = gcc_opt_prefix/"lib/gcc/#{PREFERRED_GCC_RUNTIME_VERSION}/#{library}" + gcc_library = gcc_opt_prefix/"lib/gcc/current/#{library}" # Skip if the link target doesn't exist. next unless gcc_library.readable? diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb index a36363695fb0e..13ee649519ba6 100644 --- a/Library/Homebrew/os.rb +++ b/Library/Homebrew/os.rb @@ -51,7 +51,7 @@ def self.kernel_name LINUX_GLIBC_NEXT_CI_VERSION = "2.35" LINUX_GCC_CI_VERSION = "11.0" LINUX_PREFERRED_GCC_COMPILER_FORMULA = "gcc@11" # https://packages.ubuntu.com/jammy/gcc - LINUX_PREFERRED_GCC_RUNTIME_FORMULA = "gcc@12" # https://packages.ubuntu.com/jammy/libstdc++6 + LINUX_PREFERRED_GCC_RUNTIME_FORMULA = "gcc" if OS.mac? require "os/mac"