- // TODO: Iterate over the -l list and link in any modules containing
- // global symbols that have not been resolved so far.
-
- if (DumpAsm) std::cerr << "Here's the assembly:\n" << Composite.get();
-
- std::ostream *Out = &std::cout; // Default to printing to stdout...
- if (OutputFilename != "-") {
- if (!Force && std::ifstream(OutputFilename.c_str())) {
- // If force is not specified, make sure not to overwrite a file!
- std::cerr << argv[0] << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
- return 1;
- }
- Out = new std::ofstream(OutputFilename.c_str());
- if (!Out->good()) {
- std::cerr << argv[0] << ": error opening '" << OutputFilename << "'!\n";
- return 1;
- }
-
- // Make sure that the Out file gets unlinked from the disk if we get a
- // SIGINT
- sys::RemoveFileOnSignal(sys::Path(OutputFilename));
- }
+ auto Composite = make_unique<Module>("llvm-link", Context);
+ Linker L(Composite.get(), diagnosticHandler);