- // If the user wants to generate a native executable, compile it from the
- // bitcode file.
- //
- // Otherwise, create a script that will run the bitcode through the JIT.
- if (Native) {
- // Name of the Assembly Language output file
- sys::Path AssemblyFile ( OutputFilename);
- AssemblyFile.appendSuffix("s");
-
- // Mark the output files for removal if we get an interrupt.
- sys::RemoveFileOnSignal(AssemblyFile);
- sys::RemoveFileOnSignal(sys::Path(OutputFilename));
-
- // Determine the locations of the llc and gcc programs.
- sys::Path llc = FindExecutable("llc", argv[0]);
- if (llc.isEmpty())
- PrintAndExit("Failed to find llc");
-
- sys::Path gcc = FindExecutable("gcc", argv[0]);
- if (gcc.isEmpty())
- PrintAndExit("Failed to find gcc");
-
- // Generate an assembly language file for the bitcode.
- std::string ErrMsg;
- if (0 != GenerateAssembly(AssemblyFile.toString(), RealBitcodeOutput,
- llc, ErrMsg))
- PrintAndExit(ErrMsg);
-
- if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(),
- NativeLinkItems, gcc, envp, ErrMsg))
- PrintAndExit(ErrMsg);
-
- // Remove the assembly language file.
- AssemblyFile.eraseFromDisk();
- } else if (NativeCBE) {
- sys::Path CFile (OutputFilename);
- CFile.appendSuffix("cbe.c");
-
- // Mark the output files for removal if we get an interrupt.
- sys::RemoveFileOnSignal(CFile);
- sys::RemoveFileOnSignal(sys::Path(OutputFilename));
-
- // Determine the locations of the llc and gcc programs.
- sys::Path llc = FindExecutable("llc", argv[0]);
- if (llc.isEmpty())
- PrintAndExit("Failed to find llc");
-
- sys::Path gcc = FindExecutable("gcc", argv[0]);
- if (gcc.isEmpty())
- PrintAndExit("Failed to find gcc");
-
- // Generate an assembly language file for the bitcode.
- std::string ErrMsg;
- if (0 != GenerateCFile(
- CFile.toString(), RealBitcodeOutput, llc, ErrMsg))
- PrintAndExit(ErrMsg);
+ // 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();
+
+ // Remove any consecutive duplicates of the same library...
+ Libraries.erase(std::unique(Libraries.begin(), Libraries.end()),
+ Libraries.end());