1 //===- llvm-ld.cpp - LLVM 'ld' compatible linker --------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This utility is intended to be compatible with GCC, and follows standard
11 // system 'ld' conventions. As such, the default output file is ./a.out.
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 bitcode file actually lives in
15 // the a.out.bc file generated by this program.
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,
19 // I'm not too worried about this.
21 //===----------------------------------------------------------------------===//
23 #include "llvm/LinkAllVMCore.h"
24 #include "llvm/Linker.h"
25 #include "llvm/LLVMContext.h"
26 #include "llvm/System/Program.h"
27 #include "llvm/Module.h"
28 #include "llvm/PassManager.h"
29 #include "llvm/Bitcode/ReaderWriter.h"
30 #include "llvm/Target/TargetData.h"
31 #include "llvm/Target/TargetMachine.h"
32 #include "llvm/Support/CommandLine.h"
33 #include "llvm/Support/FileUtilities.h"
34 #include "llvm/Support/ManagedStatic.h"
35 #include "llvm/Support/MemoryBuffer.h"
36 #include "llvm/Support/PrettyStackTrace.h"
37 #include "llvm/Support/SystemUtils.h"
38 #include "llvm/Support/raw_ostream.h"
39 #include "llvm/System/Signals.h"
40 #include "llvm/Config/config.h"
45 // Rightly this should go in a header file but it just seems such a waste.
47 extern void Optimize(Module*);
50 // Input/Output Options
51 static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
52 cl::desc("<input bitcode files>"));
54 static cl::opt<std::string> OutputFilename("o", cl::init("a.out"),
55 cl::desc("Override output filename"),
56 cl::value_desc("filename"));
58 static cl::opt<std::string> BitcodeOutputFilename("b", cl::init(""),
59 cl::desc("Override bitcode output filename"),
60 cl::value_desc("filename"));
62 static cl::opt<bool> Verbose("v",
63 cl::desc("Print information about actions taken"));
65 static cl::list<std::string> LibPaths("L", cl::Prefix,
66 cl::desc("Specify a library search path"),
67 cl::value_desc("directory"));
69 static cl::list<std::string> FrameworkPaths("F", cl::Prefix,
70 cl::desc("Specify a framework search path"),
71 cl::value_desc("directory"));
73 static cl::list<std::string> Libraries("l", cl::Prefix,
74 cl::desc("Specify libraries to link to"),
75 cl::value_desc("library prefix"));
77 static cl::list<std::string> Frameworks("framework",
78 cl::desc("Specify frameworks to link to"),
79 cl::value_desc("framework"));
81 // Options to control the linking, optimization, and code gen processes
82 static cl::opt<bool> LinkAsLibrary("link-as-library",
83 cl::desc("Link the .bc files together as a library, not an executable"));
85 static cl::alias Relink("r", cl::aliasopt(LinkAsLibrary),
86 cl::desc("Alias for -link-as-library"));
88 static cl::opt<bool> Native("native",
89 cl::desc("Generate a native binary instead of a shell script"));
91 static cl::opt<bool>NativeCBE("native-cbe",
92 cl::desc("Generate a native binary with the C backend and GCC"));
94 static cl::list<std::string> PostLinkOpts("post-link-opts",
95 cl::value_desc("path"),
96 cl::desc("Run one or more optimization programs after linking"));
98 static cl::list<std::string> XLinker("Xlinker", cl::value_desc("option"),
99 cl::desc("Pass options to the system linker"));
101 // Compatibility options that llvm-ld ignores but are supported for
102 // compatibility with LD
103 static cl::opt<std::string> CO3("soname", cl::Hidden,
104 cl::desc("Compatibility option: ignored"));
106 static cl::opt<std::string> CO4("version-script", cl::Hidden,
107 cl::desc("Compatibility option: ignored"));
109 static cl::opt<bool> CO5("eh-frame-hdr", cl::Hidden,
110 cl::desc("Compatibility option: ignored"));
112 static cl::opt<std::string> CO6("h", cl::Hidden,
113 cl::desc("Compatibility option: ignored"));
115 static cl::opt<bool> CO7("start-group", cl::Hidden,
116 cl::desc("Compatibility option: ignored"));
118 static cl::opt<bool> CO8("end-group", cl::Hidden,
119 cl::desc("Compatibility option: ignored"));
121 static cl::opt<std::string> CO9("m", cl::Hidden,
122 cl::desc("Compatibility option: ignored"));
124 /// This is just for convenience so it doesn't have to be passed around
126 static std::string progname;
128 /// FileRemover objects to clean up output files in the event of an error.
129 static FileRemover OutputRemover;
130 static FileRemover BitcodeOutputRemover;
132 /// PrintAndExit - Prints a message to standard error and exits with error code
135 /// Message - The message to print to standard error.
137 static void PrintAndExit(const std::string &Message, Module *M, int errcode = 1) {
138 errs() << progname << ": " << Message << "\n";
144 static void PrintCommand(const std::vector<const char*> &args) {
145 std::vector<const char*>::const_iterator I = args.begin(), E = args.end();
148 outs() << "'" << *I << "'" << " ";
149 outs() << "\n"; outs().flush();
152 /// CopyEnv - This function takes an array of environment variables and makes a
153 /// copy of it. This copy can then be manipulated any way the caller likes
154 /// without affecting the process's real environment.
157 /// envp - An array of C strings containing an environment.
160 /// NULL - An error occurred.
162 /// Otherwise, a pointer to a new array of C strings is returned. Every string
163 /// in the array is a duplicate of the one in the original array (i.e. we do
164 /// not copy the char *'s from one array to another).
166 static char ** CopyEnv(char ** const envp) {
167 // Count the number of entries in the old list;
168 unsigned entries; // The number of entries in the old environment list
169 for (entries = 0; envp[entries] != NULL; entries++)
172 // Add one more entry for the NULL pointer that ends the list.
175 // If there are no entries at all, just return NULL.
179 // Allocate a new environment list.
180 char **newenv = new char* [entries];
181 if ((newenv = new char* [entries]) == NULL)
184 // Make a copy of the list. Don't forget the NULL that ends the list.
186 while (envp[entries] != NULL) {
187 size_t len = strlen(envp[entries]) + 1;
188 newenv[entries] = new char[len];
189 memcpy(newenv[entries], envp[entries], len);
192 newenv[entries] = NULL;
198 /// RemoveEnv - Remove the specified environment variable from the environment
202 /// name - The name of the variable to remove. It cannot be NULL.
203 /// envp - The array of environment variables. It cannot be NULL.
206 /// This is mainly done because functions to remove items from the environment
207 /// are not available across all platforms. In particular, Solaris does not
208 /// seem to have an unsetenv() function or a setenv() function (or they are
209 /// undocumented if they do exist).
211 static void RemoveEnv(const char * name, char ** const envp) {
212 for (unsigned index=0; envp[index] != NULL; index++) {
213 // Find the first equals sign in the array and make it an EOS character.
214 char *p = strchr (envp[index], '=');
220 // Compare the two strings. If they are equal, zap this string.
221 // Otherwise, restore it.
222 if (!strcmp(name, envp[index]))
231 /// GenerateBitcode - generates a bitcode file from the module provided
232 void GenerateBitcode(Module* M, const std::string& FileName) {
235 outs() << "Generating Bitcode To " << FileName << '\n';
237 // Create the output file.
238 std::string ErrorInfo;
239 raw_fd_ostream Out(FileName.c_str(), ErrorInfo,
240 raw_fd_ostream::F_Binary);
241 if (!ErrorInfo.empty())
242 PrintAndExit(ErrorInfo, M);
245 WriteBitcodeToFile(M, Out);
248 /// GenerateAssembly - generates a native assembly language source file from the
249 /// specified bitcode file.
252 /// InputFilename - The name of the input bitcode file.
253 /// OutputFilename - The name of the file to generate.
254 /// llc - The pathname to use for LLC.
255 /// envp - The environment to use when running LLC.
257 /// Return non-zero value on error.
259 static int GenerateAssembly(const std::string &OutputFilename,
260 const std::string &InputFilename,
261 const sys::Path &llc,
262 std::string &ErrMsg ) {
263 // Run LLC to convert the bitcode file into assembly code.
264 std::vector<const char*> args;
265 args.push_back(llc.c_str());
266 // We will use GCC to assemble the program so set the assembly syntax to AT&T,
267 // regardless of what the target in the bitcode file is.
268 args.push_back("-x86-asm-syntax=att");
269 args.push_back("-o");
270 args.push_back(OutputFilename.c_str());
271 args.push_back(InputFilename.c_str());
275 outs() << "Generating Assembly With: \n";
279 return sys::Program::ExecuteAndWait(llc, &args[0], 0, 0, 0, 0, &ErrMsg);
282 /// GenerateCFile - generates a C source file from the specified bitcode file.
283 static int GenerateCFile(const std::string &OutputFile,
284 const std::string &InputFile,
285 const sys::Path &llc,
286 std::string& ErrMsg) {
287 // Run LLC to convert the bitcode file into C.
288 std::vector<const char*> args;
289 args.push_back(llc.c_str());
290 args.push_back("-march=c");
291 args.push_back("-o");
292 args.push_back(OutputFile.c_str());
293 args.push_back(InputFile.c_str());
297 outs() << "Generating C Source With: \n";
301 return sys::Program::ExecuteAndWait(llc, &args[0], 0, 0, 0, 0, &ErrMsg);
304 /// GenerateNative - generates a native object file from the
305 /// specified bitcode file.
308 /// InputFilename - The name of the input bitcode file.
309 /// OutputFilename - The name of the file to generate.
310 /// NativeLinkItems - The native libraries, files, code with which to link
311 /// LibPaths - The list of directories in which to find libraries.
312 /// FrameworksPaths - The list of directories in which to find frameworks.
313 /// Frameworks - The list of frameworks (dynamic libraries)
314 /// gcc - The pathname to use for GGC.
315 /// envp - A copy of the process's current environment.
320 /// Returns non-zero value on error.
322 static int GenerateNative(const std::string &OutputFilename,
323 const std::string &InputFilename,
324 const Linker::ItemList &LinkItems,
325 const sys::Path &gcc, char ** const envp,
326 std::string& ErrMsg) {
327 // Remove these environment variables from the environment of the
328 // programs that we will execute. It appears that GCC sets these
329 // environment variables so that the programs it uses can configure
330 // themselves identically.
332 // However, when we invoke GCC below, we want it to use its normal
333 // configuration. Hence, we must sanitize its environment.
334 char ** clean_env = CopyEnv(envp);
335 if (clean_env == NULL)
337 RemoveEnv("LIBRARY_PATH", clean_env);
338 RemoveEnv("COLLECT_GCC_OPTIONS", clean_env);
339 RemoveEnv("GCC_EXEC_PREFIX", clean_env);
340 RemoveEnv("COMPILER_PATH", clean_env);
341 RemoveEnv("COLLECT_GCC", clean_env);
344 // Run GCC to assemble and link the program into native code.
347 // We can't just assemble and link the file with the system assembler
348 // and linker because we don't know where to put the _start symbol.
349 // GCC mysteriously knows how to do it.
350 std::vector<std::string> args;
351 args.push_back(gcc.c_str());
352 args.push_back("-fno-strict-aliasing");
353 args.push_back("-O3");
354 args.push_back("-o");
355 args.push_back(OutputFilename);
356 args.push_back(InputFilename);
358 // Add in the library and framework paths
359 for (unsigned index = 0; index < LibPaths.size(); index++) {
360 args.push_back("-L" + LibPaths[index]);
362 for (unsigned index = 0; index < FrameworkPaths.size(); index++) {
363 args.push_back("-F" + FrameworkPaths[index]);
366 // Add the requested options
367 for (unsigned index = 0; index < XLinker.size(); index++)
368 args.push_back(XLinker[index]);
370 // Add in the libraries to link.
371 for (unsigned index = 0; index < LinkItems.size(); index++)
372 if (LinkItems[index].first != "crtend") {
373 if (LinkItems[index].second)
374 args.push_back("-l" + LinkItems[index].first);
376 args.push_back(LinkItems[index].first);
379 // Add in frameworks to link.
380 for (unsigned index = 0; index < Frameworks.size(); index++) {
381 args.push_back("-framework");
382 args.push_back(Frameworks[index]);
385 // Now that "args" owns all the std::strings for the arguments, call the c_str
386 // method to get the underlying string array. We do this game so that the
387 // std::string array is guaranteed to outlive the const char* array.
388 std::vector<const char *> Args;
389 for (unsigned i = 0, e = args.size(); i != e; ++i)
390 Args.push_back(args[i].c_str());
394 outs() << "Generating Native Executable With:\n";
398 // Run the compiler to assembly and link together the program.
399 int R = sys::Program::ExecuteAndWait(
400 gcc, &Args[0], const_cast<const char **>(clean_env), 0, 0, 0, &ErrMsg);
405 /// EmitShellScript - Output the wrapper file that invokes the JIT on the LLVM
406 /// bitcode file for the program.
407 static void EmitShellScript(char **argv, Module *M) {
409 outs() << "Emitting Shell Script\n";
410 #if defined(_WIN32) || defined(__CYGWIN__)
411 // Windows doesn't support #!/bin/sh style shell scripts in .exe files. To
412 // support windows systems, we copy the llvm-stub.exe executable from the
413 // build tree to the destination file.
415 sys::Path llvmstub = FindExecutable("llvm-stub.exe", argv[0],
416 (void *)(intptr_t)&Optimize);
417 if (llvmstub.isEmpty())
418 PrintAndExit("Could not find llvm-stub.exe executable!", M);
420 if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg))
421 PrintAndExit(ErrMsg, M);
426 // Output the script to start the program...
427 std::string ErrorInfo;
428 raw_fd_ostream Out2(OutputFilename.c_str(), ErrorInfo);
429 if (!ErrorInfo.empty())
430 PrintAndExit(ErrorInfo, M);
432 Out2 << "#!/bin/sh\n";
433 // Allow user to setenv LLVMINTERP if lli is not in their PATH.
434 Out2 << "lli=${LLVMINTERP-lli}\n";
435 Out2 << "exec $lli \\\n";
436 // gcc accepts -l<lib> and implicitly searches /lib and /usr/lib.
437 LibPaths.push_back("/lib");
438 LibPaths.push_back("/usr/lib");
439 LibPaths.push_back("/usr/X11R6/lib");
440 // We don't need to link in libc! In fact, /usr/lib/libc.so may not be a
441 // shared object at all! See RH 8: plain text.
442 std::vector<std::string>::iterator libc =
443 std::find(Libraries.begin(), Libraries.end(), "c");
444 if (libc != Libraries.end()) Libraries.erase(libc);
445 // List all the shared object (native) libraries this executable will need
446 // on the command line, so that we don't have to do this manually!
447 for (std::vector<std::string>::iterator i = Libraries.begin(),
448 e = Libraries.end(); i != e; ++i) {
449 // try explicit -L arguments first:
450 sys::Path FullLibraryPath;
451 for (cl::list<std::string>::const_iterator P = LibPaths.begin(),
452 E = LibPaths.end(); P != E; ++P) {
453 FullLibraryPath = *P;
454 FullLibraryPath.appendComponent("lib" + *i);
455 FullLibraryPath.appendSuffix(&(LTDL_SHLIB_EXT[1]));
456 if (!FullLibraryPath.isEmpty()) {
457 if (!FullLibraryPath.isDynamicLibrary()) {
458 // Not a native shared library; mark as invalid
459 FullLibraryPath = sys::Path();
463 if (FullLibraryPath.isEmpty())
464 FullLibraryPath = sys::Path::FindLibrary(*i);
465 if (!FullLibraryPath.isEmpty())
466 Out2 << " -load=" << FullLibraryPath.str() << " \\\n";
468 Out2 << " " << BitcodeOutputFilename << " ${1+\"$@\"}\n";
471 // BuildLinkItems -- This function generates a LinkItemList for the LinkItems
472 // linker function by combining the Files and Libraries in the order they were
473 // declared on the command line.
474 static void BuildLinkItems(
475 Linker::ItemList& Items,
476 const cl::list<std::string>& Files,
477 const cl::list<std::string>& Libraries) {
479 // Build the list of linkage items for LinkItems.
481 cl::list<std::string>::const_iterator fileIt = Files.begin();
482 cl::list<std::string>::const_iterator libIt = Libraries.begin();
484 int libPos = -1, filePos = -1;
485 while ( libIt != Libraries.end() || fileIt != Files.end() ) {
486 if (libIt != Libraries.end())
487 libPos = Libraries.getPosition(libIt - Libraries.begin());
490 if (fileIt != Files.end())
491 filePos = Files.getPosition(fileIt - Files.begin());
495 if (filePos != -1 && (libPos == -1 || filePos < libPos)) {
497 Items.push_back(std::make_pair(*fileIt++, false));
498 } else if (libPos != -1 && (filePos == -1 || libPos < filePos)) {
500 Items.push_back(std::make_pair(*libIt++, true));
505 int main(int argc, char **argv, char **envp) {
506 // Print a stack trace if we signal out.
507 sys::PrintStackTraceOnErrorSignal();
508 PrettyStackTraceProgram X(argc, argv);
510 LLVMContext &Context = getGlobalContext();
511 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
513 // Initial global variable above for convenience printing of program name.
514 progname = sys::Path(argv[0]).getBasename();
516 // Parse the command line options
517 cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
519 #if defined(_WIN32) || defined(__CYGWIN__)
520 if (!LinkAsLibrary) {
521 // Default to "a.exe" instead of "a.out".
522 if (OutputFilename.getNumOccurrences() == 0)
523 OutputFilename = "a.exe";
525 // If there is no suffix add an "exe" one.
526 sys::Path ExeFile( OutputFilename );
527 if (ExeFile.getSuffix() == "") {
528 ExeFile.appendSuffix("exe");
529 OutputFilename = ExeFile.str();
534 // Generate the bitcode for the optimized module.
535 // If -b wasn't specified, use the name specified
536 // with -o to construct BitcodeOutputFilename.
537 if (BitcodeOutputFilename.empty()) {
538 BitcodeOutputFilename = OutputFilename;
539 if (!LinkAsLibrary) BitcodeOutputFilename += ".bc";
542 // Arrange for the bitcode output file to be deleted on any errors.
543 BitcodeOutputRemover.setFile(sys::Path(BitcodeOutputFilename));
544 sys::RemoveFileOnSignal(sys::Path(BitcodeOutputFilename));
546 // Arrange for the output file to be deleted on any errors.
547 if (!LinkAsLibrary) {
548 OutputRemover.setFile(sys::Path(OutputFilename));
549 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
552 // Construct a Linker (now that Verbose is set)
553 Linker TheLinker(progname, OutputFilename, Context, Verbose);
555 // Keep track of the native link items (versus the bitcode items)
556 Linker::ItemList NativeLinkItems;
558 // Add library paths to the linker
559 TheLinker.addPaths(LibPaths);
560 TheLinker.addSystemPaths();
562 // Remove any consecutive duplicates of the same library...
563 Libraries.erase(std::unique(Libraries.begin(), Libraries.end()),
567 std::vector<sys::Path> Files;
568 for (unsigned i = 0; i < InputFilenames.size(); ++i )
569 Files.push_back(sys::Path(InputFilenames[i]));
570 if (TheLinker.LinkInFiles(Files))
571 return 1; // Error already printed
573 // The libraries aren't linked in but are noted as "dependent" in the
575 for (cl::list<std::string>::const_iterator I = Libraries.begin(),
576 E = Libraries.end(); I != E ; ++I) {
577 TheLinker.getModule()->addLibrary(*I);
580 // Build a list of the items from our command line
581 Linker::ItemList Items;
582 BuildLinkItems(Items, InputFilenames, Libraries);
584 // Link all the items together
585 if (TheLinker.LinkInItems(Items, NativeLinkItems) )
586 return 1; // Error already printed
589 std::auto_ptr<Module> Composite(TheLinker.releaseModule());
591 // Optimize the module
592 Optimize(Composite.get());
594 // Generate the bitcode output.
595 GenerateBitcode(Composite.get(), BitcodeOutputFilename);
597 // If we are not linking a library, generate either a native executable
598 // or a JIT shell script, depending upon what the user wants.
599 if (!LinkAsLibrary) {
600 // If the user wants to run a post-link optimization, run it now.
601 if (!PostLinkOpts.empty()) {
602 std::vector<std::string> opts = PostLinkOpts;
603 for (std::vector<std::string>::iterator I = opts.begin(),
604 E = opts.end(); I != E; ++I) {
606 if (!prog.canExecute()) {
607 prog = sys::Program::FindProgramByName(*I);
609 PrintAndExit(std::string("Optimization program '") + *I +
610 "' is not found or not executable.", Composite.get());
612 // Get the program arguments
613 sys::Path tmp_output("opt_result");
615 if (tmp_output.createTemporaryFileOnDisk(true, &ErrMsg))
616 PrintAndExit(ErrMsg, Composite.get());
619 args[0] = I->c_str();
620 args[1] = BitcodeOutputFilename.c_str();
621 args[2] = tmp_output.c_str();
623 if (0 == sys::Program::ExecuteAndWait(prog, args, 0,0,0,0, &ErrMsg)) {
624 if (tmp_output.isBitcodeFile()) {
625 sys::Path target(BitcodeOutputFilename);
626 target.eraseFromDisk();
627 if (tmp_output.renamePathOnDisk(target, &ErrMsg))
628 PrintAndExit(ErrMsg, Composite.get(), 2);
630 PrintAndExit("Post-link optimization output is not bitcode",
633 PrintAndExit(ErrMsg, Composite.get());
638 // If the user wants to generate a native executable, compile it from the
641 // Otherwise, create a script that will run the bitcode through the JIT.
643 // Name of the Assembly Language output file
644 sys::Path AssemblyFile ( OutputFilename);
645 AssemblyFile.appendSuffix("s");
647 // Mark the output files for removal.
648 FileRemover AssemblyFileRemover(AssemblyFile);
649 sys::RemoveFileOnSignal(AssemblyFile);
651 // Determine the locations of the llc and gcc programs.
652 sys::Path llc = FindExecutable("llc", argv[0],
653 (void *)(intptr_t)&Optimize);
655 PrintAndExit("Failed to find llc", Composite.get());
657 sys::Path gcc = sys::Program::FindProgramByName("gcc");
659 PrintAndExit("Failed to find gcc", Composite.get());
661 // Generate an assembly language file for the bitcode.
663 if (0 != GenerateAssembly(AssemblyFile.str(), BitcodeOutputFilename,
665 PrintAndExit(ErrMsg, Composite.get());
667 if (0 != GenerateNative(OutputFilename, AssemblyFile.str(),
668 NativeLinkItems, gcc, envp, ErrMsg))
669 PrintAndExit(ErrMsg, Composite.get());
670 } else if (NativeCBE) {
671 sys::Path CFile (OutputFilename);
672 CFile.appendSuffix("cbe.c");
674 // Mark the output files for removal.
675 FileRemover CFileRemover(CFile);
676 sys::RemoveFileOnSignal(CFile);
678 // Determine the locations of the llc and gcc programs.
679 sys::Path llc = FindExecutable("llc", argv[0],
680 (void *)(intptr_t)&Optimize);
682 PrintAndExit("Failed to find llc", Composite.get());
684 sys::Path gcc = sys::Program::FindProgramByName("gcc");
686 PrintAndExit("Failed to find gcc", Composite.get());
688 // Generate an assembly language file for the bitcode.
690 if (GenerateCFile(CFile.str(), BitcodeOutputFilename, llc, ErrMsg))
691 PrintAndExit(ErrMsg, Composite.get());
693 if (GenerateNative(OutputFilename, CFile.str(),
694 NativeLinkItems, gcc, envp, ErrMsg))
695 PrintAndExit(ErrMsg, Composite.get());
697 EmitShellScript(argv, Composite.get());
700 // Make the script executable...
702 if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg))
703 PrintAndExit(ErrMsg, Composite.get());
705 // Make the bitcode file readable and directly executable in LLEE as well
706 if (sys::Path(BitcodeOutputFilename).makeExecutableOnDisk(&ErrMsg))
707 PrintAndExit(ErrMsg, Composite.get());
709 if (sys::Path(BitcodeOutputFilename).makeReadableOnDisk(&ErrMsg))
710 PrintAndExit(ErrMsg, Composite.get());
713 // Operations which may fail are now complete.
714 BitcodeOutputRemover.releaseFile();
716 OutputRemover.releaseFile();