Enable PRE.
[oota-llvm.git] / tools / llvm-ld / llvm-ld.cpp
index 6657c7c7fd276ecbaa305018ccd95be266d9754c..40265628ac007335acb51ced15aab6e10d65a3d4 100644 (file)
@@ -530,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);