Skip to content

Commit

Permalink
Merge pull request #17950 from Homebrew/ld_classic
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocab authored Aug 3, 2024
2 parents b5af2b5 + 0477944 commit 4e95bad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Library/Homebrew/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a
# 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
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/os/mac/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a

# 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
Expand Down
6 changes: 6 additions & 0 deletions Library/Homebrew/shims/super/cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4e95bad

Please sign in to comment.