-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Enable linker dead stripping on Darwin #22839
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
See r://48283130. This shaves 6MB+ off of swift and SourceKitService, 26.8MB off of swift-llvm-opt, 29.4MB off sil-passpipeline-dumper, etc.
@swift-ci smoke test |
@akyrtzi Do you know of any build/link issues with plugins that could be triggered by dead stripping? Or are all those problems resolved at this point? |
cmake/modules/AddSwift.cmake
Outdated
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
# See rdar://48283130: This gives 6MB+ size reductions for swift and | ||
# SourceKitService, and much larger size reductions for sil-opt etc. | ||
list(APPEND result "-Wl,-dead_strip") |
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.
add_link_opts
only adds the option for a release build. It may be useful to avoid stripping in debug builds because stripping can hide linker errors caused by dependency cycles.
Or try to just delegate to add_link_opts
?
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'll add a Debug check. It'll take extensive refactoring to pull in the definition of add_link_opts
here (just including AddLLVM breaks the swift build due to conflicting variables).
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.
Hmm, I'm certainly no CMake expert but just want to point out that I've added a call to add_link_opts
in here:
https://github.com/apple/swift/blob/34f8670d2a8d1ce05c6da32da8e484e543e8ec5e/tools/libSwiftSyntaxParser/CMakeLists.txt#L21
without issues, but maybe this particular file is problematic for it.
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.
Yeah, add_link_opts requires that a target exists (it sets properties on the target directly). Most of swift's cmake logic collects properties, and then creates a target.
Maybe we should just factor out the core logic in add_link_opts into a helper which returns a list (in llvm), then use that here?
I'm not aware of any such problems, AFAIK we don't support loading plugins from swift or SourceKitService. |
It can hide linker errors caused by dependency cycles.
@swift-ci smoke test |
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.
Amazing!
# `add_link_opts` function (which, perhaps, should have been used here in the | ||
# first place, but at this point it's hard to say whether that's feasible). | ||
# | ||
# TODO: Evaluate/enable -f{function,data}-sections --gc-sections for bfd, |
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.
BFD is an unsupported linker (it cannot handle the protected semantics needed for swift)
@swift-ci smoke test Linux platform |
See r://48283130. This shaves 6MB+ off of swift and SourceKitService,
26.8MB off of swift-llvm-opt, 29.4MB off sil-passpipeline-dumper, etc.