Skip to content

Commit 9670d2e

Browse files
committed
Revert "Revert "Revert "[lld-macho] Implement -dependency_info (partially - more opcodes needed)"""
This reverts commit 5ad2c22. bots still unhappy - revertting again
1 parent 5ad2c22 commit 9670d2e

File tree

6 files changed

+3
-191
lines changed

6 files changed

+3
-191
lines changed

lld/MachO/Driver.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ using namespace llvm::sys;
5454
using namespace lld;
5555
using namespace lld::macho;
5656

57-
Configuration *macho::config;
58-
DependencyTracker *macho::depTracker;
57+
Configuration *lld::macho::config;
5958

6059
static HeaderFileType getOutputType(const InputArgList &args) {
6160
// TODO: -r, -dylinker, -preload...
@@ -85,8 +84,6 @@ findAlongPathsWithExtensions(StringRef name, ArrayRef<StringRef> extensions) {
8584
Twine location = base + ext;
8685
if (fs::exists(location))
8786
return location.str();
88-
else
89-
depTracker->logFileNotFound(location);
9087
}
9188
}
9289
return {};
@@ -818,9 +815,6 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
818815
symtab = make<SymbolTable>();
819816
target = createTargetInfo(args);
820817

821-
depTracker =
822-
make<DependencyTracker>(args.getLastArgValue(OPT_dependency_info, ""));
823-
824818
config->entry = symtab->addUndefined(args.getLastArgValue(OPT_e, "_main"),
825819
/*file=*/nullptr,
826820
/*isWeakRef=*/false);
@@ -1072,8 +1066,6 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
10721066

10731067
// Write to an output file.
10741068
writeResult();
1075-
1076-
depTracker->write(getLLDVersion(), inputFiles, config->outputFile);
10771069
}
10781070

10791071
if (config->timeTraceEnabled) {

lld/MachO/Driver.h

-50
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111

1212
#include "lld/Common/LLVM.h"
1313
#include "llvm/ADT/Optional.h"
14-
#include "llvm/ADT/SetVector.h"
1514
#include "llvm/ADT/StringRef.h"
1615
#include "llvm/Option/OptTable.h"
1716
#include "llvm/Support/MemoryBuffer.h"
1817

19-
#include <set>
20-
#include <type_traits>
21-
2218
namespace llvm {
2319
namespace MachO {
2420
class InterfaceFile;
@@ -65,52 +61,6 @@ uint32_t getModTime(llvm::StringRef path);
6561

6662
void printArchiveMemberLoad(StringRef reason, const InputFile *);
6763

68-
// Helper class to export dependency info.
69-
class DependencyTracker {
70-
public:
71-
explicit DependencyTracker(llvm::StringRef path);
72-
73-
// Adds the given path to the set of not-found files.
74-
inline void logFileNotFound(std::string path) {
75-
if (active)
76-
notFounds.insert(std::move(path));
77-
}
78-
79-
inline void logFileNotFound(const Twine &path) {
80-
if (active)
81-
notFounds.insert(path.str());
82-
}
83-
84-
// Writes the dependencies to specified path.
85-
// The content is sorted by its Op Code, then within each section,
86-
// alphabetical order.
87-
void write(llvm::StringRef version,
88-
const llvm::SetVector<InputFile *> &inputs,
89-
llvm::StringRef output);
90-
91-
private:
92-
enum DepOpCode : char {
93-
// Denotes the linker version.
94-
Version = 0x00,
95-
// Denotes the input files.
96-
Input = 0x10,
97-
// Denotes the files that do not exist(?)
98-
NotFound = 0x11,
99-
// Denotes the output files.
100-
Output = 0x40,
101-
};
102-
103-
const llvm::StringRef path;
104-
bool active;
105-
106-
// The paths need to be alphabetically ordered.
107-
// We need to own the paths because some of them are temporarily
108-
// constructed.
109-
std::set<std::string> notFounds;
110-
};
111-
112-
extern DependencyTracker *depTracker;
113-
11464
} // namespace macho
11565
} // namespace lld
11666

lld/MachO/DriverUtils.cpp

+1-51
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "llvm/Option/ArgList.h"
2424
#include "llvm/Option/Option.h"
2525
#include "llvm/Support/CommandLine.h"
26-
#include "llvm/Support/FileSystem.h"
2726
#include "llvm/Support/Path.h"
2827
#include "llvm/TextAPI/MachO/InterfaceFile.h"
2928
#include "llvm/TextAPI/MachO/TextAPIReader.h"
@@ -165,15 +164,12 @@ Optional<std::string> macho::resolveDylibPath(StringRef path) {
165164
// they are consistent.
166165
if (fs::exists(path))
167166
return std::string(path);
168-
else
169-
depTracker->logFileNotFound(path);
170167

171168
SmallString<261> location = path;
172169
path::replace_extension(location, ".tbd");
173170
if (fs::exists(location))
174171
return std::string(location);
175-
else
176-
depTracker->logFileNotFound(location);
172+
177173
return {};
178174
}
179175

@@ -244,49 +240,3 @@ void macho::printArchiveMemberLoad(StringRef reason, const InputFile *f) {
244240
if (config->printWhyLoad)
245241
message(reason + " forced load of " + toString(f));
246242
}
247-
248-
macho::DependencyTracker::DependencyTracker(StringRef path)
249-
: path(path), active(!path.empty()) {
250-
if (active && fs::exists(path) && !fs::can_write(path)) {
251-
warn("Ignoring dependency_info option since specified path is not "
252-
"writeable.");
253-
active = false;
254-
}
255-
}
256-
257-
void macho::DependencyTracker::write(llvm::StringRef version,
258-
const llvm::SetVector<InputFile *> &inputs,
259-
llvm::StringRef output) {
260-
if (!active)
261-
return;
262-
263-
std::error_code ec;
264-
llvm::raw_fd_ostream os(path, ec, llvm::sys::fs::OF_None);
265-
if (ec) {
266-
warn("Error writing dependency info to file");
267-
return;
268-
}
269-
270-
auto addDep = [&os](DepOpCode opcode, const StringRef &path) {
271-
os << opcode;
272-
os << path;
273-
os << '\0';
274-
};
275-
276-
addDep(DepOpCode::Version, version);
277-
278-
// Sort the input by its names.
279-
std::vector<StringRef> inputNames;
280-
inputNames.reserve(inputs.size());
281-
for (InputFile *f : inputs)
282-
inputNames.push_back(f->getName());
283-
llvm::sort(inputNames,
284-
[](const StringRef &a, const StringRef &b) { return a < b; });
285-
for (const StringRef &in : inputNames)
286-
addDep(DepOpCode::Input, in);
287-
288-
for (const std::string &f : notFounds)
289-
addDep(DepOpCode::NotFound, f);
290-
291-
addDep(DepOpCode::Output, output);
292-
}

lld/MachO/Options.td

+1
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ def map : Separate<["-"], "map">,
504504
def dependency_info : Separate<["-"], "dependency_info">,
505505
MetaVarName<"<path>">,
506506
HelpText<"Dump dependency info">,
507+
Flags<[HelpHidden]>,
507508
Group<grp_introspect>;
508509
def save_temps : Flag<["-"], "save-temps">,
509510
HelpText<"Save intermediate LTO compilation results">,

lld/test/MachO/Inputs/DependencyDump.py

-26
This file was deleted.

lld/test/MachO/dependency-info.s

-55
This file was deleted.

0 commit comments

Comments
 (0)