1e8d8bef9SDimitry Andric //===- DriverUtils.cpp ----------------------------------------------------===// 2e8d8bef9SDimitry Andric // 3e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e8d8bef9SDimitry Andric // 7e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===// 8e8d8bef9SDimitry Andric 9e8d8bef9SDimitry Andric #include "Config.h" 10fe6060f1SDimitry Andric #include "Driver.h" 11e8d8bef9SDimitry Andric #include "InputFiles.h" 12fe6060f1SDimitry Andric #include "ObjC.h" 13fe6060f1SDimitry Andric #include "Target.h" 14e8d8bef9SDimitry Andric 15e8d8bef9SDimitry Andric #include "lld/Common/Args.h" 1604eeddc0SDimitry Andric #include "lld/Common/CommonLinkerContext.h" 17e8d8bef9SDimitry Andric #include "lld/Common/Reproduce.h" 18e8d8bef9SDimitry Andric #include "llvm/ADT/CachedHashString.h" 19e8d8bef9SDimitry Andric #include "llvm/ADT/DenseMap.h" 20fe6060f1SDimitry Andric #include "llvm/LTO/LTO.h" 21e8d8bef9SDimitry Andric #include "llvm/Option/Arg.h" 22e8d8bef9SDimitry Andric #include "llvm/Option/ArgList.h" 23e8d8bef9SDimitry Andric #include "llvm/Option/Option.h" 24e8d8bef9SDimitry Andric #include "llvm/Support/CommandLine.h" 25fe6060f1SDimitry Andric #include "llvm/Support/FileSystem.h" 26e8d8bef9SDimitry Andric #include "llvm/Support/Path.h" 27fe6060f1SDimitry Andric #include "llvm/TextAPI/InterfaceFile.h" 28fe6060f1SDimitry Andric #include "llvm/TextAPI/TextAPIReader.h" 29e8d8bef9SDimitry Andric 30e8d8bef9SDimitry Andric using namespace llvm; 31e8d8bef9SDimitry Andric using namespace llvm::MachO; 32e8d8bef9SDimitry Andric using namespace llvm::opt; 33e8d8bef9SDimitry Andric using namespace llvm::sys; 34e8d8bef9SDimitry Andric using namespace lld; 35e8d8bef9SDimitry Andric using namespace lld::macho; 36e8d8bef9SDimitry Andric 37e8d8bef9SDimitry Andric // Create prefix string literals used in Options.td 38bdd1243dSDimitry Andric #define PREFIX(NAME, VALUE) \ 39bdd1243dSDimitry Andric static constexpr StringLiteral NAME##_init[] = VALUE; \ 40bdd1243dSDimitry Andric static constexpr ArrayRef<StringLiteral> NAME(NAME##_init, \ 41bdd1243dSDimitry Andric std::size(NAME##_init) - 1); 42e8d8bef9SDimitry Andric #include "Options.inc" 43e8d8bef9SDimitry Andric #undef PREFIX 44e8d8bef9SDimitry Andric 45e8d8bef9SDimitry Andric // Create table mapping all options defined in Options.td 46bdd1243dSDimitry Andric static constexpr OptTable::Info optInfo[] = { 47*5f757f3fSDimitry Andric #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \ 48*5f757f3fSDimitry Andric VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \ 49*5f757f3fSDimitry Andric {PREFIX, NAME, HELPTEXT, \ 50*5f757f3fSDimitry Andric METAVAR, OPT_##ID, opt::Option::KIND##Class, \ 51*5f757f3fSDimitry Andric PARAM, FLAGS, VISIBILITY, \ 52*5f757f3fSDimitry Andric OPT_##GROUP, OPT_##ALIAS, ALIASARGS, \ 53*5f757f3fSDimitry Andric VALUES}, 54e8d8bef9SDimitry Andric #include "Options.inc" 55e8d8bef9SDimitry Andric #undef OPTION 56e8d8bef9SDimitry Andric }; 57e8d8bef9SDimitry Andric 58bdd1243dSDimitry Andric MachOOptTable::MachOOptTable() : GenericOptTable(optInfo) {} 59e8d8bef9SDimitry Andric 60e8d8bef9SDimitry Andric // Set color diagnostics according to --color-diagnostics={auto,always,never} 61e8d8bef9SDimitry Andric // or --no-color-diagnostics flags. 62fe6060f1SDimitry Andric static void handleColorDiagnostics(InputArgList &args) { 63fe6060f1SDimitry Andric const Arg *arg = 64fe6060f1SDimitry Andric args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq, 65e8d8bef9SDimitry Andric OPT_no_color_diagnostics); 66e8d8bef9SDimitry Andric if (!arg) 67e8d8bef9SDimitry Andric return; 68e8d8bef9SDimitry Andric if (arg->getOption().getID() == OPT_color_diagnostics) { 69e8d8bef9SDimitry Andric lld::errs().enable_colors(true); 70e8d8bef9SDimitry Andric } else if (arg->getOption().getID() == OPT_no_color_diagnostics) { 71e8d8bef9SDimitry Andric lld::errs().enable_colors(false); 72e8d8bef9SDimitry Andric } else { 73e8d8bef9SDimitry Andric StringRef s = arg->getValue(); 74e8d8bef9SDimitry Andric if (s == "always") 75e8d8bef9SDimitry Andric lld::errs().enable_colors(true); 76e8d8bef9SDimitry Andric else if (s == "never") 77e8d8bef9SDimitry Andric lld::errs().enable_colors(false); 78e8d8bef9SDimitry Andric else if (s != "auto") 79e8d8bef9SDimitry Andric error("unknown option: --color-diagnostics=" + s); 80e8d8bef9SDimitry Andric } 81e8d8bef9SDimitry Andric } 82e8d8bef9SDimitry Andric 83fe6060f1SDimitry Andric InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) { 84e8d8bef9SDimitry Andric // Make InputArgList from string vectors. 85e8d8bef9SDimitry Andric unsigned missingIndex; 86e8d8bef9SDimitry Andric unsigned missingCount; 87e8d8bef9SDimitry Andric SmallVector<const char *, 256> vec(argv.data(), argv.data() + argv.size()); 88e8d8bef9SDimitry Andric 89e8d8bef9SDimitry Andric // Expand response files (arguments in the form of @<filename>) 90e8d8bef9SDimitry Andric // and then parse the argument again. 9104eeddc0SDimitry Andric cl::ExpandResponseFiles(saver(), cl::TokenizeGNUCommandLine, vec); 92fe6060f1SDimitry Andric InputArgList args = ParseArgs(vec, missingIndex, missingCount); 93e8d8bef9SDimitry Andric 94e8d8bef9SDimitry Andric // Handle -fatal_warnings early since it converts missing argument warnings 95e8d8bef9SDimitry Andric // to errors. 96e8d8bef9SDimitry Andric errorHandler().fatalWarnings = args.hasArg(OPT_fatal_warnings); 9781ad6265SDimitry Andric errorHandler().suppressWarnings = args.hasArg(OPT_w); 98e8d8bef9SDimitry Andric 99e8d8bef9SDimitry Andric if (missingCount) 100e8d8bef9SDimitry Andric error(Twine(args.getArgString(missingIndex)) + ": missing argument"); 101e8d8bef9SDimitry Andric 102e8d8bef9SDimitry Andric handleColorDiagnostics(args); 103e8d8bef9SDimitry Andric 104fe6060f1SDimitry Andric for (const Arg *arg : args.filtered(OPT_UNKNOWN)) { 105e8d8bef9SDimitry Andric std::string nearest; 106e8d8bef9SDimitry Andric if (findNearest(arg->getAsString(args), nearest) > 1) 107e8d8bef9SDimitry Andric error("unknown argument '" + arg->getAsString(args) + "'"); 108e8d8bef9SDimitry Andric else 109e8d8bef9SDimitry Andric error("unknown argument '" + arg->getAsString(args) + 110e8d8bef9SDimitry Andric "', did you mean '" + nearest + "'"); 111e8d8bef9SDimitry Andric } 112e8d8bef9SDimitry Andric return args; 113e8d8bef9SDimitry Andric } 114e8d8bef9SDimitry Andric 115e8d8bef9SDimitry Andric void MachOOptTable::printHelp(const char *argv0, bool showHidden) const { 116fe6060f1SDimitry Andric OptTable::printHelp(lld::outs(), 117fe6060f1SDimitry Andric (std::string(argv0) + " [options] file...").c_str(), 118e8d8bef9SDimitry Andric "LLVM Linker", showHidden); 119e8d8bef9SDimitry Andric lld::outs() << "\n"; 120e8d8bef9SDimitry Andric } 121e8d8bef9SDimitry Andric 122e8d8bef9SDimitry Andric static std::string rewritePath(StringRef s) { 123e8d8bef9SDimitry Andric if (fs::exists(s)) 124e8d8bef9SDimitry Andric return relativeToRoot(s); 125e8d8bef9SDimitry Andric return std::string(s); 126e8d8bef9SDimitry Andric } 127e8d8bef9SDimitry Andric 128fe6060f1SDimitry Andric static std::string rewriteInputPath(StringRef s) { 129fe6060f1SDimitry Andric // Don't bother rewriting "absolute" paths that are actually under the 130fe6060f1SDimitry Andric // syslibroot; simply rewriting the syslibroot is sufficient. 131fe6060f1SDimitry Andric if (rerootPath(s) == s && fs::exists(s)) 132fe6060f1SDimitry Andric return relativeToRoot(s); 133fe6060f1SDimitry Andric return std::string(s); 134fe6060f1SDimitry Andric } 135fe6060f1SDimitry Andric 136e8d8bef9SDimitry Andric // Reconstructs command line arguments so that so that you can re-run 137e8d8bef9SDimitry Andric // the same command with the same inputs. This is for --reproduce. 138fe6060f1SDimitry Andric std::string macho::createResponseFile(const InputArgList &args) { 139e8d8bef9SDimitry Andric SmallString<0> data; 140e8d8bef9SDimitry Andric raw_svector_ostream os(data); 141e8d8bef9SDimitry Andric 142e8d8bef9SDimitry Andric // Copy the command line to the output while rewriting paths. 143fe6060f1SDimitry Andric for (const Arg *arg : args) { 144e8d8bef9SDimitry Andric switch (arg->getOption().getID()) { 145e8d8bef9SDimitry Andric case OPT_reproduce: 146e8d8bef9SDimitry Andric break; 147e8d8bef9SDimitry Andric case OPT_INPUT: 148fe6060f1SDimitry Andric os << quote(rewriteInputPath(arg->getValue())) << "\n"; 149e8d8bef9SDimitry Andric break; 150e8d8bef9SDimitry Andric case OPT_o: 151e8d8bef9SDimitry Andric os << "-o " << quote(path::filename(arg->getValue())) << "\n"; 152e8d8bef9SDimitry Andric break; 153e8d8bef9SDimitry Andric case OPT_filelist: 154bdd1243dSDimitry Andric if (std::optional<MemoryBufferRef> buffer = readFile(arg->getValue())) 155e8d8bef9SDimitry Andric for (StringRef path : args::getLines(*buffer)) 156fe6060f1SDimitry Andric os << quote(rewriteInputPath(path)) << "\n"; 157e8d8bef9SDimitry Andric break; 158e8d8bef9SDimitry Andric case OPT_force_load: 159fe6060f1SDimitry Andric case OPT_weak_library: 160972a253aSDimitry Andric case OPT_load_hidden: 161fe6060f1SDimitry Andric os << arg->getSpelling() << " " 162fe6060f1SDimitry Andric << quote(rewriteInputPath(arg->getValue())) << "\n"; 163fe6060f1SDimitry Andric break; 164e8d8bef9SDimitry Andric case OPT_F: 165e8d8bef9SDimitry Andric case OPT_L: 166fe6060f1SDimitry Andric case OPT_bundle_loader: 167fe6060f1SDimitry Andric case OPT_exported_symbols_list: 168e8d8bef9SDimitry Andric case OPT_order_file: 169fe6060f1SDimitry Andric case OPT_syslibroot: 170fe6060f1SDimitry Andric case OPT_unexported_symbols_list: 171e8d8bef9SDimitry Andric os << arg->getSpelling() << " " << quote(rewritePath(arg->getValue())) 172e8d8bef9SDimitry Andric << "\n"; 173e8d8bef9SDimitry Andric break; 174e8d8bef9SDimitry Andric case OPT_sectcreate: 175e8d8bef9SDimitry Andric os << arg->getSpelling() << " " << quote(arg->getValue(0)) << " " 176e8d8bef9SDimitry Andric << quote(arg->getValue(1)) << " " 177e8d8bef9SDimitry Andric << quote(rewritePath(arg->getValue(2))) << "\n"; 178e8d8bef9SDimitry Andric break; 179e8d8bef9SDimitry Andric default: 180e8d8bef9SDimitry Andric os << toString(*arg) << "\n"; 181e8d8bef9SDimitry Andric } 182e8d8bef9SDimitry Andric } 183e8d8bef9SDimitry Andric return std::string(data.str()); 184e8d8bef9SDimitry Andric } 185e8d8bef9SDimitry Andric 186fe6060f1SDimitry Andric static void searchedDylib(const Twine &path, bool found) { 187fe6060f1SDimitry Andric if (config->printDylibSearch) 188fe6060f1SDimitry Andric message("searched " + path + (found ? ", found " : ", not found")); 189fe6060f1SDimitry Andric if (!found) 190fe6060f1SDimitry Andric depTracker->logFileNotFound(path); 191fe6060f1SDimitry Andric } 192fe6060f1SDimitry Andric 193bdd1243dSDimitry Andric std::optional<StringRef> macho::resolveDylibPath(StringRef dylibPath) { 194e8d8bef9SDimitry Andric // TODO: if a tbd and dylib are both present, we should check to make sure 195e8d8bef9SDimitry Andric // they are consistent. 196fe6060f1SDimitry Andric SmallString<261> tbdPath = dylibPath; 197fe6060f1SDimitry Andric path::replace_extension(tbdPath, ".tbd"); 198fe6060f1SDimitry Andric bool tbdExists = fs::exists(tbdPath); 199fe6060f1SDimitry Andric searchedDylib(tbdPath, tbdExists); 200fe6060f1SDimitry Andric if (tbdExists) 20104eeddc0SDimitry Andric return saver().save(tbdPath.str()); 202349cc55cSDimitry Andric 203349cc55cSDimitry Andric bool dylibExists = fs::exists(dylibPath); 204349cc55cSDimitry Andric searchedDylib(dylibPath, dylibExists); 205349cc55cSDimitry Andric if (dylibExists) 20604eeddc0SDimitry Andric return saver().save(dylibPath); 207e8d8bef9SDimitry Andric return {}; 208e8d8bef9SDimitry Andric } 209e8d8bef9SDimitry Andric 210e8d8bef9SDimitry Andric // It's not uncommon to have multiple attempts to load a single dylib, 211e8d8bef9SDimitry Andric // especially if it's a commonly re-exported core library. 212e8d8bef9SDimitry Andric static DenseMap<CachedHashStringRef, DylibFile *> loadedDylibs; 213e8d8bef9SDimitry Andric 214fe6060f1SDimitry Andric DylibFile *macho::loadDylib(MemoryBufferRef mbref, DylibFile *umbrella, 21581ad6265SDimitry Andric bool isBundleLoader, bool explicitlyLinked) { 216fe6060f1SDimitry Andric CachedHashStringRef path(mbref.getBufferIdentifier()); 217fe6060f1SDimitry Andric DylibFile *&file = loadedDylibs[path]; 21881ad6265SDimitry Andric if (file) { 21981ad6265SDimitry Andric if (explicitlyLinked) 22061cfbce3SDimitry Andric file->setExplicitlyLinked(); 221e8d8bef9SDimitry Andric return file; 22281ad6265SDimitry Andric } 223e8d8bef9SDimitry Andric 224fe6060f1SDimitry Andric DylibFile *newFile; 225e8d8bef9SDimitry Andric file_magic magic = identify_magic(mbref.getBuffer()); 226e8d8bef9SDimitry Andric if (magic == file_magic::tapi_file) { 227e8d8bef9SDimitry Andric Expected<std::unique_ptr<InterfaceFile>> result = TextAPIReader::get(mbref); 228e8d8bef9SDimitry Andric if (!result) { 229e8d8bef9SDimitry Andric error("could not load TAPI file at " + mbref.getBufferIdentifier() + 230e8d8bef9SDimitry Andric ": " + toString(result.takeError())); 231fe6060f1SDimitry Andric return nullptr; 232e8d8bef9SDimitry Andric } 23381ad6265SDimitry Andric file = 23481ad6265SDimitry Andric make<DylibFile>(**result, umbrella, isBundleLoader, explicitlyLinked); 235fe6060f1SDimitry Andric 236fe6060f1SDimitry Andric // parseReexports() can recursively call loadDylib(). That's fine since 237fe6060f1SDimitry Andric // we wrote the DylibFile we just loaded to the loadDylib cache via the 238fe6060f1SDimitry Andric // `file` reference. But the recursive load can grow loadDylibs, so the 239fe6060f1SDimitry Andric // `file` reference might become invalid after parseReexports() -- so copy 240fe6060f1SDimitry Andric // the pointer it refers to before continuing. 241fe6060f1SDimitry Andric newFile = file; 242fe6060f1SDimitry Andric if (newFile->exportingFile) 243fe6060f1SDimitry Andric newFile->parseReexports(**result); 244e8d8bef9SDimitry Andric } else { 245e8d8bef9SDimitry Andric assert(magic == file_magic::macho_dynamically_linked_shared_lib || 246fe6060f1SDimitry Andric magic == file_magic::macho_dynamically_linked_shared_lib_stub || 247fe6060f1SDimitry Andric magic == file_magic::macho_executable || 248fe6060f1SDimitry Andric magic == file_magic::macho_bundle); 24981ad6265SDimitry Andric file = make<DylibFile>(mbref, umbrella, isBundleLoader, explicitlyLinked); 250fe6060f1SDimitry Andric 251fe6060f1SDimitry Andric // parseLoadCommands() can also recursively call loadDylib(). See comment 252fe6060f1SDimitry Andric // in previous block for why this means we must copy `file` here. 253fe6060f1SDimitry Andric newFile = file; 254fe6060f1SDimitry Andric if (newFile->exportingFile) 255fe6060f1SDimitry Andric newFile->parseLoadCommands(mbref); 256e8d8bef9SDimitry Andric } 257fe6060f1SDimitry Andric return newFile; 258fe6060f1SDimitry Andric } 259fe6060f1SDimitry Andric 260349cc55cSDimitry Andric void macho::resetLoadedDylibs() { loadedDylibs.clear(); } 261349cc55cSDimitry Andric 262bdd1243dSDimitry Andric std::optional<StringRef> 263fe6060f1SDimitry Andric macho::findPathCombination(const Twine &name, 264fe6060f1SDimitry Andric const std::vector<StringRef> &roots, 265fe6060f1SDimitry Andric ArrayRef<StringRef> extensions) { 266fe6060f1SDimitry Andric SmallString<261> base; 267fe6060f1SDimitry Andric for (StringRef dir : roots) { 268fe6060f1SDimitry Andric base = dir; 269fe6060f1SDimitry Andric path::append(base, name); 270fe6060f1SDimitry Andric for (StringRef ext : extensions) { 271fe6060f1SDimitry Andric Twine location = base + ext; 272fe6060f1SDimitry Andric bool exists = fs::exists(location); 273fe6060f1SDimitry Andric searchedDylib(location, exists); 274fe6060f1SDimitry Andric if (exists) 27504eeddc0SDimitry Andric return saver().save(location.str()); 276fe6060f1SDimitry Andric } 277fe6060f1SDimitry Andric } 278fe6060f1SDimitry Andric return {}; 279fe6060f1SDimitry Andric } 280fe6060f1SDimitry Andric 281fe6060f1SDimitry Andric StringRef macho::rerootPath(StringRef path) { 28206c3fb27SDimitry Andric if (!path::is_absolute(path, path::Style::posix) || path.ends_with(".o")) 283fe6060f1SDimitry Andric return path; 284fe6060f1SDimitry Andric 285bdd1243dSDimitry Andric if (std::optional<StringRef> rerootedPath = 286fe6060f1SDimitry Andric findPathCombination(path, config->systemLibraryRoots)) 287fe6060f1SDimitry Andric return *rerootedPath; 288fe6060f1SDimitry Andric 289fe6060f1SDimitry Andric return path; 290fe6060f1SDimitry Andric } 291fe6060f1SDimitry Andric 292e8d8bef9SDimitry Andric uint32_t macho::getModTime(StringRef path) { 293fe6060f1SDimitry Andric if (config->zeroModTime) 294fe6060f1SDimitry Andric return 0; 295fe6060f1SDimitry Andric 296e8d8bef9SDimitry Andric fs::file_status stat; 297e8d8bef9SDimitry Andric if (!fs::status(path, stat)) 298e8d8bef9SDimitry Andric if (fs::exists(stat)) 299e8d8bef9SDimitry Andric return toTimeT(stat.getLastModificationTime()); 300e8d8bef9SDimitry Andric 301e8d8bef9SDimitry Andric warn("failed to get modification time of " + path); 302e8d8bef9SDimitry Andric return 0; 303e8d8bef9SDimitry Andric } 304e8d8bef9SDimitry Andric 305e8d8bef9SDimitry Andric void macho::printArchiveMemberLoad(StringRef reason, const InputFile *f) { 306e8d8bef9SDimitry Andric if (config->printEachFile) 307e8d8bef9SDimitry Andric message(toString(f)); 308e8d8bef9SDimitry Andric if (config->printWhyLoad) 309e8d8bef9SDimitry Andric message(reason + " forced load of " + toString(f)); 310e8d8bef9SDimitry Andric } 311fe6060f1SDimitry Andric 312fe6060f1SDimitry Andric macho::DependencyTracker::DependencyTracker(StringRef path) 313fe6060f1SDimitry Andric : path(path), active(!path.empty()) { 314fe6060f1SDimitry Andric if (active && fs::exists(path) && !fs::can_write(path)) { 315fe6060f1SDimitry Andric warn("Ignoring dependency_info option since specified path is not " 316fe6060f1SDimitry Andric "writeable."); 317fe6060f1SDimitry Andric active = false; 318fe6060f1SDimitry Andric } 319fe6060f1SDimitry Andric } 320fe6060f1SDimitry Andric 321fe6060f1SDimitry Andric void macho::DependencyTracker::write(StringRef version, 322fe6060f1SDimitry Andric const SetVector<InputFile *> &inputs, 323fe6060f1SDimitry Andric StringRef output) { 324fe6060f1SDimitry Andric if (!active) 325fe6060f1SDimitry Andric return; 326fe6060f1SDimitry Andric 327fe6060f1SDimitry Andric std::error_code ec; 328fe6060f1SDimitry Andric raw_fd_ostream os(path, ec, fs::OF_None); 329fe6060f1SDimitry Andric if (ec) { 330fe6060f1SDimitry Andric warn("Error writing dependency info to file"); 331fe6060f1SDimitry Andric return; 332fe6060f1SDimitry Andric } 333fe6060f1SDimitry Andric 334fe6060f1SDimitry Andric auto addDep = [&os](DepOpCode opcode, const StringRef &path) { 335fe6060f1SDimitry Andric // XXX: Even though DepOpCode's underlying type is uint8_t, 336fe6060f1SDimitry Andric // this cast is still needed because Clang older than 10.x has a bug, 337fe6060f1SDimitry Andric // where it doesn't know to cast the enum to its underlying type. 338fe6060f1SDimitry Andric // Hence `<< DepOpCode` is ambiguous to it. 339fe6060f1SDimitry Andric os << static_cast<uint8_t>(opcode); 340fe6060f1SDimitry Andric os << path; 341fe6060f1SDimitry Andric os << '\0'; 342fe6060f1SDimitry Andric }; 343fe6060f1SDimitry Andric 344fe6060f1SDimitry Andric addDep(DepOpCode::Version, version); 345fe6060f1SDimitry Andric 346fe6060f1SDimitry Andric // Sort the input by its names. 347fe6060f1SDimitry Andric std::vector<StringRef> inputNames; 348fe6060f1SDimitry Andric inputNames.reserve(inputs.size()); 349fe6060f1SDimitry Andric for (InputFile *f : inputs) 350fe6060f1SDimitry Andric inputNames.push_back(f->getName()); 351fe6060f1SDimitry Andric llvm::sort(inputNames); 352fe6060f1SDimitry Andric 353fe6060f1SDimitry Andric for (const StringRef &in : inputNames) 354fe6060f1SDimitry Andric addDep(DepOpCode::Input, in); 355fe6060f1SDimitry Andric 356fe6060f1SDimitry Andric for (const std::string &f : notFounds) 357fe6060f1SDimitry Andric addDep(DepOpCode::NotFound, f); 358fe6060f1SDimitry Andric 359fe6060f1SDimitry Andric addDep(DepOpCode::Output, output); 360fe6060f1SDimitry Andric } 361