[PATCH] D19321: lld-link: Fix default output name with /dll flag.

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 05:53:02 PDT 2016


thakis created this revision.
thakis added a reviewer: ruiu.
thakis added a subscriber: llvm-commits.

If /dll is passed, the default output filename should be foo.dll, not foo.exe.

http://reviews.llvm.org/D19321

Files:
  COFF/Driver.cpp
  test/COFF/out.test

Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -50,11 +50,12 @@
   return true;
 }
 
-// Drop directory components and replace extension with ".exe".
+// Drop directory components and replace extension with ".exe" or ".dll".
 static std::string getOutputPath(StringRef Path) {
   auto P = Path.find_last_of("\\/");
   StringRef S = (P == StringRef::npos) ? Path : Path.substr(P + 1);
-  return (S.substr(0, S.rfind('.')) + ".exe").str();
+  const char* E = Config->DLL ? ".dll" : ".exe";
+  return (S.substr(0, S.rfind('.')) + E).str();
 }
 
 // Opens a file. Path has to be resolved already.
Index: test/COFF/out.test
===================================================================
--- test/COFF/out.test
+++ test/COFF/out.test
@@ -5,12 +5,13 @@
 # RUN: cp %t.obj %T/out/tmp/out2
 # RUN: cp %t.obj %T/out/tmp/out3.xyz
 
+# RUN: rm -f out1.exe out2.exe out3.exe out3.dll
 # RUN: lld-link /entry:main %T/out/out1.obj
 # RUN: lld-link /entry:main %T/out/tmp/out2
-# RUN: lld-link /entry:main %T/out/tmp/out3.xyz
+# RUN: lld-link /dll /entry:main %T/out/tmp/out3.xyz
 
 # RUN: llvm-readobj out1.exe | FileCheck %s
 # RUN: llvm-readobj out2.exe | FileCheck %s
-# RUN: llvm-readobj out3.exe | FileCheck %s
+# RUN: llvm-readobj out3.dll | FileCheck %s
 
 CHECK: File:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19321.54351.patch
Type: text/x-patch
Size: 1382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160420/474f41d9/attachment.bin>


More information about the llvm-commits mailing list