Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lld/wasm/Driver.cpp
Show First 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | case file_magic::archive: { | ||||
files.push_back(make<ArchiveFile>(mbref)); | files.push_back(make<ArchiveFile>(mbref)); | ||||
return; | return; | ||||
} | } | ||||
case file_magic::bitcode: | case file_magic::bitcode: | ||||
case file_magic::wasm_object: | case file_magic::wasm_object: | ||||
files.push_back(createObjectFile(mbref)); | files.push_back(createObjectFile(mbref)); | ||||
break; | break; | ||||
case file_magic::unknown: | |||||
dschuff: Any particular reason not to just make #STUB the file magic for a new kind of file? or is that… | |||||
if (mbref.getBuffer().starts_with("#STUB\n")) { | |||||
files.push_back(make<StubFile>(mbref)); | |||||
break; | |||||
} | |||||
[[fallthrough]]; | |||||
default: | default: | ||||
error("unknown file type: " + mbref.getBufferIdentifier()); | error("unknown file type: " + mbref.getBufferIdentifier()); | ||||
} | } | ||||
} | } | ||||
static std::optional<std::string> findFromSearchPaths(StringRef path) { | static std::optional<std::string> findFromSearchPaths(StringRef path) { | ||||
for (StringRef dir : config->searchPaths) | for (StringRef dir : config->searchPaths) | ||||
if (std::optional<std::string> s = findFile(dir, path)) | if (std::optional<std::string> s = findFile(dir, path)) | ||||
▲ Show 20 Lines • Show All 573 Lines • ▼ Show 20 Lines | static void createOptionalSymbols() { | ||||
// start of the `.tdata` static segment. | // start of the `.tdata` static segment. | ||||
// | // | ||||
// __tls_size and __tls_align are not needed in this case since they are only | // __tls_size and __tls_align are not needed in this case since they are only | ||||
// needed for __wasm_init_tls (which we do not create in this case). | // needed for __wasm_init_tls (which we do not create in this case). | ||||
if (!config->sharedMemory) | if (!config->sharedMemory) | ||||
WasmSym::tlsBase = createOptionalGlobal("__tls_base", false); | WasmSym::tlsBase = createOptionalGlobal("__tls_base", false); | ||||
} | } | ||||
static void processStubLibraries() { | |||||
Not Done ReplyInline Actionscan we rename the methods and variables/comments to match the renaming of the feature? dschuff: can we rename the methods and variables/comments to match the renaming of the feature? | |||||
log("-- processStubLibraries"); | |||||
for (auto &stub_file : symtab->stubFiles) { | |||||
LLVM_DEBUG(llvm::dbgs() | |||||
<< "processing stub file: " << stub_file->getName() << "\n"); | |||||
for (auto [name, deps]: stub_file->symbolDependencies) { | |||||
auto* sym = symtab->find(name); | |||||
if (!sym || !sym->isUndefined() || !sym->isUsedInRegularObj || | |||||
sym->forceImport) { | |||||
LLVM_DEBUG(llvm::dbgs() << "stub not in needed: " << name << "\n"); | |||||
Here you mean "stub symbol" , right? Same issue in other messages in this hunk. pmatos: Here you mean "stub symbol" , right? Same issue in other messages in this hunk. | |||||
continue; | |||||
} | |||||
// The first stub library to define a given symbol sets this and | |||||
// definitions in later stub libraries are ignored. | |||||
sym->forceImport = true; | |||||
if (sym->traced) | |||||
message(toString(stub_file) + ": importing " + name); | |||||
else | |||||
LLVM_DEBUG(llvm::dbgs() | |||||
<< toString(stub_file) << ": importing " << name << "\n"); | |||||
for (const auto dep : deps) { | |||||
auto* needed = symtab->find(dep); | |||||
if (!needed) { | |||||
error(toString(stub_file) + ": undefined symbol: " + dep + | |||||
". Required by " + toString(*sym)); | |||||
} else if (needed->isUndefined()) { | |||||
error(toString(stub_file) + | |||||
": undefined symbol: " + toString(*needed) + | |||||
". Required by " + toString(*sym)); | |||||
} else { | |||||
LLVM_DEBUG(llvm::dbgs() | |||||
<< "force export: " << toString(*needed) << "\n"); | |||||
needed->forceExport = true; | |||||
needed->isUsedInRegularObj = true; | |||||
if (auto *lazy = dyn_cast<LazySymbol>(needed)) { | |||||
lazy->fetch(); | |||||
if (!config->whyExtract.empty()) | |||||
config->whyExtractRecords.emplace_back(stub_file->getName(), | |||||
sym->getFile(), *sym); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
log("-- done processStubLibraries"); | |||||
} | |||||
// Reconstructs command line arguments so that so that you can re-run | // Reconstructs command line arguments so that so that you can re-run | ||||
// the same command with the same inputs. This is for --reproduce. | // the same command with the same inputs. This is for --reproduce. | ||||
static std::string createResponseFile(const opt::InputArgList &args) { | static std::string createResponseFile(const opt::InputArgList &args) { | ||||
SmallString<0> data; | SmallString<0> data; | ||||
raw_svector_ostream os(data); | raw_svector_ostream os(data); | ||||
// Copy the command line to the output while rewriting paths. | // Copy the command line to the output while rewriting paths. | ||||
for (auto *arg : args) { | for (auto *arg : args) { | ||||
▲ Show 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { | ||||
writeWhyExtract(); | writeWhyExtract(); | ||||
// Do link-time optimization if given files are LLVM bitcode files. | // Do link-time optimization if given files are LLVM bitcode files. | ||||
// This compiles bitcode files into real object files. | // This compiles bitcode files into real object files. | ||||
symtab->compileBitcodeFiles(); | symtab->compileBitcodeFiles(); | ||||
if (errorCount()) | if (errorCount()) | ||||
return; | return; | ||||
processStubLibraries(); | |||||
createOptionalSymbols(); | createOptionalSymbols(); | ||||
// Resolve any variant symbols that were created due to signature | // Resolve any variant symbols that were created due to signature | ||||
// mismatchs. | // mismatchs. | ||||
symtab->handleSymbolVariants(); | symtab->handleSymbolVariants(); | ||||
if (errorCount()) | if (errorCount()) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
Any particular reason not to just make #STUB the file magic for a new kind of file? or is that not done for text files?