Merge pull request #17950 from Homebrew/ld_classic

This commit is contained in:
Carlo Cabrera 2024-08-04 05:55:45 +08:00 committed by GitHub
commit 4e95bad9c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 1 deletions

View File

@ -104,11 +104,13 @@ module Superenv
# K - Don't strip -arch <arch>, -m32, or -m64
# d - Don't strip -march=<target>. Use only in formulae that
# have runtime detection of CPU features.
# w - Pass -no_weak_imports to the linker
# D - Generate debugging information
# w - Pass `-no_weak_imports` to the linker
# f - Pass `-no_fixup_chains` to `ld` whenever it
# is invoked with `-undefined dynamic_lookup`
# o - Pass `-oso_prefix` to `ld` whenever it is invoked
# c - Pass `-ld_classic` to `ld` whenever it is invoked
# with `-dead_strip_dylibs`
#
# These flags will also be present:
# a - apply fix for apr-1-config path

View File

@ -143,6 +143,10 @@ module Superenv
# Strip build prefixes from linker where supported, for deterministic builds.
append_to_cccfg "o" if DevelopmentTools.ld64_version >= 512
# Pass `-ld_classic` whenever the linker is invoked with `-dead_strip_dylibs`
# on `ld` versions that don't properly handle that option.
append_to_cccfg "c" if DevelopmentTools.ld64_version >= "1015.7" && DevelopmentTools.ld64_version <= "1022.1"
end
def no_weak_imports

View File

@ -324,11 +324,13 @@ class Cmd
args << "-no_weak_imports" if no_weak_imports?
args << "-no_fixup_chains" if no_fixup_chains?
args << "-oso_prefix" << formula_buildpath if oso_prefix? && formula_buildpath
args << "-ld_classic" if ld_classic?
when :ccld, :cxxld
args << "-Wl,-headerpad_max_install_names"
args << "-Wl,-no_weak_imports" if no_weak_imports?
args << "-Wl,-no_fixup_chains" if no_fixup_chains?
args << "-Wl,-oso_prefix,#{formula_buildpath}" if oso_prefix? && formula_buildpath
args << "-Wl,-ld_classic" if ld_classic?
end
args
end
@ -441,6 +443,10 @@ class Cmd
config.include?("o") && !configure?
end
def ld_classic?
config.include?("c") && calls_ld? && @args.any? { |arg| arg.match?(/^(-Wl,)?-dead_strip_dylibs$/) }
end
def calls_ld?
return true if mode == :ld
return false unless [:ccld, :cxxld].include?(mode)