+ cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+ if (!LinkAsLibrary) {
+ // Default to "a.exe" instead of "a.out".
+ if (OutputFilename.getNumOccurrences() == 0)
+ OutputFilename = "a.exe";
+
+ // If there is no suffix add an "exe" one.
+ sys::Path ExeFile( OutputFilename );
+ if (ExeFile.getSuffix() == "") {
+ ExeFile.appendSuffix("exe");
+ OutputFilename = ExeFile.str();
+ }
+ }
+#endif
+
+ // Generate the bitcode for the optimized module.
+ // If -b wasn't specified, use the name specified
+ // with -o to construct BitcodeOutputFilename.
+ if (BitcodeOutputFilename.empty()) {
+ BitcodeOutputFilename = OutputFilename;
+ if (!LinkAsLibrary) BitcodeOutputFilename += ".bc";
+ }
+
+ // Arrange for the bitcode output file to be deleted on any errors.
+ BitcodeOutputRemover.setFile(sys::Path(BitcodeOutputFilename));
+ sys::RemoveFileOnSignal(sys::Path(BitcodeOutputFilename));
+
+ // Arrange for the output file to be deleted on any errors.
+ if (!LinkAsLibrary) {
+ OutputRemover.setFile(sys::Path(OutputFilename));
+ sys::RemoveFileOnSignal(sys::Path(OutputFilename));
+ }
+
+ // Construct a Linker (now that Verbose is set)
+ Linker TheLinker(progname, OutputFilename, Context, Verbose);
+
+ // Keep track of the native link items (versus the bitcode items)
+ Linker::ItemList NativeLinkItems;
+
+ // Add library paths to the linker
+ TheLinker.addPaths(LibPaths);
+ TheLinker.addSystemPaths();