Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 1 | //===- gccld.cpp - LLVM 'ld' compatible linker ----------------------------===// |
John Criswell | 7c0e022 | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 9 | // |
| 10 | // This utility is intended to be compatible with GCC, and follows standard |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 11 | // system 'ld' conventions. As such, the default output file is ./a.out. |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 12 | // Additionally, this program outputs a shell script that is used to invoke LLI |
| 13 | // to execute the program. In this manner, the generated executable (a.out for |
| 14 | // example), is directly executable, whereas the bytecode file actually lives in |
| 15 | // the a.out.bc file generated by this program. Also, Force is on by default. |
| 16 | // |
| 17 | // Note that if someone (or a script) deletes the executable program generated, |
| 18 | // the .bc file will be left around. Considering that this is a temporary hack, |
Brian Gaeke | 69a7960 | 2003-05-23 20:27:07 +0000 | [diff] [blame] | 19 | // I'm not too worried about this. |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 20 | // |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | |
Chris Lattner | 6e27123 | 2003-09-22 20:21:34 +0000 | [diff] [blame] | 23 | #include "gccld.h" |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 24 | #include "llvm/Module.h" |
Chris Lattner | ad202a0 | 2002-04-08 00:14:58 +0000 | [diff] [blame] | 25 | #include "llvm/PassManager.h" |
| 26 | #include "llvm/Bytecode/Reader.h" |
| 27 | #include "llvm/Bytecode/WriteBytecodePass.h" |
Chris Lattner | 9c3b55e | 2003-04-24 19:13:02 +0000 | [diff] [blame] | 28 | #include "llvm/Target/TargetData.h" |
Chris Lattner | d9d8c07 | 2002-07-23 22:04:43 +0000 | [diff] [blame] | 29 | #include "llvm/Transforms/IPO.h" |
Chris Lattner | d9d8c07 | 2002-07-23 22:04:43 +0000 | [diff] [blame] | 30 | #include "llvm/Transforms/Scalar.h" |
Misha Brukman | 008248f | 2004-06-23 17:33:09 +0000 | [diff] [blame] | 31 | #include "llvm/Support/Linker.h" |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 32 | #include "Support/CommandLine.h" |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 33 | #include "Support/FileUtilities.h" |
Chris Lattner | bed85ff | 2004-05-27 05:41:36 +0000 | [diff] [blame] | 34 | #include "llvm/System/Signals.h" |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 35 | #include "Support/SystemUtils.h" |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 36 | #include <fstream> |
| 37 | #include <memory> |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 38 | using namespace llvm; |
| 39 | |
Chris Lattner | f3d4f17 | 2003-04-18 23:01:25 +0000 | [diff] [blame] | 40 | namespace { |
| 41 | cl::list<std::string> |
| 42 | InputFilenames(cl::Positional, cl::desc("<input bytecode files>"), |
| 43 | cl::OneOrMore); |
Chris Lattner | 5ff62e9 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 44 | |
Chris Lattner | f3d4f17 | 2003-04-18 23:01:25 +0000 | [diff] [blame] | 45 | cl::opt<std::string> |
| 46 | OutputFilename("o", cl::desc("Override output filename"), cl::init("a.out"), |
| 47 | cl::value_desc("filename")); |
Chris Lattner | 5ff62e9 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 48 | |
Chris Lattner | f3d4f17 | 2003-04-18 23:01:25 +0000 | [diff] [blame] | 49 | cl::opt<bool> |
| 50 | Verbose("v", cl::desc("Print information about actions taken")); |
| 51 | |
| 52 | cl::list<std::string> |
| 53 | LibPaths("L", cl::desc("Specify a library search path"), cl::Prefix, |
| 54 | cl::value_desc("directory")); |
Chris Lattner | 5ff62e9 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 55 | |
Chris Lattner | f3d4f17 | 2003-04-18 23:01:25 +0000 | [diff] [blame] | 56 | cl::list<std::string> |
| 57 | Libraries("l", cl::desc("Specify libraries to link to"), cl::Prefix, |
| 58 | cl::value_desc("library prefix")); |
Chris Lattner | 5ff62e9 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 59 | |
Chris Lattner | f3d4f17 | 2003-04-18 23:01:25 +0000 | [diff] [blame] | 60 | cl::opt<bool> |
| 61 | Strip("s", cl::desc("Strip symbol info from executable")); |
Chris Lattner | 5ff62e9 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 62 | |
Chris Lattner | f3d4f17 | 2003-04-18 23:01:25 +0000 | [diff] [blame] | 63 | cl::opt<bool> |
| 64 | NoInternalize("disable-internalize", |
| 65 | cl::desc("Do not mark all symbols as internal")); |
Chris Lattner | fe32bf5 | 2003-11-05 06:05:21 +0000 | [diff] [blame] | 66 | cl::alias |
Chris Lattner | a2b2dc9 | 2003-08-22 19:18:45 +0000 | [diff] [blame] | 67 | ExportDynamic("export-dynamic", cl::desc("Alias for -disable-internalize"), |
| 68 | cl::aliasopt(NoInternalize)); |
Chris Lattner | a856db2 | 2003-04-18 23:38:22 +0000 | [diff] [blame] | 69 | |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 70 | cl::opt<bool> |
| 71 | LinkAsLibrary("link-as-library", cl::desc("Link the .bc files together as a" |
| 72 | " library, not an executable")); |
Chris Lattner | fe32bf5 | 2003-11-05 06:05:21 +0000 | [diff] [blame] | 73 | cl::alias |
| 74 | Relink("r", cl::desc("Alias for -link-as-library"), |
| 75 | cl::aliasopt(LinkAsLibrary)); |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 76 | |
John Criswell | dabaf7d | 2003-09-16 21:27:35 +0000 | [diff] [blame] | 77 | cl::opt<bool> |
Chris Lattner | 6e27123 | 2003-09-22 20:21:34 +0000 | [diff] [blame] | 78 | Native("native", |
| 79 | cl::desc("Generate a native binary instead of a shell script")); |
Chris Lattner | 69e8d28 | 2004-04-06 16:43:13 +0000 | [diff] [blame] | 80 | cl::opt<bool> |
| 81 | NativeCBE("native-cbe", |
| 82 | cl::desc("Generate a native binary with the C backend and GCC")); |
John Criswell | dabaf7d | 2003-09-16 21:27:35 +0000 | [diff] [blame] | 83 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 84 | // Compatibility options that are ignored but supported by LD |
Chris Lattner | a856db2 | 2003-04-18 23:38:22 +0000 | [diff] [blame] | 85 | cl::opt<std::string> |
| 86 | CO3("soname", cl::Hidden, cl::desc("Compatibility option: ignored")); |
| 87 | cl::opt<std::string> |
| 88 | CO4("version-script", cl::Hidden, cl::desc("Compatibility option: ignored")); |
| 89 | cl::opt<bool> |
| 90 | CO5("eh-frame-hdr", cl::Hidden, cl::desc("Compatibility option: ignored")); |
John Criswell | aa2a47d | 2003-12-09 15:39:11 +0000 | [diff] [blame] | 91 | cl::opt<std::string> |
| 92 | CO6("h", cl::Hidden, cl::desc("Compatibility option: ignored")); |
Chris Lattner | f3d4f17 | 2003-04-18 23:01:25 +0000 | [diff] [blame] | 93 | } |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 94 | |
Chris Lattner | 0ebee74 | 2004-06-02 00:22:24 +0000 | [diff] [blame] | 95 | /// PrintAndReturn - Prints a message to standard error and returns true. |
Misha Brukman | 9839969 | 2003-11-20 06:21:54 +0000 | [diff] [blame] | 96 | /// |
| 97 | /// Inputs: |
| 98 | /// progname - The name of the program (i.e. argv[0]). |
| 99 | /// Message - The message to print to standard error. |
Misha Brukman | 9839969 | 2003-11-20 06:21:54 +0000 | [diff] [blame] | 100 | /// |
Chris Lattner | 0ebee74 | 2004-06-02 00:22:24 +0000 | [diff] [blame] | 101 | static int PrintAndReturn(const char *progname, const std::string &Message) { |
| 102 | std::cerr << progname << ": " << Message << "\n"; |
John Criswell | 71478b7 | 2003-09-19 20:24:23 +0000 | [diff] [blame] | 103 | return 1; |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Chris Lattner | 7e88d41 | 2004-06-02 00:10:19 +0000 | [diff] [blame] | 106 | /// EmitShellScript - Output the wrapper file that invokes the JIT on the LLVM |
| 107 | /// bytecode file for the program. |
| 108 | static void EmitShellScript(char **argv) { |
Chris Lattner | 681692d | 2004-06-02 00:53:57 +0000 | [diff] [blame] | 109 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 110 | // Windows doesn't support #!/bin/sh style shell scripts in .exe files. To |
| 111 | // support windows systems, we copy the llvm-stub.exe executable from the |
| 112 | // build tree to the destination file. |
| 113 | std::string llvmstub = FindExecutable("llvm-stub.exe", argv[0]); |
| 114 | if (llvmstub.empty()) { |
| 115 | std::cerr << "Could not find llvm-stub.exe executable!\n"; |
| 116 | exit(1); |
| 117 | } |
| 118 | if (CopyFile(OutputFilename, llvmstub)) { |
| 119 | std::cerr << "Could not copy the llvm-stub.exe executable!\n"; |
| 120 | exit(1); |
| 121 | } |
| 122 | return; |
| 123 | #endif |
| 124 | |
Chris Lattner | 7e88d41 | 2004-06-02 00:10:19 +0000 | [diff] [blame] | 125 | // Output the script to start the program... |
| 126 | std::ofstream Out2(OutputFilename.c_str()); |
| 127 | if (!Out2.good()) |
| 128 | exit(PrintAndReturn(argv[0], "error opening '" + OutputFilename + |
| 129 | "' for writing!")); |
| 130 | |
| 131 | Out2 << "#!/bin/sh\n"; |
| 132 | // Allow user to setenv LLVMINTERP if lli is not in their PATH. |
| 133 | Out2 << "lli=${LLVMINTERP-lli}\n"; |
| 134 | Out2 << "exec $lli \\\n"; |
| 135 | // gcc accepts -l<lib> and implicitly searches /lib and /usr/lib. |
| 136 | LibPaths.push_back("/lib"); |
| 137 | LibPaths.push_back("/usr/lib"); |
| 138 | LibPaths.push_back("/usr/X11R6/lib"); |
| 139 | // We don't need to link in libc! In fact, /usr/lib/libc.so may not be a |
| 140 | // shared object at all! See RH 8: plain text. |
| 141 | std::vector<std::string>::iterator libc = |
| 142 | std::find(Libraries.begin(), Libraries.end(), "c"); |
| 143 | if (libc != Libraries.end()) Libraries.erase(libc); |
| 144 | // List all the shared object (native) libraries this executable will need |
| 145 | // on the command line, so that we don't have to do this manually! |
| 146 | for (std::vector<std::string>::iterator i = Libraries.begin(), |
| 147 | e = Libraries.end(); i != e; ++i) { |
| 148 | std::string FullLibraryPath = FindLib(*i, LibPaths, true); |
| 149 | if (!FullLibraryPath.empty() && IsSharedObject(FullLibraryPath)) |
| 150 | Out2 << " -load=" << FullLibraryPath << " \\\n"; |
| 151 | } |
| 152 | Out2 << " $0.bc ${1+\"$@\"}\n"; |
| 153 | Out2.close(); |
| 154 | } |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 155 | |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 156 | int main(int argc, char **argv, char **envp) { |
Chris Lattner | 5ff62e9 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 157 | cl::ParseCommandLineOptions(argc, argv, " llvm linker for GCC\n"); |
Chris Lattner | 364d120 | 2004-02-19 20:32:39 +0000 | [diff] [blame] | 158 | PrintStackTraceOnErrorSignal(); |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 159 | |
Misha Brukman | 9839969 | 2003-11-20 06:21:54 +0000 | [diff] [blame] | 160 | std::string ModuleID("gccld-output"); |
Brian Gaeke | 00cc86a | 2003-11-05 22:13:00 +0000 | [diff] [blame] | 161 | std::auto_ptr<Module> Composite(new Module(ModuleID)); |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 162 | |
Brian Gaeke | 69a7960 | 2003-05-23 20:27:07 +0000 | [diff] [blame] | 163 | // We always look first in the current directory when searching for libraries. |
| 164 | LibPaths.insert(LibPaths.begin(), "."); |
| 165 | |
Misha Brukman | cf00c4a | 2003-10-10 17:57:28 +0000 | [diff] [blame] | 166 | // If the user specified an extra search path in their environment, respect |
| 167 | // it. |
Chris Lattner | d34a51d | 2003-04-21 19:53:24 +0000 | [diff] [blame] | 168 | if (char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH")) |
| 169 | LibPaths.push_back(SearchPath); |
| 170 | |
Chris Lattner | c65b104 | 2003-04-19 23:07:33 +0000 | [diff] [blame] | 171 | // Remove any consecutive duplicates of the same library... |
| 172 | Libraries.erase(std::unique(Libraries.begin(), Libraries.end()), |
| 173 | Libraries.end()); |
| 174 | |
John Criswell | 71478b7 | 2003-09-19 20:24:23 +0000 | [diff] [blame] | 175 | // Link in all of the files |
Brian Gaeke | e98ddfc | 2003-09-30 14:03:48 +0000 | [diff] [blame] | 176 | if (LinkFiles(argv[0], Composite.get(), InputFilenames, Verbose)) |
| 177 | return 1; // Error already printed |
Chris Lattner | fd35c64 | 2003-11-03 17:27:17 +0000 | [diff] [blame] | 178 | |
| 179 | if (!LinkAsLibrary) |
| 180 | LinkLibraries(argv[0], Composite.get(), Libraries, LibPaths, |
| 181 | Verbose, Native); |
John Criswell | 71478b7 | 2003-09-19 20:24:23 +0000 | [diff] [blame] | 182 | |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 183 | // Link in all of the libraries next... |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 184 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 185 | // Create the output file. |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 186 | std::string RealBytecodeOutput = OutputFilename; |
| 187 | if (!LinkAsLibrary) RealBytecodeOutput += ".bc"; |
| 188 | std::ofstream Out(RealBytecodeOutput.c_str()); |
| 189 | if (!Out.good()) |
| 190 | return PrintAndReturn(argv[0], "error opening '" + RealBytecodeOutput + |
| 191 | "' for writing!"); |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 192 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 193 | // Ensure that the bytecode file gets removed from the disk if we get a |
| 194 | // SIGINT signal. |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 195 | RemoveFileOnSignal(RealBytecodeOutput); |
Chris Lattner | 76d1229 | 2002-04-18 19:55:25 +0000 | [diff] [blame] | 196 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 197 | // Generate the bytecode file. |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 198 | if (GenerateBytecode(Composite.get(), Strip, !NoInternalize, &Out)) { |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 199 | Out.close(); |
Brian Gaeke | 00cc86a | 2003-11-05 22:13:00 +0000 | [diff] [blame] | 200 | return PrintAndReturn(argv[0], "error generating bytecode"); |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 201 | } |
| 202 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 203 | // Close the bytecode file. |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 204 | Out.close(); |
| 205 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 206 | // If we are not linking a library, generate either a native executable |
| 207 | // or a JIT shell script, depending upon what the user wants. |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 208 | if (!LinkAsLibrary) { |
John Criswell | dabaf7d | 2003-09-16 21:27:35 +0000 | [diff] [blame] | 209 | // If the user wants to generate a native executable, compile it from the |
| 210 | // bytecode file. |
| 211 | // |
| 212 | // Otherwise, create a script that will run the bytecode through the JIT. |
Chris Lattner | 6e27123 | 2003-09-22 20:21:34 +0000 | [diff] [blame] | 213 | if (Native) { |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 214 | // Name of the Assembly Language output file |
| 215 | std::string AssemblyFile = OutputFilename + ".s"; |
| 216 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 217 | // Mark the output files for removal if we get an interrupt. |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 218 | RemoveFileOnSignal(AssemblyFile); |
| 219 | RemoveFileOnSignal(OutputFilename); |
John Criswell | dabaf7d | 2003-09-16 21:27:35 +0000 | [diff] [blame] | 220 | |
John Criswell | 83ca6ec | 2003-09-17 19:04:22 +0000 | [diff] [blame] | 221 | // Determine the locations of the llc and gcc programs. |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 222 | std::string llc = FindExecutable("llc", argv[0]); |
| 223 | std::string gcc = FindExecutable("gcc", argv[0]); |
John Criswell | 83ca6ec | 2003-09-17 19:04:22 +0000 | [diff] [blame] | 224 | if (llc.empty()) |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 225 | return PrintAndReturn(argv[0], "Failed to find llc"); |
John Criswell | 83ca6ec | 2003-09-17 19:04:22 +0000 | [diff] [blame] | 226 | |
| 227 | if (gcc.empty()) |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 228 | return PrintAndReturn(argv[0], "Failed to find gcc"); |
John Criswell | 83ca6ec | 2003-09-17 19:04:22 +0000 | [diff] [blame] | 229 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 230 | // Generate an assembly language file for the bytecode. |
John Criswell | 71478b7 | 2003-09-19 20:24:23 +0000 | [diff] [blame] | 231 | if (Verbose) std::cout << "Generating Assembly Code\n"; |
Chris Lattner | 6e27123 | 2003-09-22 20:21:34 +0000 | [diff] [blame] | 232 | GenerateAssembly(AssemblyFile, RealBytecodeOutput, llc, envp); |
John Criswell | 71478b7 | 2003-09-19 20:24:23 +0000 | [diff] [blame] | 233 | if (Verbose) std::cout << "Generating Native Code\n"; |
Chris Lattner | 6e27123 | 2003-09-22 20:21:34 +0000 | [diff] [blame] | 234 | GenerateNative(OutputFilename, AssemblyFile, Libraries, LibPaths, |
| 235 | gcc, envp); |
John Criswell | dabaf7d | 2003-09-16 21:27:35 +0000 | [diff] [blame] | 236 | |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 237 | // Remove the assembly language file. |
John Criswell | dc0de4f | 2003-09-18 16:22:26 +0000 | [diff] [blame] | 238 | removeFile (AssemblyFile); |
Chris Lattner | 69e8d28 | 2004-04-06 16:43:13 +0000 | [diff] [blame] | 239 | } else if (NativeCBE) { |
| 240 | std::string CFile = OutputFilename + ".cbe.c"; |
| 241 | |
| 242 | // Mark the output files for removal if we get an interrupt. |
| 243 | RemoveFileOnSignal(CFile); |
| 244 | RemoveFileOnSignal(OutputFilename); |
| 245 | |
| 246 | // Determine the locations of the llc and gcc programs. |
| 247 | std::string llc = FindExecutable("llc", argv[0]); |
| 248 | std::string gcc = FindExecutable("gcc", argv[0]); |
| 249 | if (llc.empty()) |
| 250 | return PrintAndReturn(argv[0], "Failed to find llc"); |
| 251 | if (gcc.empty()) |
| 252 | return PrintAndReturn(argv[0], "Failed to find gcc"); |
| 253 | |
| 254 | // Generate an assembly language file for the bytecode. |
| 255 | if (Verbose) std::cout << "Generating Assembly Code\n"; |
| 256 | GenerateCFile(CFile, RealBytecodeOutput, llc, envp); |
| 257 | if (Verbose) std::cout << "Generating Native Code\n"; |
| 258 | GenerateNative(OutputFilename, CFile, Libraries, LibPaths, gcc, envp); |
| 259 | |
| 260 | // Remove the assembly language file. |
| 261 | removeFile(CFile); |
| 262 | |
Chris Lattner | 6e27123 | 2003-09-22 20:21:34 +0000 | [diff] [blame] | 263 | } else { |
Chris Lattner | 7e88d41 | 2004-06-02 00:10:19 +0000 | [diff] [blame] | 264 | EmitShellScript(argv); |
John Criswell | dabaf7d | 2003-09-16 21:27:35 +0000 | [diff] [blame] | 265 | } |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 266 | |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 267 | // Make the script executable... |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 268 | MakeFileExecutable(OutputFilename); |
Misha Brukman | c1fdca8 | 2003-08-20 20:38:15 +0000 | [diff] [blame] | 269 | |
John Criswell | 22edc39 | 2003-09-02 21:11:22 +0000 | [diff] [blame] | 270 | // Make the bytecode file readable and directly executable in LLEE as well |
Misha Brukman | e97fbed | 2003-09-30 17:59:25 +0000 | [diff] [blame] | 271 | MakeFileExecutable(RealBytecodeOutput); |
| 272 | MakeFileReadable(RealBytecodeOutput); |
Chris Lattner | 10970eb | 2003-04-19 22:44:38 +0000 | [diff] [blame] | 273 | } |
Chris Lattner | e7fca51 | 2002-01-24 19:12:12 +0000 | [diff] [blame] | 274 | |
| 275 | return 0; |
| 276 | } |