-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Pass -no_fixup_chains to linker when required
#14873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Invoking `ld` with `-undefined dynamic_lookup` emits a warning starting
Xcode 14:
ld: warning: -undefined dynamic_lookup may not work with chained fixups
Chained fixups is a linker optimisation that results in faster binary
load times, and is enabled by default starting Xcode 13 when the target
is macOS 12 or newer.
However, this interacts poorly with `-undefined dynamic_lookup`, and
Xcode will disable chained fixups when it is invoked with this flag
starting Xcode 14.3. Until then, we may be shipping binaries that are
broken in subtle ways, so let's disable chained fixups when necessary
instead.
I patterned the changes here after the handling of `-no_weak_imports`.
The only difference is that we need to check the flags that were passed
to the linker first to see if we do need to disable chained fixups.
For additional context, see:
https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes
https://www.wwdcnotes.com/notes/wwdc22/110362/
https://www.emergetools.com/blog/posts/iOS15LaunchTime
python/cpython#97524
pybind/pybind11#4301
|
Review period will end on 2023-03-06 at 16:19:59 UTC. |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, nice work as usual @carlocab!
|
Additionally, is there any concerns with this paired with |
- 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.
The only formula I'm aware of that uses this is |
|
Review period ended. |
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still get that xcrun stderr noise on I think 11-arm64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is -version_details for better parsing (it's JSON) though it requires Xcode 10.2+.
Though with that said we could hardwire < Mojave to false which covers < 10.2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still see a lot of xcrun stderr noise. Used -version_details instead, so we don't accidentally catch any stderr garbage.
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?Invoking
ldwith-undefined dynamic_lookupemits a warning startingXcode 14:
Chained fixups is a linker optimisation that results in faster binary
load times, and is enabled by default starting Xcode 13 when the target
is macOS 12 or newer.
However, this interacts poorly with
-undefined dynamic_lookup, andXcode will disable chained fixups when it is invoked with this flag
starting Xcode 14.3. Until then, we may be shipping binaries that are
broken in subtle ways, so let's disable chained fixups when necessary
instead.
I patterned the changes here after the handling of
-no_weak_imports.The only difference is that we need to check the flags that were passed
to the linker first to see if we do need to disable chained fixups.
For additional context, see:
https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes
https://www.wwdcnotes.com/notes/wwdc22/110362/
https://www.emergetools.com/blog/posts/iOS15LaunchTime
python/cpython#97524
pybind/pybind11#4301