aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/Driver.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-02-18 22:37:06 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-02-18 22:37:06 +0000
commit7eff647615f93a9aaff1997e1880b195dc3aabe6 (patch)
treeae348c384d518be05d73326fbfc22a1f66eb56d0 /lld/ELF/Driver.cpp
parent1e9a9d6d056506b23ad26952df45eaac949385c7 (diff)
Diffstat (limited to 'lld/ELF/Driver.cpp')
-rw-r--r--lld/ELF/Driver.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 406571e4e9fd..54b487bdc243 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -235,22 +235,28 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
// user is attempting LTO and using a default ar command that doesn't
// understand the LLVM bitcode file. Treat the archive as a group of lazy
// object files.
- if (!file->isEmpty() && !file->hasSymbolTable()) {
- for (const std::pair<MemoryBufferRef, uint64_t> &p :
- getArchiveMembers(mbref)) {
- auto magic = identify_magic(p.first.getBuffer());
- if (magic == file_magic::bitcode ||
- magic == file_magic::elf_relocatable)
- files.push_back(createLazyFile(p.first, path, p.second));
- else
- error(path + ": archive member '" + p.first.getBufferIdentifier() +
- "' is neither ET_REL nor LLVM bitcode");
- }
+ if (file->isEmpty() || file->hasSymbolTable()) {
+ // Handle the regular case.
+ files.push_back(make<ArchiveFile>(std::move(file)));
return;
}
- // Handle the regular case.
- files.push_back(make<ArchiveFile>(std::move(file)));
+ // All files within the archive get the same group ID to allow mutual
+ // references for --warn-backrefs.
+ bool saved = InputFile::isInGroup;
+ InputFile::isInGroup = true;
+ for (const std::pair<MemoryBufferRef, uint64_t> &p :
+ getArchiveMembers(mbref)) {
+ auto magic = identify_magic(p.first.getBuffer());
+ if (magic == file_magic::bitcode || magic == file_magic::elf_relocatable)
+ files.push_back(createLazyFile(p.first, path, p.second));
+ else
+ error(path + ": archive member '" + p.first.getBufferIdentifier() +
+ "' is neither ET_REL nor LLVM bitcode");
+ }
+ InputFile::isInGroup = saved;
+ if (!saved)
+ ++InputFile::nextGroupId;
return;
}
case file_magic::elf_shared_object:
@@ -1234,6 +1240,9 @@ static void readConfigs(opt::InputArgList &args) {
error(errPrefix + toString(pat.takeError()));
}
+ if (args.hasArg(OPT_define_common, OPT_no_define_common))
+ warn("-d, -dc, -dp, and --[no-]define-common will be removed. See https://github.com/llvm/llvm-project/issues/53660");
+
cl::ResetAllOptionOccurrences();
// Parse LTO options.