2024-08-12 10:30:59 +01:00
|
|
|
# typed: true # rubocop:todo Sorbet/StrictSigil
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-02-08 20:06:09 +01:00
|
|
|
require "compilers"
|
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
module OS
|
|
|
|
module Linux
|
|
|
|
module LinkageChecker
|
|
|
|
# Libraries provided by glibc and gcc.
|
|
|
|
SYSTEM_LIBRARY_ALLOWLIST = %w[
|
|
|
|
ld-linux-x86-64.so.2
|
|
|
|
ld-linux-aarch64.so.1
|
|
|
|
libanl.so.1
|
|
|
|
libatomic.so.1
|
|
|
|
libc.so.6
|
|
|
|
libdl.so.2
|
|
|
|
libm.so.6
|
|
|
|
libmvec.so.1
|
|
|
|
libnss_files.so.2
|
|
|
|
libpthread.so.0
|
|
|
|
libresolv.so.2
|
|
|
|
librt.so.1
|
|
|
|
libthread_db.so.1
|
|
|
|
libutil.so.1
|
|
|
|
libgcc_s.so.1
|
|
|
|
libgomp.so.1
|
|
|
|
libstdc++.so.6
|
|
|
|
libquadmath.so.0
|
|
|
|
].freeze
|
2018-09-05 15:29:42 -07:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
private
|
2022-04-15 20:37:32 +01:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
def check_dylibs(rebuild_cache:)
|
|
|
|
super
|
2018-09-05 15:29:42 -07:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
# glibc and gcc are implicit dependencies.
|
|
|
|
# No other linkage to system libraries is expected or desired.
|
|
|
|
@unwanted_system_dylibs = @system_dylibs.reject do |s|
|
|
|
|
SYSTEM_LIBRARY_ALLOWLIST.include? File.basename(s)
|
|
|
|
end
|
2022-09-02 14:28:07 +08:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
# We build all formulae with an RPATH that includes the gcc formula's runtime lib directory.
|
|
|
|
# See: https://github.com/Homebrew/brew/blob/e689cc07/Library/Homebrew/extend/os/linux/extend/ENV/super.rb#L53
|
|
|
|
# This results in formulae showing linkage with gcc whenever it is installed, even if no dependency is
|
|
|
|
# declared.
|
|
|
|
# See discussions at:
|
|
|
|
# https://github.com/Homebrew/brew/pull/13659
|
|
|
|
# https://github.com/Homebrew/brew/pull/13796
|
|
|
|
# TODO: Find a nicer way to handle this. (e.g. examining the ELF file to determine the required libstdc++.)
|
|
|
|
@undeclared_deps.delete("gcc")
|
|
|
|
@indirect_deps.delete("gcc")
|
|
|
|
end
|
|
|
|
end
|
2018-09-05 15:29:42 -07:00
|
|
|
end
|
|
|
|
end
|
2025-06-13 16:59:10 +01:00
|
|
|
|
|
|
|
LinkageChecker.prepend(OS::Linux::LinkageChecker)
|