//
// The LLVM Compiler Infrastructure
//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#include "llvm/System/Signals.h"
#include <fstream>
#include <memory>
+#include <cstring>
using namespace llvm;
// Input/Output Options
cl::desc("Specify a library search path"),
cl::value_desc("directory"));
+static cl::list<std::string> FrameworkPaths("F", cl::Prefix,
+ cl::desc("Specify a framework search path"),
+ cl::value_desc("directory"));
+
static cl::list<std::string> Libraries("l", cl::Prefix,
cl::desc("Specify libraries to link to"),
cl::value_desc("library prefix"));
+static cl::list<std::string> Frameworks("framework",
+ cl::desc("Specify frameworks to link to"),
+ cl::value_desc("framework"));
+
// Options to control the linking, optimization, and code gen processes
static cl::opt<bool> LinkAsLibrary("link-as-library",
cl::desc("Link the .bc files together as a library, not an executable"));
static cl::alias Relink("r", cl::aliasopt(LinkAsLibrary),
cl::desc("Alias for -link-as-library"));
-static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser>
- MachineArch("march", cl::desc("Architecture to generate assembly for:"));
-
static cl::opt<bool> Native("native",
cl::desc("Generate a native binary instead of a shell script"));
/// OutputFilename - The name of the file to generate.
/// NativeLinkItems - The native libraries, files, code with which to link
/// LibPaths - The list of directories in which to find libraries.
+/// FrameworksPaths - The list of directories in which to find frameworks.
+/// Frameworks - The list of frameworks (dynamic libraries)
/// gcc - The pathname to use for GGC.
/// envp - A copy of the process's current environment.
///
args.push_back(OutputFilename);
args.push_back(InputFilename);
- // Add in the library paths
+ // Add in the library and framework paths
for (unsigned index = 0; index < LibPaths.size(); index++) {
- args.push_back("-L");
- args.push_back(LibPaths[index]);
+ args.push_back("-L" + LibPaths[index]);
+ }
+ for (unsigned index = 0; index < FrameworkPaths.size(); index++) {
+ args.push_back("-F" + FrameworkPaths[index]);
}
// Add the requested options
- for (unsigned index = 0; index < XLinker.size(); index++) {
+ for (unsigned index = 0; index < XLinker.size(); index++)
args.push_back(XLinker[index]);
- args.push_back(Libraries[index]);
- }
// Add in the libraries to link.
for (unsigned index = 0; index < LinkItems.size(); index++)
args.push_back(LinkItems[index].first);
}
+ // Add in frameworks to link.
+ for (unsigned index = 0; index < Frameworks.size(); index++) {
+ args.push_back("-framework");
+ args.push_back(Frameworks[index]);
+ }
// Now that "args" owns all the std::strings for the arguments, call the c_str
// method to get the underlying string array. We do this game so that the
progname = sys::Path(argv[0]).getBasename();
// Parse the command line options
- cl::ParseCommandLineOptions(argc, argv, " llvm linker\n");
+ cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
sys::PrintStackTraceOnErrorSignal();
// Construct a Linker (now that Verbose is set)
// Optimize the module
Optimize(Composite.get());
+#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.toString();
+ }
+ }
+#endif
+
// Generate the bitcode for the optimized module.
std::string RealBitcodeOutput = OutputFilename;
+
if (!LinkAsLibrary) RealBitcodeOutput += ".bc";
GenerateBitcode(Composite.get(), RealBitcodeOutput);