aboutsummaryrefslogtreecommitdiff
path: root/lld/COFF/Driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/COFF/Driver.cpp')
-rw-r--r--lld/COFF/Driver.cpp68
1 files changed, 37 insertions, 31 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 283aeed..570b8f9 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -274,8 +274,13 @@ void LinkerDriver::addBuffer(std::unique_ptr<MemoryBuffer> mb,
make<std::unique_ptr<Archive>>(std::move(file)); // take ownership
int memberIndex = 0;
- for (MemoryBufferRef m : getArchiveMembers(ctx, archive))
- addArchiveBuffer(m, "<whole-archive>", filename, memberIndex++);
+ for (MemoryBufferRef m : getArchiveMembers(ctx, archive)) {
+ if (!archive->isThin())
+ addArchiveBuffer(m, "<whole-archive>", filename, memberIndex++);
+ else
+ addThinArchiveBuffer(m, "<whole-archive>");
+ }
+
return;
}
addFile(make<ArchiveFile>(ctx, mbref));
@@ -386,6 +391,14 @@ void LinkerDriver::addArchiveBuffer(MemoryBufferRef mb, StringRef symName,
Log(ctx) << "Loaded " << obj << " for " << symName;
}
+void LinkerDriver::addThinArchiveBuffer(MemoryBufferRef mb, StringRef symName) {
+ // Pass an empty string as the archive name and an offset of 0 so that
+ // the original filename is used as the buffer identifier. This is
+ // useful for DTLTO, where having the member identifier be the actual
+ // path on disk enables distribution of bitcode files during ThinLTO.
+ addArchiveBuffer(mb, symName, /*parentName=*/"", /*OffsetInArchive=*/0);
+}
+
void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
const Archive::Symbol &sym,
StringRef parentName) {
@@ -422,11 +435,8 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
reportBufferError(errorCodeToError(mbOrErr.second), childName);
llvm::TimeTraceScope timeScope("Archive: ",
mbOrErr.first->getBufferIdentifier());
- // Pass empty string as archive name so that the original filename is
- // used as the buffer identifier.
- ctx.driver.addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)),
- toCOFFString(ctx, sym), "",
- /*OffsetInArchive=*/0);
+ ctx.driver.addThinArchiveBuffer(takeBuffer(std::move(mbOrErr.first)),
+ toCOFFString(ctx, sym));
});
}
@@ -1643,8 +1653,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
config->warnLocallyDefinedImported = false;
else if (s == "longsections")
config->warnLongSectionNames = false;
- else if (s == "exporteddllmain")
- config->warnExportedDllMain = false;
+ else if (s == "importeddllmain")
+ config->warnImportedDllMain = false;
// Other warning numbers are ignored.
}
}
@@ -2088,6 +2098,23 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
Fatal(ctx) << "/manifestinput: requires /manifest:embed";
}
+ // Handle /thinlto-distributor:<path>
+ config->dtltoDistributor = args.getLastArgValue(OPT_thinlto_distributor);
+
+ // Handle /thinlto-distributor-arg:<arg>
+ for (auto *arg : args.filtered(OPT_thinlto_distributor_arg))
+ config->dtltoDistributorArgs.push_back(arg->getValue());
+
+ // Handle /thinlto-remote-compiler:<path>
+ config->dtltoCompiler = args.getLastArgValue(OPT_thinlto_compiler);
+ if (!config->dtltoDistributor.empty() && config->dtltoCompiler.empty())
+ Err(ctx) << "A value must be specified for /thinlto-remote-compiler if "
+ "/thinlto-distributor is specified.";
+
+ // Handle /thinlto-remote-compiler-arg:<arg>
+ for (auto *arg : args.filtered(OPT_thinlto_compiler_arg))
+ config->dtltoCompilerArgs.push_back(arg->getValue());
+
// Handle /dwodir
config->dwoDir = args.getLastArgValue(OPT_dwodir);
@@ -2527,28 +2554,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
e.symbolName = symtab.mangleMaybe(e.sym);
}
- // Add weak aliases. Weak aliases is a mechanism to give remaining
- // undefined symbols final chance to be resolved successfully.
- for (auto pair : symtab.alternateNames) {
- StringRef from = pair.first;
- StringRef to = pair.second;
- Symbol *sym = symtab.find(from);
- if (!sym)
- continue;
- if (auto *u = dyn_cast<Undefined>(sym)) {
- if (u->weakAlias) {
- // On ARM64EC, anti-dependency aliases are treated as undefined
- // symbols unless a demangled symbol aliases a defined one, which
- // is part of the implementation.
- if (!symtab.isEC() || !u->isAntiDep)
- continue;
- if (!isa<Undefined>(u->weakAlias) &&
- !isArm64ECMangledFunctionName(u->getName()))
- continue;
- }
- u->setWeakAlias(symtab.addUndefined(to));
- }
- }
+ symtab.resolveAlternateNames();
});
ctx.forEachActiveSymtab([&](SymbolTable &symtab) {