-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows #31146
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
[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows #31146
Conversation
e4ba672
to
c2b370c
Compare
What do you think of spelling this option as This will also allow for |
Why is this limited to macOS? Linux and Windows can also support this. |
7510a06
to
11a6113
Compare
@compnerd I updated option style to
I tried to support Linux and Windows but I faced some problems I want to ask you. 1. For Linux:LLVM LTO with gold needs
Or should we give up to link using gold and use lld instead of gold on Linux? 2. For Windows:(I'm not familiar with Windows development) As far as I investigated, only lld supports LLVM LTO on Windows. |
That said, I don't think that requiring lld is a terrible thing. Windows is going to require that we use lld anyways. link does support LTO, just does not have a plugin interface. It is enabled via the |
4866f8c
to
550fafe
Compare
@compnerd I implemented for both Linux and Windows using LLVMgold and lld-link. But I faced an issue on windows around static archives. But when clang linker received |
Static libraries shouldn’t have the lib prefix imo. However, static libraries don’t work on windows. I would recommend that you just stick to dynamic libraries everywhere. |
OK, I disabled some test cases related to static library on Windows |
5e4a643
to
a6096da
Compare
I don't think that we should be cloning the binutils repository. |
a476a27
to
89b1752
Compare
binutils repository is necessary to build LLVMgold.so. But I agree that we should use official repository instead of mirror repo if we use that. |
You can require that the user install the package. What exactly is needed from the binutils package? The license in that makes it challenging to use. |
50eddff
to
c8bddd8
Compare
LLVMGold depends on
OK, I removed binutils dependency. Now, user needs to build LLVMGold following docs and put it in the |
c8bddd8
to
41f6f75
Compare
Build failed |
@swift-ci please test |
Build failed |
@swift-ci please test |
I found that lld is not built on windows CI, so the job failed. I'll add lld to |
7ee923b
to
7e57cdc
Compare
@compnerd Could you trigger CI again? |
Build failed |
7e57cdc
to
7297430
Compare
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test Linux platform |
@swift-ci please test Windows platform |
This commit adds -lto flag for driver to enable LTO at LLVM level. When -lto=llvm given, compiler emits LLVM bitcode file instead of object file and perform thin LTO using libLTO.dylib plugin. When -lto=llvm-full given, perform full LTO instead of thin LTO.
7297430
to
915c4a6
Compare
Build failed |
@swift-ci please clean test |
Build failed |
@swift-ci please test Windows platform |
@swift-ci please test Linux platform |
1 similar comment
@swift-ci please test Linux platform |
Is there anything that prevents this PR from being merged? |
On platforms which don't support LTO, should these just be XFAIL? Or is there a nicer way of detecting lack of LTO that we can put into a REQUIRES declaration? |
All the ELF platforms should be able to support LTO, though it requires that lld is used as the linker. LTO doesn't really have much in terms of platform specific dependencies other than a linker that supports LTO itself. |
@kateinoigakukun - this seems to have caused failures on many of the CI hosts due to the LLVMgold plugin not being built I suspect:
I'm going to revert this until that has been addressed. |
This commit adds -llvm-lto flag for driver to enable LTO at LLVM level.
When -llvm-lto given, compiler emits LLVM bitcode file instead of object
file and link them using libLTO.dylib plugin.
Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.
Resolves SR-NNNN.