Fix DevelopmentTools::ld64_version on macOS

This commit is contained in:
Rylan Polster 2025-06-21 21:13:38 -04:00
parent 2a7fbd00a9
commit 508c8b606c
No known key found for this signature in database
4 changed files with 9 additions and 4 deletions

View File

@ -57,6 +57,11 @@ class DevelopmentTools
:clang
end
sig { returns(Version) }
def ld64_version
Version::NULL
end
# Get the Clang version.
#
# @api public

View File

@ -37,7 +37,7 @@ module OS
end
sig { returns(Version) }
def self.ld64_version
def ld64_version
@ld64_version ||= T.let(begin
json = Utils.popen_read("/usr/bin/ld", "-version_details")
if $CHILD_STATUS.success?

View File

@ -41,7 +41,7 @@ module OS
# This is supported starting Xcode 13, which ships ld64-711.
# https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes
# https://en.wikipedia.org/wiki/Xcode#Xcode_11.0_-_14.x_(since_SwiftUI_framework)_2
OS::Mac::DevelopmentTools.ld64_version >= 711
::DevelopmentTools.ld64_version >= 711
end
end
end

View File

@ -149,11 +149,11 @@ module OS
no_fixup_chains
# Strip build prefixes from linker where supported, for deterministic builds.
append_to_cccfg "o" if OS::Mac::DevelopmentTools.ld64_version >= 512
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.
return unless OS::Mac::DevelopmentTools.ld64_version.between?("1015.7", "1022.1")
return unless ::DevelopmentTools.ld64_version.between?("1015.7", "1022.1")
append_to_cccfg "c"
end