comparison lld/MachO/Driver.h @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 5f17cb93ff66
children 1f2b6ac9f198
comparison
equal deleted inserted replaced
232:70dce7da266c 236:c4bab56944e8
11 11
12 #include "lld/Common/LLVM.h" 12 #include "lld/Common/LLVM.h"
13 #include "llvm/ADT/Optional.h" 13 #include "llvm/ADT/Optional.h"
14 #include "llvm/ADT/SetVector.h" 14 #include "llvm/ADT/SetVector.h"
15 #include "llvm/ADT/StringRef.h" 15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/BinaryFormat/MachO.h"
16 #include "llvm/Option/OptTable.h" 17 #include "llvm/Option/OptTable.h"
17 #include "llvm/Support/MemoryBuffer.h" 18 #include "llvm/Support/MemoryBuffer.h"
18 19
19 #include <set> 20 #include <set>
20 #include <type_traits> 21 #include <type_traits>
21 22
22 namespace llvm { 23 namespace lld::macho {
23 namespace MachO {
24 class InterfaceFile;
25 enum class PlatformKind : unsigned;
26 } // namespace MachO
27 } // namespace llvm
28
29 namespace lld {
30 namespace macho {
31 24
32 class DylibFile; 25 class DylibFile;
33 class InputFile; 26 class InputFile;
34 27
35 class MachOOptTable : public llvm::opt::OptTable { 28 class MachOOptTable : public llvm::opt::OptTable {
50 void parseLCLinkerOption(InputFile *, unsigned argc, StringRef data); 43 void parseLCLinkerOption(InputFile *, unsigned argc, StringRef data);
51 44
52 std::string createResponseFile(const llvm::opt::InputArgList &args); 45 std::string createResponseFile(const llvm::opt::InputArgList &args);
53 46
54 // Check for both libfoo.dylib and libfoo.tbd (in that order). 47 // Check for both libfoo.dylib and libfoo.tbd (in that order).
55 llvm::Optional<std::string> resolveDylibPath(llvm::StringRef path); 48 llvm::Optional<StringRef> resolveDylibPath(llvm::StringRef path);
56 49
57 DylibFile *loadDylib(llvm::MemoryBufferRef mbref, DylibFile *umbrella = nullptr, 50 DylibFile *loadDylib(llvm::MemoryBufferRef mbref, DylibFile *umbrella = nullptr,
58 bool isBundleLoader = false); 51 bool isBundleLoader = false,
52 bool explicitlyLinked = false);
53 void resetLoadedDylibs();
59 54
60 // Search for all possible combinations of `{root}/{name}.{extension}`. 55 // Search for all possible combinations of `{root}/{name}.{extension}`.
61 // If \p extensions are not specified, then just search for `{root}/{name}`. 56 // If \p extensions are not specified, then just search for `{root}/{name}`.
62 llvm::Optional<llvm::StringRef> 57 llvm::Optional<llvm::StringRef>
63 findPathCombination(const llvm::Twine &name, 58 findPathCombination(const llvm::Twine &name,
66 61
67 // If -syslibroot is specified, absolute paths to non-object files may be 62 // If -syslibroot is specified, absolute paths to non-object files may be
68 // rerooted. 63 // rerooted.
69 llvm::StringRef rerootPath(llvm::StringRef path); 64 llvm::StringRef rerootPath(llvm::StringRef path);
70 65
71 llvm::Optional<InputFile *> loadArchiveMember(MemoryBufferRef, uint32_t modTime,
72 StringRef archiveName,
73 bool objCOnly);
74
75 uint32_t getModTime(llvm::StringRef path); 66 uint32_t getModTime(llvm::StringRef path);
76 67
77 void printArchiveMemberLoad(StringRef reason, const InputFile *); 68 void printArchiveMemberLoad(StringRef reason, const InputFile *);
78 69
79 // Map simulator platforms to their underlying device platform. 70 // Map simulator platforms to their underlying device platform.
80 llvm::MachO::PlatformKind removeSimulator(llvm::MachO::PlatformKind platform); 71 llvm::MachO::PlatformType removeSimulator(llvm::MachO::PlatformType platform);
81 72
82 // Helper class to export dependency info. 73 // Helper class to export dependency info.
83 class DependencyTracker { 74 class DependencyTracker {
84 public: 75 public:
85 explicit DependencyTracker(llvm::StringRef path); 76 explicit DependencyTracker(llvm::StringRef path);
88 inline void logFileNotFound(const Twine &path) { 79 inline void logFileNotFound(const Twine &path) {
89 if (active) 80 if (active)
90 notFounds.insert(path.str()); 81 notFounds.insert(path.str());
91 } 82 }
92 83
93 // Writes the dependencies to specified path. 84 // Writes the dependencies to specified path. The content is first sorted by
94 // The content is sorted by its Op Code, then within each section, 85 // OpCode and then by the filename (in alphabetical order).
95 // alphabetical order.
96 void write(llvm::StringRef version, 86 void write(llvm::StringRef version,
97 const llvm::SetVector<InputFile *> &inputs, 87 const llvm::SetVector<InputFile *> &inputs,
98 llvm::StringRef output); 88 llvm::StringRef output);
99 89
100 private: 90 private:
116 // We need to own the paths because some of them are temporarily 106 // We need to own the paths because some of them are temporarily
117 // constructed. 107 // constructed.
118 std::set<std::string> notFounds; 108 std::set<std::string> notFounds;
119 }; 109 };
120 110
121 extern DependencyTracker *depTracker; 111 extern std::unique_ptr<DependencyTracker> depTracker;
122 112
123 } // namespace macho 113 } // namespace lld::macho
124 } // namespace lld
125 114
126 #endif 115 #endif