Use unversioned GCC for runtime libraries when required.

See discussion at Homebrew/homebrew-core#110010.
This commit is contained in:
Carlo Cabrera 2022-09-22 16:39:31 +08:00
parent 520d9c3ab8
commit a2081b488c
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 9 additions and 10 deletions

View File

@ -20,9 +20,6 @@ module Homebrew
].freeze ].freeze
private_constant :DYNAMIC_LINKERS 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, # 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 # 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 # as the other shared and static libraries are only used at build time where
@ -97,11 +94,13 @@ module Homebrew
# Add gcc to ld search paths # Add gcc to ld search paths
ld_gcc_conf = ld_so_conf_d/"50-homebrew-preferred-gcc.conf" ld_gcc_conf = ld_so_conf_d/"50-homebrew-preferred-gcc.conf"
unless ld_gcc_conf.exist? ld_gcc_conf_content = <<~EOS
ld_gcc_conf.atomic_write <<~EOS
# This file is generated by Homebrew. Do not modify. # This file is generated by Homebrew. Do not modify.
#{gcc_opt_prefix}/lib/gcc/#{PREFERRED_GCC_RUNTIME_VERSION} #{gcc_opt_prefix}/lib/gcc/current
EOS 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.chmod "u=rw,go-wx", ld_gcc_conf
FileUtils.rm_f HOMEBREW_PREFIX/"etc/ld.so.cache" FileUtils.rm_f HOMEBREW_PREFIX/"etc/ld.so.cache"
@ -118,7 +117,7 @@ module Homebrew
# Remove legacy symlinks # Remove legacy symlinks
FileUtils.rm gcc_library_symlink if gcc_library_symlink.symlink? FileUtils.rm gcc_library_symlink if gcc_library_symlink.symlink?
else 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. # Skip if the link target doesn't exist.
next unless gcc_library.readable? next unless gcc_library.readable?

View File

@ -51,7 +51,7 @@ module OS
LINUX_GLIBC_NEXT_CI_VERSION = "2.35" LINUX_GLIBC_NEXT_CI_VERSION = "2.35"
LINUX_GCC_CI_VERSION = "11.0" LINUX_GCC_CI_VERSION = "11.0"
LINUX_PREFERRED_GCC_COMPILER_FORMULA = "gcc@11" # https://packages.ubuntu.com/jammy/gcc 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? if OS.mac?
require "os/mac" require "os/mac"