Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unversioned GCC for runtime libraries when required. #13916

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Library/Homebrew/extend/os/linux/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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?

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/os.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down