* Print commands as we execute them with `-v'
* Add option `-save-temps'
Patch contributed by Markus Oberhumer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21367 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp
index 8698cc8..98e7dea 100644
--- a/tools/gccld/gccld.cpp
+++ b/tools/gccld/gccld.cpp
@@ -83,6 +83,10 @@
   cl::opt<bool>    
   NativeCBE("native-cbe",
             cl::desc("Generate a native binary with the C backend and GCC"));
+
+  cl::opt<bool>    
+  SaveTemps("save-temps",
+         cl::desc("Do not delete temporary files"));
             
   cl::opt<std::string>
   RPath("rpath",
@@ -300,16 +304,19 @@
 
       // Generate an assembly language file for the bytecode.
       if (Verbose) std::cout << "Generating Assembly Code\n";
-      GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc);
+      GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc, 
+                       Verbose);
       if (Verbose) std::cout << "Generating Native Code\n";
       GenerateNative(OutputFilename, AssemblyFile.toString(), 
                      LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath,
-                     SOName );
+                     SOName, Verbose);
 
-      // Remove the assembly language file.
-      AssemblyFile.destroyFile();
-      // Remove the bytecode language file.
-      sys::Path(RealBytecodeOutput).destroyFile();
+      if (!SaveTemps) {
+        // Remove the assembly language file.
+        AssemblyFile.destroyFile();
+        // Remove the bytecode language file.
+        sys::Path(RealBytecodeOutput).destroyFile();
+      }
     
     } else if (NativeCBE) {
       sys::Path CFile (OutputFilename);
@@ -329,18 +336,19 @@
         return PrintAndReturn(argv[0], "Failed to find gcc");
 
       // Generate an assembly language file for the bytecode.
-      if (Verbose) std::cout << "Generating Assembly Code\n";
-      GenerateCFile(CFile.toString(), RealBytecodeOutput, llc);
+      if (Verbose) std::cout << "Generating C Source Code\n";
+      GenerateCFile(CFile.toString(), RealBytecodeOutput, llc, Verbose);
       if (Verbose) std::cout << "Generating Native Code\n";
       GenerateNative(OutputFilename, CFile.toString(),
                      LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath,
-                     SOName );
+                     SOName, Verbose);
 
-      // Remove the assembly language file.
-      CFile.destroyFile();
-    
-      // Remove the bytecode language file.
-      sys::Path(RealBytecodeOutput).destroyFile();
+      if (!SaveTemps) {
+        // Remove the assembly language file.
+        CFile.destroyFile();
+        // Remove the bytecode language file.
+        sys::Path(RealBytecodeOutput).destroyFile();
+      }
 
     } else if (!LinkAsLibrary) {
       EmitShellScript(argv);