From 3190ca922d3743137e15fe0c525c04b177b9983b Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 8 May 2013 13:44:39 +0000 Subject: Forward #pragma comment(lib/linker) through as flags metadata Summary: Most of this change is wiring the pragma all the way through from the lexer, parser, and sema to codegen. I considered adding a Decl AST node for this, but it seemed too heavyweight. Mach-O already uses a metadata flag called "Linker Options" to do this kind of auto-linking. This change follows that pattern. LLVM knows how to forward the "Linker Options" metadata into the COFF .drectve section where these flags belong. ELF support is not implemented, but possible. This is related to auto-linking, which is http://llvm.org/PR13016. CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D723 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181426 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/ModuleBuilder.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/CodeGen/ModuleBuilder.cpp') diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp index 69e5b32304..56067a47bb 100644 --- a/lib/CodeGen/ModuleBuilder.cpp +++ b/lib/CodeGen/ModuleBuilder.cpp @@ -20,6 +20,7 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/CodeGenOptions.h" #include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/StringRef.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" @@ -115,6 +116,14 @@ namespace { Builder->EmitVTable(RD, DefinitionRequired); } + + virtual void HandleLinkerOptionPragma(llvm::StringRef Opts) { + Builder->AppendLinkerOptions(Opts); + } + + virtual void HandleDependentLibrary(llvm::StringRef Lib) { + Builder->AddDependentLib(Lib); + } }; } -- cgit v1.2.3