diff options
-rw-r--r-- | lld/include/lld/Driver/Driver.h | 3 | ||||
-rw-r--r-- | lld/lib/Driver/CoreDriver.cpp | 2 | ||||
-rw-r--r-- | lld/lib/Driver/DarwinLdDriver.cpp | 4 | ||||
-rw-r--r-- | lld/lib/Driver/Driver.cpp | 7 | ||||
-rw-r--r-- | lld/lib/Driver/GnuLdDriver.cpp | 4 |
5 files changed, 18 insertions, 2 deletions
diff --git a/lld/include/lld/Driver/Driver.h b/lld/include/lld/Driver/Driver.h index 1d0d547442a..4bf0f43f8ce 100644 --- a/lld/include/lld/Driver/Driver.h +++ b/lld/include/lld/Driver/Driver.h @@ -46,6 +46,9 @@ protected: static bool link(LinkingContext &context, raw_ostream &diag = llvm::errs()); + /// Parses the LLVM options from the context. + static void parseLLVMOptions(const LinkingContext &context); + private: Driver() = delete; }; diff --git a/lld/lib/Driver/CoreDriver.cpp b/lld/lib/Driver/CoreDriver.cpp index c9aa7ad50b0..ce864859510 100644 --- a/lld/lib/Driver/CoreDriver.cpp +++ b/lld/lib/Driver/CoreDriver.cpp @@ -159,6 +159,8 @@ bool CoreDriver::parse(llvm::ArrayRef<const char *> args, } } + parseLLVMOptions(ctx); + if (ctx.getNodes().empty()) { diagnostics << "No input files\n"; return false; diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp index cf018934e32..40fad74c952 100644 --- a/lld/lib/Driver/DarwinLdDriver.cpp +++ b/lld/lib/Driver/DarwinLdDriver.cpp @@ -822,6 +822,10 @@ bool DarwinLdDriver::parse(llvm::ArrayRef<const char *> args, } } + // Parse the LLVM options before we process files in case the file handling + // makes use of things like DEBUG(). + parseLLVMOptions(ctx); + // Handle input files and sectcreate. for (auto &arg : parsedArgs) { bool upward; diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp index a040e9cbdc5..6a7a26b3b0f 100644 --- a/lld/lib/Driver/Driver.cpp +++ b/lld/lib/Driver/Driver.cpp @@ -64,8 +64,7 @@ FileVector loadFile(LinkingContext &ctx, StringRef path, bool wholeArchive) { return files; } -/// This is where the link is actually performed. -bool Driver::link(LinkingContext &ctx, raw_ostream &diagnostics) { +void Driver::parseLLVMOptions(const LinkingContext &ctx) { // Honor -mllvm if (!ctx.llvmOptions().empty()) { unsigned numArgs = ctx.llvmOptions().size(); @@ -76,6 +75,10 @@ bool Driver::link(LinkingContext &ctx, raw_ostream &diagnostics) { args[numArgs + 1] = nullptr; llvm::cl::ParseCommandLineOptions(numArgs + 1, args); } +} + +/// This is where the link is actually performed. +bool Driver::link(LinkingContext &ctx, raw_ostream &diagnostics) { if (ctx.getNodes().empty()) return false; diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp index 5989e216248..8c75126d6d4 100644 --- a/lld/lib/Driver/GnuLdDriver.cpp +++ b/lld/lib/Driver/GnuLdDriver.cpp @@ -637,6 +637,10 @@ bool GnuLdDriver::parse(llvm::ArrayRef<const char *> args, if (ctx->allowLinkWithDynamicLibraries()) ctx->registry().addSupportELFDynamicSharedObjects(*ctx); + // Parse the LLVM options before we process files in case the file handling + // makes use of things like DEBUG(). + parseLLVMOptions(*ctx); + std::stack<int> groupStack; int numfiles = 0; bool asNeeded = false; |