Enable PRE.
[oota-llvm.git] / tools / llvm-ld / llvm-ld.cpp
index 9d0d93fd8307d0da69b38312b676a9dc25a4efac..40265628ac007335acb51ced15aab6e10d65a3d4 100644 (file)
@@ -38,6 +38,7 @@
 #include "llvm/System/Signals.h"
 #include <fstream>
 #include <memory>
+#include <cstring>
 using namespace llvm;
 
 // Input/Output Options
@@ -529,8 +530,24 @@ int main(int argc, char **argv, char **envp) {
     // Optimize the module
     Optimize(Composite.get());
 
+#if defined(_WIN32) || defined(__CYGWIN__)
+    if (!LinkAsLibrary) {
+      // Default to "a.exe" instead of "a.out".
+      if (OutputFilename.getNumOccurrences() == 0)
+        OutputFilename = "a.exe";
+
+      // If there is no suffix add an "exe" one.
+      sys::Path ExeFile( OutputFilename );
+      if (ExeFile.getSuffix() == "") {
+        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);