diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2013-05-24 15:06:56 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2013-05-24 15:06:56 +0000 |
| commit | ef50ee9ebd90cf9252c93eb7ee23e5c6304e2103 (patch) | |
| tree | ddbee18fc94dbeb59072837ccb6b50c8102ef548 /clang/lib/CodeGen/TargetInfo.cpp | |
| parent | c7715a228af2f2d761ddf9eb1c9635e843648064 (diff) | |
| download | bcm5719-llvm-ef50ee9ebd90cf9252c93eb7ee23e5c6304e2103.tar.gz bcm5719-llvm-ef50ee9ebd90cf9252c93eb7ee23e5c6304e2103.zip | |
Suffixing #pragma comment(lib) library names with .lib if necessary. This matches MSVC behavior, as well as allows us to properly link libraries such as the ones provided by the MSDN examples.
llvm-svn: 182647
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
| -rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 45fc475e341..74db0e37a4d 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -1266,6 +1266,17 @@ public: }; +static std::string qualifyWindowsLibrary(llvm::StringRef Lib) { + // If the argument does not end in .lib, automatically add the suffix. This + // matches the behavior of MSVC. + std::string ArgStr = Lib; + if (Lib.size() <= 4 || + Lib.substr(Lib.size() - 4).compare_lower(".lib") != 0) { + ArgStr += ".lib"; + } + return ArgStr; +} + class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { public: WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, unsigned RegParms) @@ -1274,7 +1285,7 @@ public: void getDependentLibraryOption(llvm::StringRef Lib, llvm::SmallString<24> &Opt) const { Opt = "/DEFAULTLIB:"; - Opt += Lib; + Opt += qualifyWindowsLibrary(Lib); } }; @@ -1300,7 +1311,7 @@ public: void getDependentLibraryOption(llvm::StringRef Lib, llvm::SmallString<24> &Opt) const { Opt = "/DEFAULTLIB:"; - Opt += Lib; + Opt += qualifyWindowsLibrary(Lib); } }; |

