summaryrefslogtreecommitdiff
path: root/tools/gccld/gccld.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-06 16:43:13 +0000
committerChris Lattner <sabre@nondot.org>2004-04-06 16:43:13 +0000
commit69e8d282bf7b34b3e86c57c8fa17cda9ab8e69aa (patch)
treec2f3f2152616a2667a11802013a0c153dcece10d /tools/gccld/gccld.cpp
parente80e637793d3ff3808e564b304b2831f6c7a1625 (diff)
downloadllvm-69e8d282bf7b34b3e86c57c8fa17cda9ab8e69aa.tar.gz
llvm-69e8d282bf7b34b3e86c57c8fa17cda9ab8e69aa.tar.bz2
llvm-69e8d282bf7b34b3e86c57c8fa17cda9ab8e69aa.tar.xz
Add a new gccld -native-cbe option which causes gccld to generate native code
for the application with the C backend instead of the native LLVM code generator git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/gccld/gccld.cpp')
-rw-r--r--tools/gccld/gccld.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp
index 0f5bc18a31..389a6b13da 100644
--- a/tools/gccld/gccld.cpp
+++ b/tools/gccld/gccld.cpp
@@ -78,6 +78,9 @@ namespace {
cl::opt<bool>
Native("native",
cl::desc("Generate a native binary instead of a shell script"));
+ cl::opt<bool>
+ NativeCBE("native-cbe",
+ cl::desc("Generate a native binary with the C backend and GCC"));
// Compatibility options that are ignored but supported by LD
cl::opt<std::string>
@@ -276,6 +279,30 @@ int main(int argc, char **argv, char **envp) {
// Remove the assembly language file.
removeFile (AssemblyFile);
+ } else if (NativeCBE) {
+ std::string CFile = OutputFilename + ".cbe.c";
+
+ // Mark the output files for removal if we get an interrupt.
+ RemoveFileOnSignal(CFile);
+ RemoveFileOnSignal(OutputFilename);
+
+ // 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");
+
+ // Generate an assembly language file for the bytecode.
+ if (Verbose) std::cout << "Generating Assembly Code\n";
+ GenerateCFile(CFile, RealBytecodeOutput, llc, envp);
+ if (Verbose) std::cout << "Generating Native Code\n";
+ GenerateNative(OutputFilename, CFile, Libraries, LibPaths, gcc, envp);
+
+ // Remove the assembly language file.
+ removeFile(CFile);
+
} else {
// Output the script to start the program...
std::ofstream Out2(OutputFilename.c_str());