summaryrefslogtreecommitdiffstats
path: root/lld/lib/Driver/LinkerInvocation.cpp
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2013-04-04 18:59:24 +0000
committerNick Kledzik <kledzik@apple.com>2013-04-04 18:59:24 +0000
commitc314b46e718bb5f23ca257af2331c120891361b2 (patch)
treeb0c6c6a9688cadb233589dc5e317df5d05d89cba /lld/lib/Driver/LinkerInvocation.cpp
parent83f1be1bfc3112d0edba33ed6d8e1a751844b06f (diff)
downloadbcm5719-llvm-c314b46e718bb5f23ca257af2331c120891361b2.tar.gz
bcm5719-llvm-c314b46e718bb5f23ca257af2331c120891361b2.zip
This is my Driver refactoring patch.
The major changes are: 1) LinkerOptions has been merged into TargetInfo 2) LinkerInvocation has been merged into Driver 3) Drivers no longer convert arguments into an intermediate (core) argument list, but instead create a TargetInfo object and call setter methods on it. This is only how in-process linking would work. That is, you can programmatically set up a TargetInfo object which controls the linking. 4) Lots of tweaks to test suite to work with driver changes 5) Add the DarwinDriver 6) I heavily doxygen commented TargetInfo.h Things to do after this patch is committed: a) Consider renaming TargetInfo, given its new roll. b) Consider pulling the list of input files out of TargetInfo. This will enable in-process clients to create one TargetInfo the re-use it with different input file lists. c) Work out a way for Drivers to format the warnings and error done in core linking. llvm-svn: 178776
Diffstat (limited to 'lld/lib/Driver/LinkerInvocation.cpp')
-rw-r--r--lld/lib/Driver/LinkerInvocation.cpp98
1 files changed, 0 insertions, 98 deletions
diff --git a/lld/lib/Driver/LinkerInvocation.cpp b/lld/lib/Driver/LinkerInvocation.cpp
deleted file mode 100644
index 21662774bd9..00000000000
--- a/lld/lib/Driver/LinkerInvocation.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-//===- lib/Driver/LinkerInvocation.cpp - Linker Invocation ----------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lld/Driver/LinkerInvocation.h"
-
-#include "lld/Core/InputFiles.h"
-#include "lld/Core/PassManager.h"
-#include "lld/Core/Resolver.h"
-#include "lld/ReaderWriter/ELFTargetInfo.h"
-#include "lld/ReaderWriter/Reader.h"
-#include "lld/ReaderWriter/Writer.h"
-
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace lld;
-
-namespace {
-std::unique_ptr<TargetInfo> createTargetInfo(const LinkerOptions &lo) {
- return ELFTargetInfo::create(lo);
-}
-}
-
-void LinkerInvocation::operator()() {
- // Honor -mllvm
- if (!_options._llvmArgs.empty()) {
- unsigned NumArgs = _options._llvmArgs.size();
- const char **Args = new const char*[NumArgs + 2];
- Args[0] = "lld (LLVM option parsing)";
- for (unsigned i = 0; i != NumArgs; ++i)
- Args[i + 1] = _options._llvmArgs[i].c_str();
- Args[NumArgs + 1] = 0;
- llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args);
- }
-
- // Create target.
- std::unique_ptr<TargetInfo> targetInfo(createTargetInfo(_options));
-
- if (!targetInfo) {
- llvm::errs() << "Failed to create target for " << _options._target
- << "\n";
- return;
- }
-
- // Read inputs
- InputFiles inputs;
- for (const auto &input : _options._input) {
- auto reader = targetInfo->getReader(input);
- if (error_code ec = reader) {
- llvm::errs() << "Failed to get reader for: " << input.getPath() << ": "
- << ec.message() << "\n";
- return;
- }
-
- auto buffer = input.getBuffer();
- if (error_code ec = buffer) {
- llvm::errs() << "Failed to read file: " << input.getPath() << ": "
- << ec.message() << "\n";
- return;
- }
-
- std::vector<std::unique_ptr<File>> files;
- if (llvm::error_code ec = reader->parseFile(std::unique_ptr<MemoryBuffer>(MemoryBuffer::getMemBuffer(buffer->getBuffer(), buffer->getBufferIdentifier())), files)) {
- llvm::errs() << "Failed to read file: " << input.getPath() << ": "
- << ec.message() << "\n";
- return;
- }
- inputs.appendFiles(files);
- }
- inputs.assignFileOrdinals();
-
- auto writer = targetInfo->getWriter();
-
- // Give writer a chance to add files
- writer->addFiles(inputs);
-
- Resolver resolver(*targetInfo, inputs);
- resolver.resolve();
- MutableFile &merged = resolver.resultFile();
-
- PassManager pm;
- targetInfo->addPasses(pm);
- pm.runOnFile(merged);
-
- if (error_code ec = writer) {
- llvm::errs() << "Failed to get writer: " << ec.message() << ".\n";
- return;
- }
-
- if (error_code ec = writer->writeFile(merged, _options._outputPath))
- llvm::errs() << "Failed to write file: " << ec.message() << "\n";
-}
OpenPOWER on IntegriCloud