summaryrefslogtreecommitdiff
path: root/tools/gccld
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-08-21 06:04:45 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-08-21 06:04:45 +0000
commit8ea5ecb0564b8822c70ad84202471f03e2690da7 (patch)
tree2b32a1dc217579d1cc5799b60e575dcb0a6dcc5d /tools/gccld
parent4ce5dc63778f36f61b510456783f15a224406e68 (diff)
For PR797:
Adjust usage of the ExecuteAndWait function to use the last argument which is the ErrMsg string. This is necessitated because this function no longer throws exceptions on error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/gccld')
-rw-r--r--tools/gccld/GenerateCode.cpp10
-rw-r--r--tools/gccld/gccld.cpp29
-rw-r--r--tools/gccld/gccld.h3
3 files changed, 32 insertions, 10 deletions
diff --git a/tools/gccld/GenerateCode.cpp b/tools/gccld/GenerateCode.cpp
index 63dda12aa07..285f7ca84cd 100644
--- a/tools/gccld/GenerateCode.cpp
+++ b/tools/gccld/GenerateCode.cpp
@@ -297,6 +297,7 @@ int llvm::GenerateBytecode(Module *M, int StripLevel, bool Internalize,
int llvm::GenerateAssembly(const std::string &OutputFilename,
const std::string &InputFilename,
const sys::Path &llc,
+ std::string& ErrMsg,
bool Verbose) {
// Run LLC to convert the bytecode file into assembly code.
std::vector<const char*> args;
@@ -307,13 +308,14 @@ int llvm::GenerateAssembly(const std::string &OutputFilename,
args.push_back(InputFilename.c_str());
args.push_back(0);
if (Verbose) dumpArgs(&args[0]);
- return sys::Program::ExecuteAndWait(llc, &args[0]);
+ return sys::Program::ExecuteAndWait(llc, &args[0],0,0,0,&ErrMsg);
}
/// GenerateCFile - generates a C source file from the specified bytecode file.
int llvm::GenerateCFile(const std::string &OutputFile,
const std::string &InputFile,
const sys::Path &llc,
+ std::string& ErrMsg,
bool Verbose) {
// Run LLC to convert the bytecode file into C.
std::vector<const char*> args;
@@ -325,7 +327,7 @@ int llvm::GenerateCFile(const std::string &OutputFile,
args.push_back(InputFile.c_str());
args.push_back(0);
if (Verbose) dumpArgs(&args[0]);
- return sys::Program::ExecuteAndWait(llc, &args[0]);
+ return sys::Program::ExecuteAndWait(llc, &args[0],0,0,0,&ErrMsg);
}
/// GenerateNative - generates a native executable file from the specified
@@ -352,6 +354,7 @@ int llvm::GenerateNative(const std::string &OutputFilename,
bool ExportAllAsDynamic,
const std::vector<std::string> &RPaths,
const std::string &SOName,
+ std::string& ErrMsg,
bool Verbose) {
// Remove these environment variables from the environment of the
// programs that we will execute. It appears that GCC sets these
@@ -436,7 +439,8 @@ int llvm::GenerateNative(const std::string &OutputFilename,
// Run the compiler to assembly and link together the program.
if (Verbose) dumpArgs(&args[0]);
- int Res = sys::Program::ExecuteAndWait(gcc, &args[0],(const char**)clean_env);
+ int Res = sys::Program::ExecuteAndWait(
+ gcc, &args[0],(const char**)clean_env,0,0,&ErrMsg);
delete [] clean_env;
diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp
index 22a26ef91a7..a9df06d69c7 100644
--- a/tools/gccld/gccld.cpp
+++ b/tools/gccld/gccld.cpp
@@ -320,12 +320,19 @@ int main(int argc, char **argv, char **envp ) {
// Generate an assembly language file for the bytecode.
if (Verbose) std::cout << "Generating Assembly Code\n";
- GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc,
- Verbose);
+ std::string ErrMsg;
+ if (0 != GenerateAssembly(
+ AssemblyFile.toString(), RealBytecodeOutput, llc, ErrMsg, Verbose)) {
+ std::cerr << argv[0] << ": " << ErrMsg << "\n";
+ return 2;
+ }
if (Verbose) std::cout << "Generating Native Code\n";
- GenerateNative(OutputFilename, AssemblyFile.toString(),
+ if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(),
LibPaths, Libraries, gcc, envp, LinkAsLibrary,
- NoInternalize, RPath, SOName, Verbose);
+ NoInternalize, RPath, SOName, ErrMsg, Verbose) ) {
+ std::cerr << argv[0] << ": " << ErrMsg << "\n";
+ return 2;
+ }
if (!SaveTemps) {
// Remove the assembly language file.
@@ -353,11 +360,19 @@ int main(int argc, char **argv, char **envp ) {
// Generate an assembly language file for the bytecode.
if (Verbose) std::cout << "Generating C Source Code\n";
- GenerateCFile(CFile.toString(), RealBytecodeOutput, llc, Verbose);
+ std::string ErrMsg;
+ if (0 != GenerateCFile(
+ CFile.toString(), RealBytecodeOutput, llc, ErrMsg, Verbose)) {
+ std::cerr << argv[0] << ": " << ErrMsg << "\n";
+ return 2;
+ }
if (Verbose) std::cout << "Generating Native Code\n";
- GenerateNative(OutputFilename, CFile.toString(),
+ if (0 != GenerateNative(OutputFilename, CFile.toString(),
LibPaths, Libraries, gcc, envp, LinkAsLibrary,
- NoInternalize, RPath, SOName, Verbose);
+ NoInternalize, RPath, SOName, ErrMsg, Verbose)) {
+ std::cerr << argv[0] << ": " << ErrMsg << "\n";
+ return 2;
+ }
if (!SaveTemps) {
// Remove the assembly language file.
diff --git a/tools/gccld/gccld.h b/tools/gccld/gccld.h
index 8dbae884c22..62c058a2df5 100644
--- a/tools/gccld/gccld.h
+++ b/tools/gccld/gccld.h
@@ -30,12 +30,14 @@ int
GenerateAssembly (const std::string &OutputFilename,
const std::string &InputFilename,
const sys::Path &llc,
+ std::string& ErrMsg,
bool Verbose=false);
int
GenerateCFile (const std::string &OutputFile,
const std::string &InputFile,
const sys::Path &llc,
+ std::string& ErrMsg,
bool Verbose=false);
int
GenerateNative (const std::string &OutputFilename,
@@ -48,6 +50,7 @@ GenerateNative (const std::string &OutputFilename,
bool ExportAllAsDynamic,
const std::vector<std::string> &RPath,
const std::string &SOName,
+ std::string& ErrMsg,
bool Verbose=false);
} // End llvm namespace