mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 06:32:09 +00:00
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
This commit is contained in:
parent
4ce5dc6377
commit
8ea5ecb056
@ -19,6 +19,7 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
void llvm::DisplayGraph(const sys::Path &Filename) {
|
void llvm::DisplayGraph(const sys::Path &Filename) {
|
||||||
|
std::string ErrMsg;
|
||||||
#if HAVE_GRAPHVIZ
|
#if HAVE_GRAPHVIZ
|
||||||
sys::Path Graphviz(LLVM_PATH_GRAPHVIZ);
|
sys::Path Graphviz(LLVM_PATH_GRAPHVIZ);
|
||||||
|
|
||||||
@ -28,8 +29,8 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
|
|||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
|
|
||||||
std::cerr << "Running 'Graphviz' program... " << std::flush;
|
std::cerr << "Running 'Graphviz' program... " << std::flush;
|
||||||
if (sys::Program::ExecuteAndWait(Graphviz, &args[0])) {
|
if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,&ErrMsg)) {
|
||||||
std::cerr << "Error viewing graph: 'Graphviz' not in path?\n";
|
std::cerr << "Error viewing graph: " << ErrMsg << "\n";
|
||||||
}
|
}
|
||||||
#elif (HAVE_GV && HAVE_DOT)
|
#elif (HAVE_GV && HAVE_DOT)
|
||||||
sys::Path PSFilename = Filename;
|
sys::Path PSFilename = Filename;
|
||||||
@ -48,8 +49,8 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
|
|||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
|
|
||||||
std::cerr << "Running 'dot' program... " << std::flush;
|
std::cerr << "Running 'dot' program... " << std::flush;
|
||||||
if (sys::Program::ExecuteAndWait(dot, &args[0])) {
|
if (sys::Program::ExecuteAndWait(dot, &args[0],0,0,0,&ErrMsg)) {
|
||||||
std::cerr << "Error viewing graph: 'dot' not in path?\n";
|
std::cerr << "Error viewing graph: '" << ErrMsg << "\n";
|
||||||
} else {
|
} else {
|
||||||
std::cerr << " done. \n";
|
std::cerr << " done. \n";
|
||||||
|
|
||||||
@ -59,8 +60,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
|
|||||||
args.push_back(PSFilename.c_str());
|
args.push_back(PSFilename.c_str());
|
||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
|
|
||||||
if (sys::Program::ExecuteAndWait(gv, &args[0])) {
|
ErrMsg.clear();
|
||||||
std::cerr << "Error viewing graph: 'gv' not in path?\n";
|
if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,&ErrMsg)) {
|
||||||
|
std::cerr << "Error viewing graph: " << ErrMsg << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PSFilename.eraseFromDisk();
|
PSFilename.eraseFromDisk();
|
||||||
@ -72,8 +74,8 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
|
|||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
|
|
||||||
std::cerr << "Running 'dotty' program... " << std::flush;
|
std::cerr << "Running 'dotty' program... " << std::flush;
|
||||||
if (sys::Program::ExecuteAndWait(dotty, &args[0])) {
|
if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,&ErrMsg)) {
|
||||||
std::cerr << "Error viewing graph: 'dotty' not in path?\n";
|
std::cerr << "Error viewing graph: " << ErrMsg << "\n";
|
||||||
} else {
|
} else {
|
||||||
#ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns.
|
#ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns.
|
||||||
return;
|
return;
|
||||||
|
@ -179,7 +179,8 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
|||||||
args[n++] = 0;
|
args[n++] = 0;
|
||||||
|
|
||||||
sys::Path prog(sys::Program::FindProgramByName(ToolName));
|
sys::Path prog(sys::Program::FindProgramByName(ToolName));
|
||||||
int result = sys::Program::ExecuteAndWait(prog,args,0,0,Timeout);
|
std::string ErrMsg;
|
||||||
|
int result = sys::Program::ExecuteAndWait(prog,args,0,0,Timeout,&ErrMsg);
|
||||||
|
|
||||||
// If we are supposed to delete the bytecode file or if the passes crashed,
|
// If we are supposed to delete the bytecode file or if the passes crashed,
|
||||||
// remove it now. This may fail if the file was never created, but that's ok.
|
// remove it now. This may fail if the file was never created, but that's ok.
|
||||||
@ -194,10 +195,12 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
|||||||
std::cout << "Success!\n";
|
std::cout << "Success!\n";
|
||||||
else if (result > 0)
|
else if (result > 0)
|
||||||
std::cout << "Exited with error code '" << result << "'\n";
|
std::cout << "Exited with error code '" << result << "'\n";
|
||||||
else if (result == -9999)
|
else if (result < 0) {
|
||||||
std::cout << "Program not executable\n";
|
if (result == -1)
|
||||||
else if (result < 0)
|
std::cout << "Execute failed: " << ErrMsg << "\n";
|
||||||
std::cout << "Crashed with signal #" << abs(result) << "\n";
|
else
|
||||||
|
std::cout << "Crashed with signal #" << abs(result) << "\n";
|
||||||
|
}
|
||||||
if (result & 0x01000000)
|
if (result & 0x01000000)
|
||||||
std::cout << "Dumped core\n";
|
std::cout << "Dumped core\n";
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ static void ProcessFailure(sys::Path ProgPath, const char** Args) {
|
|||||||
sys::Path ErrorFilename("error_messages");
|
sys::Path ErrorFilename("error_messages");
|
||||||
ErrorFilename.makeUnique();
|
ErrorFilename.makeUnique();
|
||||||
RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
|
RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
|
||||||
ErrorFilename); // FIXME: check return code
|
ErrorFilename); // FIXME: check return code ?
|
||||||
|
|
||||||
// Print out the error messages generated by GCC if possible...
|
// Print out the error messages generated by GCC if possible...
|
||||||
std::ifstream ErrorFile(ErrorFilename.c_str());
|
std::ifstream ErrorFile(ErrorFilename.c_str());
|
||||||
|
@ -297,6 +297,7 @@ int llvm::GenerateBytecode(Module *M, int StripLevel, bool Internalize,
|
|||||||
int llvm::GenerateAssembly(const std::string &OutputFilename,
|
int llvm::GenerateAssembly(const std::string &OutputFilename,
|
||||||
const std::string &InputFilename,
|
const std::string &InputFilename,
|
||||||
const sys::Path &llc,
|
const sys::Path &llc,
|
||||||
|
std::string& ErrMsg,
|
||||||
bool Verbose) {
|
bool Verbose) {
|
||||||
// Run LLC to convert the bytecode file into assembly code.
|
// Run LLC to convert the bytecode file into assembly code.
|
||||||
std::vector<const char*> args;
|
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(InputFilename.c_str());
|
||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
if (Verbose) dumpArgs(&args[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.
|
/// GenerateCFile - generates a C source file from the specified bytecode file.
|
||||||
int llvm::GenerateCFile(const std::string &OutputFile,
|
int llvm::GenerateCFile(const std::string &OutputFile,
|
||||||
const std::string &InputFile,
|
const std::string &InputFile,
|
||||||
const sys::Path &llc,
|
const sys::Path &llc,
|
||||||
|
std::string& ErrMsg,
|
||||||
bool Verbose) {
|
bool Verbose) {
|
||||||
// Run LLC to convert the bytecode file into C.
|
// Run LLC to convert the bytecode file into C.
|
||||||
std::vector<const char*> args;
|
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(InputFile.c_str());
|
||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
if (Verbose) dumpArgs(&args[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
|
/// GenerateNative - generates a native executable file from the specified
|
||||||
@ -352,6 +354,7 @@ int llvm::GenerateNative(const std::string &OutputFilename,
|
|||||||
bool ExportAllAsDynamic,
|
bool ExportAllAsDynamic,
|
||||||
const std::vector<std::string> &RPaths,
|
const std::vector<std::string> &RPaths,
|
||||||
const std::string &SOName,
|
const std::string &SOName,
|
||||||
|
std::string& ErrMsg,
|
||||||
bool Verbose) {
|
bool Verbose) {
|
||||||
// Remove these environment variables from the environment of the
|
// Remove these environment variables from the environment of the
|
||||||
// programs that we will execute. It appears that GCC sets these
|
// 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.
|
// Run the compiler to assembly and link together the program.
|
||||||
if (Verbose) dumpArgs(&args[0]);
|
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;
|
delete [] clean_env;
|
||||||
|
|
||||||
|
@ -320,12 +320,19 @@ int main(int argc, char **argv, char **envp ) {
|
|||||||
|
|
||||||
// Generate an assembly language file for the bytecode.
|
// Generate an assembly language file for the bytecode.
|
||||||
if (Verbose) std::cout << "Generating Assembly Code\n";
|
if (Verbose) std::cout << "Generating Assembly Code\n";
|
||||||
GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc,
|
std::string ErrMsg;
|
||||||
Verbose);
|
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";
|
if (Verbose) std::cout << "Generating Native Code\n";
|
||||||
GenerateNative(OutputFilename, AssemblyFile.toString(),
|
if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(),
|
||||||
LibPaths, Libraries, gcc, envp, LinkAsLibrary,
|
LibPaths, Libraries, gcc, envp, LinkAsLibrary,
|
||||||
NoInternalize, RPath, SOName, Verbose);
|
NoInternalize, RPath, SOName, ErrMsg, Verbose) ) {
|
||||||
|
std::cerr << argv[0] << ": " << ErrMsg << "\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (!SaveTemps) {
|
if (!SaveTemps) {
|
||||||
// Remove the assembly language file.
|
// 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.
|
// Generate an assembly language file for the bytecode.
|
||||||
if (Verbose) std::cout << "Generating C Source Code\n";
|
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";
|
if (Verbose) std::cout << "Generating Native Code\n";
|
||||||
GenerateNative(OutputFilename, CFile.toString(),
|
if (0 != GenerateNative(OutputFilename, CFile.toString(),
|
||||||
LibPaths, Libraries, gcc, envp, LinkAsLibrary,
|
LibPaths, Libraries, gcc, envp, LinkAsLibrary,
|
||||||
NoInternalize, RPath, SOName, Verbose);
|
NoInternalize, RPath, SOName, ErrMsg, Verbose)) {
|
||||||
|
std::cerr << argv[0] << ": " << ErrMsg << "\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (!SaveTemps) {
|
if (!SaveTemps) {
|
||||||
// Remove the assembly language file.
|
// Remove the assembly language file.
|
||||||
|
@ -30,12 +30,14 @@ int
|
|||||||
GenerateAssembly (const std::string &OutputFilename,
|
GenerateAssembly (const std::string &OutputFilename,
|
||||||
const std::string &InputFilename,
|
const std::string &InputFilename,
|
||||||
const sys::Path &llc,
|
const sys::Path &llc,
|
||||||
|
std::string& ErrMsg,
|
||||||
bool Verbose=false);
|
bool Verbose=false);
|
||||||
|
|
||||||
int
|
int
|
||||||
GenerateCFile (const std::string &OutputFile,
|
GenerateCFile (const std::string &OutputFile,
|
||||||
const std::string &InputFile,
|
const std::string &InputFile,
|
||||||
const sys::Path &llc,
|
const sys::Path &llc,
|
||||||
|
std::string& ErrMsg,
|
||||||
bool Verbose=false);
|
bool Verbose=false);
|
||||||
int
|
int
|
||||||
GenerateNative (const std::string &OutputFilename,
|
GenerateNative (const std::string &OutputFilename,
|
||||||
@ -48,6 +50,7 @@ GenerateNative (const std::string &OutputFilename,
|
|||||||
bool ExportAllAsDynamic,
|
bool ExportAllAsDynamic,
|
||||||
const std::vector<std::string> &RPath,
|
const std::vector<std::string> &RPath,
|
||||||
const std::string &SOName,
|
const std::string &SOName,
|
||||||
|
std::string& ErrMsg,
|
||||||
bool Verbose=false);
|
bool Verbose=false);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@ -227,7 +227,8 @@ void GenerateBytecode(Module* M, const std::string& FileName) {
|
|||||||
///
|
///
|
||||||
static int GenerateAssembly(const std::string &OutputFilename,
|
static int GenerateAssembly(const std::string &OutputFilename,
|
||||||
const std::string &InputFilename,
|
const std::string &InputFilename,
|
||||||
const sys::Path &llc) {
|
const sys::Path &llc,
|
||||||
|
std::string &ErrMsg ) {
|
||||||
// Run LLC to convert the bytecode file into assembly code.
|
// Run LLC to convert the bytecode file into assembly code.
|
||||||
std::vector<const char*> args;
|
std::vector<const char*> args;
|
||||||
args.push_back(llc.c_str());
|
args.push_back(llc.c_str());
|
||||||
@ -237,13 +238,14 @@ static int GenerateAssembly(const std::string &OutputFilename,
|
|||||||
args.push_back(InputFilename.c_str());
|
args.push_back(InputFilename.c_str());
|
||||||
args.push_back(0);
|
args.push_back(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.
|
/// GenerateCFile - generates a C source file from the specified bytecode file.
|
||||||
static int GenerateCFile(const std::string &OutputFile,
|
static int GenerateCFile(const std::string &OutputFile,
|
||||||
const std::string &InputFile,
|
const std::string &InputFile,
|
||||||
const sys::Path &llc) {
|
const sys::Path &llc,
|
||||||
|
std::string& ErrMsg) {
|
||||||
// Run LLC to convert the bytecode file into C.
|
// Run LLC to convert the bytecode file into C.
|
||||||
std::vector<const char*> args;
|
std::vector<const char*> args;
|
||||||
args.push_back(llc.c_str());
|
args.push_back(llc.c_str());
|
||||||
@ -253,7 +255,7 @@ static int GenerateCFile(const std::string &OutputFile,
|
|||||||
args.push_back(OutputFile.c_str());
|
args.push_back(OutputFile.c_str());
|
||||||
args.push_back(InputFile.c_str());
|
args.push_back(InputFile.c_str());
|
||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
return sys::Program::ExecuteAndWait(llc, &args[0]);
|
return sys::Program::ExecuteAndWait(llc, &args[0],0,0,0,&ErrMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GenerateNative - generates a native object file from the
|
/// GenerateNative - generates a native object file from the
|
||||||
@ -275,7 +277,8 @@ static int GenerateCFile(const std::string &OutputFile,
|
|||||||
static int GenerateNative(const std::string &OutputFilename,
|
static int GenerateNative(const std::string &OutputFilename,
|
||||||
const std::string &InputFilename,
|
const std::string &InputFilename,
|
||||||
const std::vector<std::string> &Libraries,
|
const std::vector<std::string> &Libraries,
|
||||||
const sys::Path &gcc, char ** const envp) {
|
const sys::Path &gcc, char ** const envp,
|
||||||
|
std::string& ErrMsg) {
|
||||||
// Remove these environment variables from the environment of the
|
// Remove these environment variables from the environment of the
|
||||||
// programs that we will execute. It appears that GCC sets these
|
// programs that we will execute. It appears that GCC sets these
|
||||||
// environment variables so that the programs it uses can configure
|
// environment variables so that the programs it uses can configure
|
||||||
@ -329,7 +332,8 @@ static int GenerateNative(const std::string &OutputFilename,
|
|||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
|
|
||||||
// Run the compiler to assembly and link together the program.
|
// Run the compiler to assembly and link together the program.
|
||||||
int R = sys::Program::ExecuteAndWait(gcc, &args[0], (const char**)clean_env);
|
int R = sys::Program::ExecuteAndWait(
|
||||||
|
gcc, &args[0], (const char**)clean_env,0,0,&ErrMsg);
|
||||||
delete [] clean_env;
|
delete [] clean_env;
|
||||||
return R;
|
return R;
|
||||||
}
|
}
|
||||||
@ -497,7 +501,8 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
args[1] = RealBytecodeOutput.c_str();
|
args[1] = RealBytecodeOutput.c_str();
|
||||||
args[2] = tmp_output.c_str();
|
args[2] = tmp_output.c_str();
|
||||||
args[3] = 0;
|
args[3] = 0;
|
||||||
if (0 == sys::Program::ExecuteAndWait(prog, args)) {
|
std::string ErrMsg;
|
||||||
|
if (0 == sys::Program::ExecuteAndWait(prog, args, 0,0,0, &ErrMsg)) {
|
||||||
if (tmp_output.isBytecodeFile()) {
|
if (tmp_output.isBytecodeFile()) {
|
||||||
sys::Path target(RealBytecodeOutput);
|
sys::Path target(RealBytecodeOutput);
|
||||||
target.eraseFromDisk();
|
target.eraseFromDisk();
|
||||||
@ -505,6 +510,9 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
} else
|
} else
|
||||||
return PrintAndReturn(
|
return PrintAndReturn(
|
||||||
"Post-link optimization output is not bytecode");
|
"Post-link optimization output is not bytecode");
|
||||||
|
} else {
|
||||||
|
std::cerr << argv[0] << ": " << ErrMsg << "\n";
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -533,10 +541,19 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
// Generate an assembly language file for the bytecode.
|
// Generate an assembly language file for the bytecode.
|
||||||
if (Verbose) std::cout << "Generating Assembly Code\n";
|
if (Verbose) std::cout << "Generating Assembly Code\n";
|
||||||
GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc);
|
std::string ErrMsg;
|
||||||
|
if (0 != GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput,
|
||||||
|
llc, ErrMsg)) {
|
||||||
|
std::cerr << argv[0] << ": " << ErrMsg << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (Verbose) std::cout << "Generating Native Code\n";
|
if (Verbose) std::cout << "Generating Native Code\n";
|
||||||
GenerateNative(OutputFilename, AssemblyFile.toString(), Libraries,
|
if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(),
|
||||||
gcc, envp);
|
Libraries,gcc,envp,ErrMsg)) {
|
||||||
|
std::cerr << argv[0] << ": " << ErrMsg << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the assembly language file.
|
// Remove the assembly language file.
|
||||||
AssemblyFile.eraseFromDisk();
|
AssemblyFile.eraseFromDisk();
|
||||||
@ -559,9 +576,19 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
// Generate an assembly language file for the bytecode.
|
// Generate an assembly language file for the bytecode.
|
||||||
if (Verbose) std::cout << "Generating Assembly Code\n";
|
if (Verbose) std::cout << "Generating Assembly Code\n";
|
||||||
GenerateCFile(CFile.toString(), RealBytecodeOutput, llc);
|
std::string ErrMsg;
|
||||||
|
if (0 != GenerateCFile(
|
||||||
|
CFile.toString(), RealBytecodeOutput, llc, ErrMsg)) {
|
||||||
|
std::cerr << argv[0] << ": " << ErrMsg << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (Verbose) std::cout << "Generating Native Code\n";
|
if (Verbose) std::cout << "Generating Native Code\n";
|
||||||
GenerateNative(OutputFilename, CFile.toString(), Libraries, gcc, envp);
|
if (0 != GenerateNative(OutputFilename, CFile.toString(), Libraries,
|
||||||
|
gcc, envp, ErrMsg)) {
|
||||||
|
std::cerr << argv[0] << ": " << ErrMsg << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the assembly language file.
|
// Remove the assembly language file.
|
||||||
CFile.eraseFromDisk();
|
CFile.eraseFromDisk();
|
||||||
|
@ -451,7 +451,7 @@ private:
|
|||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoAction(Action*action) {
|
int DoAction(Action*action, std::string& ErrMsg) {
|
||||||
assert(action != 0 && "Invalid Action!");
|
assert(action != 0 && "Invalid Action!");
|
||||||
if (isSet(VERBOSE_FLAG))
|
if (isSet(VERBOSE_FLAG))
|
||||||
WriteAction(action);
|
WriteAction(action);
|
||||||
@ -477,15 +477,17 @@ private:
|
|||||||
if (isSet(TIME_ACTIONS_FLAG)) {
|
if (isSet(TIME_ACTIONS_FLAG)) {
|
||||||
Timer timer(action->program.toString());
|
Timer timer(action->program.toString());
|
||||||
timer.startTimer();
|
timer.startTimer();
|
||||||
int resultCode = sys::Program::ExecuteAndWait(action->program, Args);
|
int resultCode =
|
||||||
|
sys::Program::ExecuteAndWait(action->program, Args,0,0,0,&ErrMsg);
|
||||||
timer.stopTimer();
|
timer.stopTimer();
|
||||||
timer.print(timer,std::cerr);
|
timer.print(timer,std::cerr);
|
||||||
return resultCode == 0;
|
return resultCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0 == sys::Program::ExecuteAndWait(action->program, Args);
|
return
|
||||||
|
sys::Program::ExecuteAndWait(action->program, Args, 0,0,0, &ErrMsg);
|
||||||
}
|
}
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This method tries various variants of a linkage item's file
|
/// This method tries various variants of a linkage item's file
|
||||||
@ -594,7 +596,7 @@ private:
|
|||||||
/// @name Methods
|
/// @name Methods
|
||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
virtual int execute(const InputList& InpList, const sys::Path& Output ) {
|
virtual int execute(const InputList& InpList, const sys::Path& Output, std::string& ErrMsg ) {
|
||||||
try {
|
try {
|
||||||
// Echo the configuration of options if we're running verbose
|
// Echo the configuration of options if we're running verbose
|
||||||
if (isSet(DEBUG_FLAG)) {
|
if (isSet(DEBUG_FLAG)) {
|
||||||
@ -851,8 +853,9 @@ public:
|
|||||||
std::vector<Action*>::iterator AI = actions.begin();
|
std::vector<Action*>::iterator AI = actions.begin();
|
||||||
std::vector<Action*>::iterator AE = actions.end();
|
std::vector<Action*>::iterator AE = actions.end();
|
||||||
while (AI != AE) {
|
while (AI != AE) {
|
||||||
if (!DoAction(*AI))
|
int ActionResult = DoAction(*AI, ErrMsg);
|
||||||
throw std::string("Action failed");
|
if (ActionResult != 0)
|
||||||
|
return ActionResult;
|
||||||
AI++;
|
AI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,8 +935,9 @@ public:
|
|||||||
link->args.push_back(Output.toString());
|
link->args.push_back(Output.toString());
|
||||||
|
|
||||||
// Execute the link
|
// Execute the link
|
||||||
if (!DoAction(link))
|
int ActionResult = DoAction(link, ErrMsg);
|
||||||
throw std::string("Action failed");
|
if (ActionResult != 0)
|
||||||
|
return ActionResult;
|
||||||
}
|
}
|
||||||
} catch (std::string& msg) {
|
} catch (std::string& msg) {
|
||||||
cleanup();
|
cleanup();
|
||||||
|
@ -150,7 +150,8 @@ namespace llvm {
|
|||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
/// @brief Execute the actions requested for the given input list.
|
/// @brief Execute the actions requested for the given input list.
|
||||||
virtual int execute(const InputList& list, const sys::Path& output) = 0;
|
virtual int execute(
|
||||||
|
const InputList& list, const sys::Path& output, std::string& ErrMsg) =0;
|
||||||
|
|
||||||
/// @brief Set the final phase at which compilation terminates
|
/// @brief Set the final phase at which compilation terminates
|
||||||
virtual void setFinalPhase(Phases phase) = 0;
|
virtual void setFinalPhase(Phases phase) = 0;
|
||||||
|
@ -355,9 +355,10 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tell the driver to do its thing
|
// Tell the driver to do its thing
|
||||||
int result = CD->execute(InpList, sys::Path(OutputFilename));
|
std::string ErrMsg;
|
||||||
|
int result = CD->execute(InpList, sys::Path(OutputFilename), ErrMsg);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
throw std::string("Error executing actions. Terminated.");
|
std::cerr << argv[0] << ": " << ErrMsg << '\n';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user