mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Added the use of the const keyword.
Have gccld find the path to llc and gcc instead of having the library do it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8586 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -339,7 +339,7 @@ static int PrintAndReturn(const char *progname, const std::string &Message,
|
|||||||
// not copy the char *'s from one array to another).
|
// not copy the char *'s from one array to another).
|
||||||
//
|
//
|
||||||
static char **
|
static char **
|
||||||
copy_env (char ** envp)
|
copy_env (char ** const envp)
|
||||||
{
|
{
|
||||||
// The new environment list
|
// The new environment list
|
||||||
char ** newenv;
|
char ** newenv;
|
||||||
@@ -414,7 +414,7 @@ copy_env (char ** envp)
|
|||||||
// undocumented if they do exist).
|
// undocumented if they do exist).
|
||||||
//
|
//
|
||||||
static void
|
static void
|
||||||
remove_env (const char * name, char ** envp)
|
remove_env (const char * name, char ** const envp)
|
||||||
{
|
{
|
||||||
// Pointer for scanning arrays
|
// Pointer for scanning arrays
|
||||||
register char * p;
|
register char * p;
|
||||||
@@ -601,18 +601,33 @@ int main(int argc, char **argv, char ** envp) {
|
|||||||
remove_env ("COMPILER_PATH", clean_env);
|
remove_env ("COMPILER_PATH", clean_env);
|
||||||
remove_env ("COLLECT_GCC", clean_env);
|
remove_env ("COLLECT_GCC", clean_env);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine the locations of the llc and gcc programs.
|
||||||
|
//
|
||||||
|
std::string llc=FindExecutable ("llc", argv[0]);
|
||||||
|
std::string gcc=FindExecutable ("gcc", argv[0]);
|
||||||
|
if (llc.empty())
|
||||||
|
{
|
||||||
|
return PrintAndReturn (argv[0], "Failed to find llc");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gcc.empty())
|
||||||
|
{
|
||||||
|
return PrintAndReturn (argv[0], "Failed to find gcc");
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Run LLC to convert the bytecode file into assembly code.
|
// Run LLC to convert the bytecode file into assembly code.
|
||||||
//
|
//
|
||||||
char * cmd[8];
|
const char * cmd[8];
|
||||||
std::string AssemblyFile = OutputFilename + ".s";
|
std::string AssemblyFile = OutputFilename + ".s";
|
||||||
|
|
||||||
cmd[0] = (char *) "llc";
|
cmd[0] = llc.c_str();
|
||||||
cmd[1] = (char *) "-f";
|
cmd[1] = "-f";
|
||||||
cmd[2] = (char *) "-o";
|
cmd[2] = "-o";
|
||||||
cmd[3] = (char *) AssemblyFile.c_str();
|
cmd[3] = AssemblyFile.c_str();
|
||||||
cmd[4] = (char *) RealBytecodeOutput.c_str();
|
cmd[4] = RealBytecodeOutput.c_str();
|
||||||
cmd[5] = (char *) NULL;
|
cmd[5] = NULL;
|
||||||
if ((ExecWait (cmd, clean_env)) == -1)
|
if ((ExecWait (cmd, clean_env)) == -1)
|
||||||
{
|
{
|
||||||
return PrintAndReturn (argv[0], "Failed to compile bytecode");
|
return PrintAndReturn (argv[0], "Failed to compile bytecode");
|
||||||
@@ -626,11 +641,11 @@ int main(int argc, char **argv, char ** envp) {
|
|||||||
// and linker because we don't know where to put the _start symbol.
|
// and linker because we don't know where to put the _start symbol.
|
||||||
// GCC mysteriously knows how to do it.
|
// GCC mysteriously knows how to do it.
|
||||||
//
|
//
|
||||||
cmd[0] = (char *) "gcc";
|
cmd[0] = gcc.c_str();
|
||||||
cmd[1] = (char *) "-o";
|
cmd[1] = "-o";
|
||||||
cmd[2] = (char *) OutputFilename.c_str();
|
cmd[2] = OutputFilename.c_str();
|
||||||
cmd[3] = (char *) AssemblyFile.c_str();
|
cmd[3] = AssemblyFile.c_str();
|
||||||
cmd[4] = (char *) NULL;
|
cmd[4] = NULL;
|
||||||
if ((ExecWait (cmd, clean_env)) == -1)
|
if ((ExecWait (cmd, clean_env)) == -1)
|
||||||
{
|
{
|
||||||
return PrintAndReturn (argv[0], "Failed to link native code file");
|
return PrintAndReturn (argv[0], "Failed to link native code file");
|
||||||
|
Reference in New Issue
Block a user