-#include <algorithm>
-#include <sys/types.h> // For FileExists
-#include <sys/stat.h>
-
-
-cl::StringList InputFilenames("", "Load <arg> files, linking them together",
- cl::OneOrMore);
-cl::String OutputFilename("o", "Override output filename", cl::NoFlags,"a.out");
-cl::Flag Verbose ("v", "Print information about actions taken");
-cl::StringList LibPaths ("L", "Specify a library search path", cl::ZeroOrMore);
-cl::StringList Libraries ("l", "Specify libraries to link to", cl::ZeroOrMore);
-cl::Flag Strip ("s", "Strip symbol info from executable");
-
-// FileExists - Return true if the specified string is an openable file...
-static inline bool FileExists(const std::string &FN) {
- struct stat StatBuf;
- return stat(FN.c_str(), &StatBuf) != -1;
+
+namespace {
+ cl::list<std::string>
+ InputFilenames(cl::Positional, cl::desc("<input bytecode files>"),
+ cl::OneOrMore);
+
+ cl::opt<std::string>
+ OutputFilename("o", cl::desc("Override output filename"), cl::init("a.out"),
+ cl::value_desc("filename"));
+
+ cl::opt<bool>
+ Verbose("v", cl::desc("Print information about actions taken"));
+
+ cl::list<std::string>
+ LibPaths("L", cl::desc("Specify a library search path"), cl::Prefix,
+ cl::value_desc("directory"));
+
+ cl::list<std::string>
+ Libraries("l", cl::desc("Specify libraries to link to"), cl::Prefix,
+ cl::value_desc("library prefix"));
+
+ cl::opt<bool>
+ Strip("s", cl::desc("Strip symbol info from executable"));
+
+ cl::opt<bool>
+ NoInternalize("disable-internalize",
+ cl::desc("Do not mark all symbols as internal"));
+ static cl::alias
+ ExportDynamic("export-dynamic", cl::desc("Alias for -disable-internalize"),
+ cl::aliasopt(NoInternalize));
+
+ cl::opt<bool>
+ LinkAsLibrary("link-as-library", cl::desc("Link the .bc files together as a"
+ " library, not an executable"));
+
+ cl::opt<bool>
+ Native("native",
+ cl::desc("Generate a native binary instead of a shell script"));
+
+ // Compatibility options that are ignored but supported by LD
+ cl::opt<std::string>
+ CO3("soname", cl::Hidden, cl::desc("Compatibility option: ignored"));
+ cl::opt<std::string>
+ CO4("version-script", cl::Hidden, cl::desc("Compatibility option: ignored"));
+ cl::opt<bool>
+ CO5("eh-frame-hdr", cl::Hidden, cl::desc("Compatibility option: ignored"));
+ cl::opt<bool>
+ CO6("r", cl::Hidden, cl::desc("Compatibility option: ignored"));