[llvm-commits] [llvm] r52287 - /llvm/trunk/tools/llvm-ld/llvm-ld.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Sun Jun 15 06:48:12 PDT 2008


Author: akirtzidis
Date: Sun Jun 15 08:48:12 2008
New Revision: 52287

URL: http://llvm.org/viewvc/llvm-project?rev=52287&view=rev
Log:
Make sure all produced executable files have "exe" suffix on Windows.
With this more general way, -native and -native-cbe options are handled too.

Modified:
    llvm/trunk/tools/llvm-ld/llvm-ld.cpp

Modified: llvm/trunk/tools/llvm-ld/llvm-ld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ld/llvm-ld.cpp?rev=52287&r1=52286&r2=52287&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-ld/llvm-ld.cpp (original)
+++ llvm/trunk/tools/llvm-ld/llvm-ld.cpp Sun Jun 15 08:48:12 2008
@@ -403,11 +403,7 @@
   if (llvmstub.isEmpty())
     PrintAndExit("Could not find llvm-stub.exe executable!");
 
-  sys::Path OutPath(OutputFilename);
-  if (OutPath.getSuffix() != "exe")
-    OutPath.appendSuffix("exe");
-
-  if (0 != sys::CopyFile(OutPath, llvmstub, &ErrMsg))
+  if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg))
     PrintAndExit(ErrMsg);
 
   return;
@@ -534,14 +530,24 @@
     // Optimize the module
     Optimize(Composite.get());
 
-    // Generate the bitcode for the optimized module.
-    std::string RealBitcodeOutput = OutputFilename;
-
 #if defined(_WIN32) || defined(__CYGWIN__)
-    if (!LinkAsLibrary && sys::Path(OutputFilename).getSuffix() != "exe")
-      RealBitcodeOutput += ".exe";
+    if (!LinkAsLibrary) {
+      // Make sure the output executable has an "exe" suffix.
+      sys::Path ExeFile( OutputFilename );
+      if (ExeFile.getSuffix() != "exe") {
+        if (OutputFilename == "a.out") {
+          OutputFilename = "a.exe";
+        } else {
+          ExeFile.appendSuffix("exe");
+          OutputFilename = ExeFile.toString();
+        }
+      }
+    }
 #endif
 
+    // Generate the bitcode for the optimized module.
+    std::string RealBitcodeOutput = OutputFilename;
+
     if (!LinkAsLibrary) RealBitcodeOutput += ".bc";
     GenerateBitcode(Composite.get(), RealBitcodeOutput);
 





More information about the llvm-commits mailing list