-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Revert "Revert "[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows"" #32237
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
Revert "Revert "[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows"" #32237
Conversation
…rwin, Linux and Windows"" This reverts commit 71309a8.
At this time, we don't support gold and other linkers for LTO.
@swift-ci please test |
@compnerd Could you trigger android and other platforms CI jobs? |
I dont think its possible to trigger a run for android sadly. I can trigger it for AWS Linux and CentOS 8 though, so lets just ensure that those will stay green. |
@swift-ci Please test Amazon Linux 2 platform |
@swift-ci Please test CentOS 8 platform |
Build failed |
Build failed |
Hmm, it seems these CI jobs are not working well... |
I'm not sure who maintains these platforms CI, but it seems something wrong in CI system. CC: @compnerd |
CC: @shahmishal - are CentOS and AWS Linux CI builders supposed to work? |
They should be working, I will look into this tomorrow. |
Build failed |
Build failed |
Build failed |
@swift-ci Please test Amazon Linux 2 platform |
Build failed |
Thats not really helpful :/, lets try this once more. If it fails (due to infra), lets go ahead and merge and deal with the fallout. |
@swift-ci please test Amazon Linux 2 platform |
Why merge it with known failure? Are you not able to reproduce this locally? |
@shahmishal hmm, are there instructions for reproducing the builds locally? But, I suspect that its a disk size thing. |
@swift-ci please test CentOS 8 platform |
Build failed |
@shahmishal CentOS still is failing without building:
|
@compnerd I am looking into the CentOS 8 issues, however Amazon Linux 2 issue looks real. |
Build failed |
Build failed |
assert(Kind != LinkKind::None && Kind != LinkKind::StaticLibrary); | ||
} | ||
|
||
LinkKind getKind() const { return Kind; } | ||
|
||
bool PerformLTO() const { return LTO; } |
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.
Please follow naming guidelines!
-> shouldPerformLTO().
Can you rename the flag to ShouldPerformLTO? What does bool LTO even mean? It is ambiguous.
@@ -217,6 +223,8 @@ class IRGenOptions { | |||
/// Whether we should embed the bitcode file. | |||
IRGenEmbedMode EmbedMode : 2; | |||
|
|||
IRGenLLVMLTOKind LLVMLTOKind: 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.
This code has not been run through git-clang-format. Please do so before this lands!
@@ -1779,6 +1782,18 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args, | |||
|
|||
} | |||
|
|||
if (const Arg *A = Args.getLastArg(options::OPT_lto)) { | |||
auto LTOVariant = llvm::StringSwitch<Optional<OutputInfo::LTOKind>>(A->getValue()) | |||
.Case("llvm", OutputInfo::LTOKind::LLVMThin) |
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.
Lets be explicit here and be clear that it is llvm-thin.
} | ||
break; | ||
} | ||
case OutputInfo::LTOKind::None: break; |
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.
This is another example where you haven't used git-clang-format. Please do so before this lands!
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 want to look at this again before it goes back in. All of the changes that have been made to IRGen need IRGen FileCheck test cases.
Build failed |
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.
At a higher level, you probably want to split up this PR into a PR that handles the driver part and the part that handles the pipeline part. The first PR would have a bunch of IR tests that validate that all of the proper LTO bigs work together ignoring the driver. This PR smooshes the two together and doesn't provide any .ll tests. That needs to be fixed.
// When performing LTO, we always use lld that supports auto linking mechanism with ELF. | ||
// So embed dependent libraries names in "llvm.dependent-libraries" instead of "llvm.linker.options". | ||
const StringRef AutolinkSectionName = | ||
TargetInfo.OutputObjectFormat == llvm::Triple::ELF && IRGen.Opts.LLVMLTOKind != IRGenLLVMLTOKind::None |
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.
Test?
llvm::MDNode::get(ctx, llvm::MDString::get(ctx, opt))); | ||
if (TargetInfo.OutputObjectFormat == llvm::Triple::ELF && IRGen.Opts.LLVMLTOKind != IRGenLLVMLTOKind::None) { | ||
// When performing LTO, we always use lld that supports auto linking mechanism with ELF. | ||
// So embed dependent libraries names in "llvm.dependent-libraries" instead of options |
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.
Test?
CC: @atrick @eeckstein |
Resolve CI failure on android and other hosts addressed at #31146 (comment) and restore #32235
Android test cases try to use gold linker
-use-ld=gold
but we don't support gold and other linkers except for lld for LTO now. So I changed to force to use lld when LTO on Unix like toolchainCC: @compnerd