namespace options {
static bool generate_api_file = false;
+ static std::string bc_path;
static const char *as_path = NULL;
// Additional options to pass into the code generator.
// Note: This array will contain all plugin options which are not claimed
} else {
as_path = strdup(opt + 3);
}
+ } else if(llvm::StringRef(opt).startswith("also-emit-llvm=")) {
+ const char *path = opt + strlen("also-emit-llvm=");
+ if (bc_path != "") {
+ (*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(std::string(opt));
E = Modules.end(); I != E; ++I) {
(*get_symbols)(I->handle, I->syms.size(), &I->syms[0]);
for (unsigned i = 0, e = I->syms.size(); i != e; i++) {
- if (I->syms[i].resolution == LDPR_PREVAILING_DEF ||
- (I->syms[i].def == LDPK_COMMON &&
- I->syms[i].resolution == LDPR_RESOLVED_IR)) {
+ if (I->syms[i].resolution == LDPR_PREVAILING_DEF) {
lto_codegen_add_must_preserve_symbol(cg, I->syms[i].name);
anySymbolsPreserved = true;
}
}
+ if (options::bc_path != "") {
+ bool err = lto_codegen_write_merged_modules(cg, options::bc_path.c_str());
+ if (err)
+ (*message)(LDPL_FATAL, "Failed to write the output file.");
+ }
size_t bufsize = 0;
const char *buffer = static_cast<const char *>(lto_codegen_compile(cg,
&bufsize));
(*message)(LDPL_ERROR, "%s", ErrMsg.c_str());
return LDPS_ERR;
}
- raw_fd_ostream *objFile =
+ raw_fd_ostream *objFile =
new raw_fd_ostream(uniqueObjPath.c_str(), ErrMsg,
raw_fd_ostream::F_Binary);
if (!ErrMsg.empty()) {