Add support for -ffat-lto-objects. (#4549)

This commit is contained in:
Johan Engelen 2024-03-01 21:19:00 +01:00 committed by GitHub
parent 0b62d9d510
commit e0f9fa6e20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 3 deletions

View file

@ -201,6 +201,8 @@ void ArgsBuilder::addDarwinLTOFlags() {
/// Adds the required linker flags for LTO builds to args.
void ArgsBuilder::addLTOLinkFlags() {
bool isLld = opts::linker == "lld" || useInternalLLDForLinking() ||
(opts::linker.empty() && isLldDefaultLinker());
if (global.params.targetTriple->isOSLinux() ||
global.params.targetTriple->isOSFreeBSD() ||
global.params.targetTriple->isOSNetBSD() ||
@ -208,12 +210,15 @@ void ArgsBuilder::addLTOLinkFlags() {
global.params.targetTriple->isOSDragonFly()) {
// LLD supports LLVM LTO natively, do not add the plugin itself.
// Otherwise, assume that ld.gold or ld.bfd is used with plugin support.
bool isLld = opts::linker == "lld" || useInternalLLDForLinking() ||
(opts::linker.empty() && isLldDefaultLinker());
addLTOGoldPluginFlags(!isLld);
} else if (global.params.targetTriple->isOSDarwin()) {
addDarwinLTOFlags();
}
// Pass Fat LTO option to LLD
if (isLld && opts::ltoFatObjects) {
addLdFlag("--fat-lto-objects");
}
}
bool ArgsBuilder::isLldDefaultLinker() {