Incoroporate feedback from code review
- check the version of `/usr/bin/ld` for support of `-no_fixup_chains` - check for usage of the `-fuse-ld` flag, since this flag is only supported by Apple ld64 Also, call `no_fixup_chains` when setting up the build environment.
This commit is contained in:
parent
1b12d74945
commit
c4fe6e7617
@ -26,9 +26,12 @@ module SharedEnvExtension
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def no_fixup_chains_support?
|
||||
return false if !MacOS::CLT.version.null? && MacOS::CLT.version < "13.0"
|
||||
return false if !MacOS::Xcode.version.null? && MacOS::Xcode.version < "13.0"
|
||||
ld_v = Utils.safe_popen_read("/usr/bin/ld", "-v", err: :out).lines.first.chomp
|
||||
ld_version = Version.parse(ld_v[/\d+(\.\d+)*$/])
|
||||
|
||||
true
|
||||
# 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
|
||||
ld_version >= 711
|
||||
end
|
||||
end
|
||||
|
@ -131,6 +131,11 @@ module Superenv
|
||||
# Notably, Xcode 10.2 fixes issues where ZERO_AR_DATE affected file mtimes.
|
||||
# Xcode 11.0 contains fixes for lldb reading things built with ZERO_AR_DATE.
|
||||
self["ZERO_AR_DATE"] = "1" if MacOS::Xcode.version >= "11.0" || MacOS::CLT.version >= "11.0"
|
||||
|
||||
# Pass `-no_fixup_chains` whenever the linker is invoked with `-undefined dynamic_lookup`.
|
||||
# See: https://github.com/python/cpython/issues/97524
|
||||
# https://github.com/pybind/pybind11/pull/4301
|
||||
no_fixup_chains
|
||||
end
|
||||
|
||||
def no_weak_imports
|
||||
@ -138,9 +143,6 @@ module Superenv
|
||||
end
|
||||
|
||||
def no_fixup_chains
|
||||
# Pass `-no_fixup_chains` whenever the linker is invoked with `-undefined dynamic_lookup`.
|
||||
# See: https://github.com/python/cpython/issues/97524
|
||||
# https://github.com/pybind/pybind11/pull/4301
|
||||
append_to_cccfg "f" if no_fixup_chains_support?
|
||||
end
|
||||
end
|
||||
|
@ -221,7 +221,7 @@ class Cmd
|
||||
args << "-Wl,-undefined,dynamic_lookup"
|
||||
when /^-isysroot=/, /^--sysroot=/
|
||||
if mac?
|
||||
sdk = arg.split("=")[1..-1].join("=")
|
||||
sdk = arg.split("=", 2).last
|
||||
# We set the sysroot for macOS SDKs
|
||||
args << arg unless sdk.downcase.include? "osx"
|
||||
else
|
||||
@ -420,6 +420,7 @@ class Cmd
|
||||
|
||||
def no_fixup_chains?
|
||||
return false unless config.include?("f")
|
||||
return false unless calls_ld?
|
||||
return true if @args.include?("-Wl,-undefined,dynamic_lookup")
|
||||
|
||||
args_consecutive_pairs = @args.each_cons(2)
|
||||
@ -430,6 +431,19 @@ class Cmd
|
||||
@args.include?("-undefineddynamic_lookup")
|
||||
end
|
||||
|
||||
def calls_ld?
|
||||
return true if mode == :ld
|
||||
return false unless [:ccld, :cxxld].include?(mode)
|
||||
|
||||
fuse_ld_flags = @args.find_all { |arg| arg.match?(/^-fuse-ld=/) }
|
||||
return true if fuse_ld_flags.empty?
|
||||
|
||||
fuse_ld_flag = fuse_ld_flags.last.strip
|
||||
fuse_ld_arg = fuse_ld_flag.split("=", 2).last
|
||||
|
||||
(fuse_ld_arg == "ld") || fuse_ld_arg.end_with("/usr/bin/ld")
|
||||
end
|
||||
|
||||
def canonical_path(path)
|
||||
path = Pathname.new(path)
|
||||
path = path.realpath if path.exist?
|
||||
|
Loading…
x
Reference in New Issue
Block a user