Skip to content

Commit 0bd918c

Browse files
committed
Revert "[ELF] Add --dependency-file option"
This reverts commit b4c7657 which seems to be breaking certain bots with assertion error.
1 parent 9b04fec commit 0bd918c

File tree

5 files changed

+1
-104
lines changed

5 files changed

+1
-104
lines changed

lld/ELF/Config.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include "lld/Common/ErrorHandler.h"
1313
#include "llvm/ADT/MapVector.h"
14-
#include "llvm/ADT/SetVector.h"
1514
#include "llvm/ADT/StringRef.h"
1615
#include "llvm/ADT/StringSet.h"
1716
#include "llvm/BinaryFormat/ELF.h"
@@ -91,13 +90,11 @@ struct Configuration {
9190
uint8_t osabi = 0;
9291
uint32_t andFeatures = 0;
9392
llvm::CachePruningPolicy thinLTOCachePolicy;
94-
llvm::SetVector<StringRef> dependencyFiles; // for --dependency-file
9593
llvm::StringMap<uint64_t> sectionStartMap;
9694
llvm::StringRef bfdname;
9795
llvm::StringRef chroot;
98-
llvm::StringRef dependencyFile;
99-
llvm::StringRef dwoDir;
10096
llvm::StringRef dynamicLinker;
97+
llvm::StringRef dwoDir;
10198
llvm::StringRef entry;
10299
llvm::StringRef emulation;
103100
llvm::StringRef fini;

lld/ELF/Driver.cpp

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,6 @@ static void readConfigs(opt::InputArgList &args) {
918918
config->optimizeBBJumps =
919919
args.hasFlag(OPT_optimize_bb_jumps, OPT_no_optimize_bb_jumps, false);
920920
config->demangle = args.hasFlag(OPT_demangle, OPT_no_demangle, true);
921-
config->dependencyFile = args.getLastArgValue(OPT_dependency_file);
922921
config->dependentLibraries = args.hasFlag(OPT_dependent_libraries, OPT_no_dependent_libraries, true);
923922
config->disableVerify = args.hasArg(OPT_disable_verify);
924923
config->discard = getDiscard(args);
@@ -1565,75 +1564,6 @@ static void handleLibcall(StringRef name) {
15651564
sym->fetch();
15661565
}
15671566

1568-
// Handle --dependency-file=<path>. If that option is given, lld creates a
1569-
// file at a given path with the following contents:
1570-
//
1571-
// <output-file>: <input-file> ...
1572-
//
1573-
// <input-file>:
1574-
//
1575-
// where <output-file> is a pathname of an output file and <input-file>
1576-
// ... is a list of pathnames of all input files. `make` command can read a
1577-
// file in the above format and interpret it as a dependency info. We write
1578-
// phony targets for every <input-file> to avoid an error when that file is
1579-
// removed.
1580-
//
1581-
// This option is useful if you want to make your final executable to depend
1582-
// on all input files including system libraries. Here is why.
1583-
//
1584-
// When you write a Makefile, you usually write it so that the final
1585-
// executable depends on all user-generated object files. Normally, you
1586-
// don't make your executable to depend on system libraries (such as libc)
1587-
// because you don't know the exact paths of libraries, even though system
1588-
// libraries that are linked to your executable statically are technically a
1589-
// part of your program. By using --dependency-file option, you can make
1590-
// lld to dump dependency info so that you can maintain exact dependencies
1591-
// easily.
1592-
static void writeDependencyFile() {
1593-
std::error_code ec;
1594-
raw_fd_ostream os(config->dependencyFile, ec, sys::fs::F_None);
1595-
if (ec) {
1596-
error("cannot open " + config->dependencyFile + ": " + ec.message());
1597-
return;
1598-
}
1599-
1600-
// We use the same escape rules as Clang/GCC which are accepted by Make/Ninja:
1601-
// * A space is escaped by a backslash which itself must be escaped.
1602-
// * A hash sign is escaped by a single backslash.
1603-
// * $ is escapes as $$.
1604-
auto printFilename = [](raw_fd_ostream &os, StringRef filename) {
1605-
llvm::SmallString<256> nativePath;
1606-
llvm::sys::path::native(filename.str(), nativePath);
1607-
llvm::sys::path::remove_dots(nativePath, /*remove_dot_dot=*/true);
1608-
for (unsigned i = 0, e = nativePath.size(); i != e; ++i) {
1609-
if (nativePath[i] == '#') {
1610-
os << '\\';
1611-
} else if (nativePath[i] == ' ') {
1612-
os << '\\';
1613-
unsigned j = i;
1614-
while (j > 0 && nativePath[--j] == '\\')
1615-
os << '\\';
1616-
} else if (nativePath[i] == '$') {
1617-
os << '$';
1618-
}
1619-
os << nativePath[i];
1620-
}
1621-
};
1622-
1623-
os << config->outputFile << ":";
1624-
for (StringRef path : config->dependencyFiles) {
1625-
os << " \\\n ";
1626-
printFilename(os, path);
1627-
}
1628-
os << "\n";
1629-
1630-
for (StringRef path : config->dependencyFiles) {
1631-
os << "\n";
1632-
printFilename(os, path);
1633-
os << ":\n";
1634-
}
1635-
}
1636-
16371567
// Replaces common symbols with defined symbols reside in .bss sections.
16381568
// This function is called after all symbol names are resolved. As a
16391569
// result, the passes after the symbol resolution won't see any
@@ -2134,11 +2064,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
21342064
return false;
21352065
});
21362066

2137-
// Since we now have a complete set of input files, we can create
2138-
// a .d file to record build dependencies.
2139-
if (!config->dependencyFile.empty())
2140-
writeDependencyFile();
2141-
21422067
// Now that the number of partitions is fixed, save a pointer to the main
21432068
// partition.
21442069
mainPart = &partitions[0];

lld/ELF/InputFiles.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ Optional<MemoryBufferRef> elf::readFile(StringRef path) {
110110
path = saver.save(config->chroot + path);
111111

112112
log(path);
113-
config->dependencyFiles.insert(path);
114113

115114
auto mbOrErr = MemoryBuffer::getFile(path, -1, false);
116115
if (auto ec = mbOrErr.getError()) {

lld/ELF/Options.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ defm demangle: B<"demangle",
132132
"Demangle symbol names (default)",
133133
"Do not demangle symbol names">;
134134

135-
defm dependency_file: EEq<"dependency-file", "Write a dependency file">,
136-
MetaVarName<"<path>">;
137-
138135
def disable_new_dtags: F<"disable-new-dtags">,
139136
HelpText<"Disable new dynamic tags">;
140137

lld/test/ELF/dependency-file.s

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)