diff options
Diffstat (limited to 'contrib/llvm/tools/llvm-ld/llvm-ld.cpp')
-rw-r--r-- | contrib/llvm/tools/llvm-ld/llvm-ld.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/contrib/llvm/tools/llvm-ld/llvm-ld.cpp b/contrib/llvm/tools/llvm-ld/llvm-ld.cpp index ad6956c..3bbea9d 100644 --- a/contrib/llvm/tools/llvm-ld/llvm-ld.cpp +++ b/contrib/llvm/tools/llvm-ld/llvm-ld.cpp @@ -145,8 +145,8 @@ static void PrintCommand(const std::vector<const char*> &args) { std::vector<const char*>::const_iterator I = args.begin(), E = args.end(); for (; I != E; ++I) if (*I) - outs() << "'" << *I << "'" << " "; - outs() << "\n"; outs().flush(); + errs() << "'" << *I << "'" << " "; + errs() << "\n"; } /// CopyEnv - This function takes an array of environment variables and makes a @@ -232,17 +232,20 @@ static void RemoveEnv(const char * name, char ** const envp) { void GenerateBitcode(Module* M, const std::string& FileName) { if (Verbose) - outs() << "Generating Bitcode To " << FileName << '\n'; + errs() << "Generating Bitcode To " << FileName << '\n'; // Create the output file. std::string ErrorInfo; - raw_fd_ostream Out(FileName.c_str(), ErrorInfo, - raw_fd_ostream::F_Binary); - if (!ErrorInfo.empty()) + tool_output_file Out(FileName.c_str(), ErrorInfo, + raw_fd_ostream::F_Binary); + if (!ErrorInfo.empty()) { PrintAndExit(ErrorInfo, M); + return; + } // Write it out - WriteBitcodeToFile(M, Out); + WriteBitcodeToFile(M, Out.os()); + Out.keep(); } /// GenerateAssembly - generates a native assembly language source file from the @@ -272,7 +275,7 @@ static int GenerateAssembly(const std::string &OutputFilename, args.push_back(0); if (Verbose) { - outs() << "Generating Assembly With: \n"; + errs() << "Generating Assembly With: \n"; PrintCommand(args); } @@ -294,7 +297,7 @@ static int GenerateCFile(const std::string &OutputFile, args.push_back(0); if (Verbose) { - outs() << "Generating C Source With: \n"; + errs() << "Generating C Source With: \n"; PrintCommand(args); } @@ -391,7 +394,7 @@ static int GenerateNative(const std::string &OutputFilename, Args.push_back(0); if (Verbose) { - outs() << "Generating Native Executable With:\n"; + errs() << "Generating Native Executable With:\n"; PrintCommand(Args); } @@ -406,7 +409,7 @@ static int GenerateNative(const std::string &OutputFilename, /// bitcode file for the program. static void EmitShellScript(char **argv, Module *M) { if (Verbose) - outs() << "Emitting Shell Script\n"; + errs() << "Emitting Shell Script\n"; #if defined(_WIN32) || defined(__CYGWIN__) // Windows doesn't support #!/bin/sh style shell scripts in .exe files. To // support windows systems, we copy the llvm-stub.exe executable from the @@ -425,14 +428,14 @@ static void EmitShellScript(char **argv, Module *M) { // Output the script to start the program... std::string ErrorInfo; - raw_fd_ostream Out2(OutputFilename.c_str(), ErrorInfo); + tool_output_file Out2(OutputFilename.c_str(), ErrorInfo); if (!ErrorInfo.empty()) PrintAndExit(ErrorInfo, M); - Out2 << "#!/bin/sh\n"; + Out2.os() << "#!/bin/sh\n"; // Allow user to setenv LLVMINTERP if lli is not in their PATH. - Out2 << "lli=${LLVMINTERP-lli}\n"; - Out2 << "exec $lli \\\n"; + Out2.os() << "lli=${LLVMINTERP-lli}\n"; + Out2.os() << "exec $lli \\\n"; // gcc accepts -l<lib> and implicitly searches /lib and /usr/lib. LibPaths.push_back("/lib"); LibPaths.push_back("/usr/lib"); @@ -463,9 +466,10 @@ static void EmitShellScript(char **argv, Module *M) { if (FullLibraryPath.isEmpty()) FullLibraryPath = sys::Path::FindLibrary(*i); if (!FullLibraryPath.isEmpty()) - Out2 << " -load=" << FullLibraryPath.str() << " \\\n"; + Out2.os() << " -load=" << FullLibraryPath.str() << " \\\n"; } - Out2 << " " << BitcodeOutputFilename << " ${1+\"$@\"}\n"; + Out2.os() << " " << BitcodeOutputFilename << " ${1+\"$@\"}\n"; + Out2.keep(); } // BuildLinkItems -- This function generates a LinkItemList for the LinkItems |