Skip to content

Commit 2554b95

Browse files
committed
Revert "[lld-macho] Implement -dependency_info (partially - more opcodes needed)"
This reverts commit c53a132. Test only passes depending on build dir having a lexicographically later name than the source dir, and doesn't link on mac/win. See https://reviews.llvm.org/D98559#2640265 onward.
1 parent be87321 commit 2554b95

File tree

6 files changed

+3
-190
lines changed

6 files changed

+3
-190
lines changed

lld/MachO/Driver.cpp

Lines changed: 1 addition & 9 deletions
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

Lines changed: 0 additions & 43 deletions
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,45 +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-
void logFileNotFound(std::string);
75-
void logFileNotFound(const llvm::Twine &path);
76-
77-
// Writes the dependencies to specified path.
78-
// The content is sorted by its Op Code, then within each section,
79-
// alphabetical order.
80-
void write(llvm::StringRef version,
81-
const llvm::SetVector<InputFile *> &inputs,
82-
llvm::StringRef output);
83-
84-
private:
85-
enum DepOpCode : char {
86-
// Denotes the linker version.
87-
Version = 0x00,
88-
// Denotes the input files.
89-
Input = 0x10,
90-
// Denotes the files that do not exist(?)
91-
NotFound = 0x11,
92-
// Denotes the output files.
93-
Output = 0x40,
94-
};
95-
96-
const llvm::StringRef path;
97-
bool active;
98-
99-
// The paths need to be alphabetically ordered.
100-
// We need to own the paths because some of them are temporarily
101-
// constructed.
102-
std::set<std::string> notFounds;
103-
};
104-
105-
extern DependencyTracker *depTracker;
106-
10764
} // namespace macho
10865
} // namespace lld
10966

lld/MachO/DriverUtils.cpp

Lines changed: 1 addition & 61 deletions
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,59 +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-
inline void macho::DependencyTracker::logFileNotFound(std::string path) {
258-
if (active)
259-
notFounds.insert(std::move(path));
260-
}
261-
262-
inline void macho::DependencyTracker::logFileNotFound(const Twine &path) {
263-
if (active)
264-
notFounds.insert(path.str());
265-
}
266-
267-
void macho::DependencyTracker::write(llvm::StringRef version,
268-
const llvm::SetVector<InputFile *> &inputs,
269-
llvm::StringRef output) {
270-
if (!active)
271-
return;
272-
273-
std::error_code ec;
274-
llvm::raw_fd_ostream os(path, ec, llvm::sys::fs::OF_None);
275-
if (ec) {
276-
warn("Error writing dependency info to file");
277-
return;
278-
}
279-
280-
auto addDep = [&os](DepOpCode opcode, const StringRef &path) {
281-
os << opcode;
282-
os << path;
283-
os << '\0';
284-
};
285-
286-
addDep(DepOpCode::Version, version);
287-
288-
// Sort the input by its names.
289-
std::vector<StringRef> inputNames;
290-
inputNames.reserve(inputs.size());
291-
for (InputFile *f : inputs)
292-
inputNames.push_back(f->getName());
293-
llvm::sort(inputNames,
294-
[](const StringRef &a, const StringRef &b) { return a < b; });
295-
for (const StringRef &in : inputNames)
296-
addDep(DepOpCode::Input, in);
297-
298-
for (const std::string &f : notFounds)
299-
addDep(DepOpCode::NotFound, f);
300-
301-
addDep(DepOpCode::Output, output);
302-
}

lld/MachO/Options.td

Lines changed: 1 addition & 0 deletions
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

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

lld/test/MachO/dependency-info.s

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

0 commit comments

Comments
 (0)