+namespace options {
+ enum generate_bc { BC_NO, BC_ALSO, BC_ONLY };
+ static bool generate_api_file = false;
+ static generate_bc generate_bc_file = BC_NO;
+ static std::string bc_path;
+ static std::string as_path;
+ static std::vector<std::string> pass_through;
+ static std::string extra_library_path;
+ static std::string triple;
+ // Additional options to pass into the code generator.
+ // Note: This array will contain all plugin options which are not claimed
+ // as plugin exclusive to pass to the code generator.
+ // For example, "generate-api-file" and "as"options are for the plugin
+ // use only and will not be passed.
+ static std::vector<std::string> extra;
+
+ static void process_plugin_option(const char* opt_)
+ {
+ if (opt_ == NULL)
+ return;
+ llvm::StringRef opt = opt_;
+
+ if (opt == "generate-api-file") {
+ generate_api_file = true;
+ } else if (opt.startswith("as=")) {
+ if (!as_path.empty()) {
+ (*message)(LDPL_WARNING, "Path to as specified twice. "
+ "Discarding %s", opt_);
+ } else {
+ as_path = opt.substr(strlen("as="));
+ }
+ } else if (opt.startswith("extra-library-path=")) {
+ extra_library_path = opt.substr(strlen("extra_library_path="));
+ } else if (opt.startswith("pass-through=")) {
+ llvm::StringRef item = opt.substr(strlen("pass-through="));
+ pass_through.push_back(item.str());
+ } else if (opt == "mtriple=") {
+ triple = opt.substr(strlen("mtriple="));
+ } else if (opt == "emit-llvm") {
+ generate_bc_file = BC_ONLY;
+ } else if (opt == "also-emit-llvm") {
+ generate_bc_file = BC_ALSO;
+ } else if (opt.startswith("also-emit-llvm=")) {
+ llvm::StringRef path = opt.substr(strlen("also-emit-llvm="));
+ generate_bc_file = BC_ALSO;
+ if (!bc_path.empty()) {
+ (*message)(LDPL_WARNING, "Path to the output IL file specified twice. "
+ "Discarding %s", opt_);
+ } else {
+ bc_path = path;
+ }
+ } else {
+ // Save this option to pass to the code generator.
+ extra.push_back(opt);
+ }
+ }
+}
+
+static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
+ int *claimed);
+static ld_plugin_status all_symbols_read_hook(void);
+static ld_plugin_status cleanup_hook(void);