} catch (error &e) {
if (e.get() == CL_INVALID_COMPILER_OPTIONS)
return CL_INVALID_BUILD_OPTIONS;
- if (e.get() == CL_COMPILE_PROGRAM_FAILURE)
- return CL_BUILD_PROGRAM_FAILURE;
return e.get();
}
prog.build(devs, opts, headers);
return CL_SUCCESS;
+} catch (build_error &e) {
+ return CL_COMPILE_PROGRAM_FAILURE;
+
} catch (error &e) {
return e.get();
}
cl_int code;
};
- class compile_error : public error {
+ class build_error : public error {
public:
- compile_error(const std::string &what = "") :
- error(CL_COMPILE_PROGRAM_FAILURE, what) {
- }
+ build_error(const std::string &what = "") :
+ error(CL_BUILD_PROGRAM_FAILURE, what) {}
};
template<typename O>
const auto elf = elf::get(code);
const auto symtab = elf::get_symbol_table(elf.get());
if (!symtab)
- fail(r_log, compile_error(), "Unable to find symbol table.");
+ fail(r_log, build_error(), "Unable to find symbol table.");
return elf::get_symbol_offsets(elf.get(), symtab);
}
std::string err;
auto t = ::llvm::TargetRegistry::lookupTarget(target.triple, err);
if (!t)
- fail(r_log, compile_error(), err);
+ fail(r_log, build_error(), err);
std::unique_ptr<TargetMachine> tm {
t->createTargetMachine(target.triple, target.cpu, "", {},
::llvm::CodeModel::Default,
::llvm::CodeGenOpt::Default) };
if (!tm)
- fail(r_log, compile_error(),
+ fail(r_log, build_error(),
"Could not create TargetMachine: " + target.triple);
::llvm::SmallVector<char, 1024> data;
(ft == TargetMachine::CGFT_AssemblyFile);
if (tm->addPassesToEmitFile(pm, fos, ft))
- fail(r_log, compile_error(), "TargetMachine can't emit this file");
+ fail(r_log, build_error(), "TargetMachine can't emit this file");
pm.run(mod);
}
raw_string_ostream os { *reinterpret_cast<std::string *>(data) };
::llvm::DiagnosticPrinterRawOStream printer { os };
di.print(printer);
- throw compile_error();
+ throw build_error();
}
}
// Compile the code
clang::EmitLLVMOnlyAction act(&ctx);
if (!c.ExecuteAction(act))
- throw compile_error();
+ throw build_error();
return act.takeModule();
}
for (auto &m : modules) {
if (compat::link_in_module(*linker,
parse_module_library(m, ctx, r_log)))
- throw compile_error();
+ throw build_error();
}
return std::move(mod);
if (!(ts >> offset)) {
r_log = "invalid kernel start address";
- throw compile_error();
+ throw build_error();
}
while (ts >> tok) {
args.push_back({ module::argument::sampler, 0 });
else {
r_log = "invalid kernel argument";
- throw compile_error();
+ throw build_error();
}
}
if (!tgsi_text_translate(source, prog, ARRAY_SIZE(prog))) {
r_log = "translate failed";
- throw compile_error();
+ throw build_error();
}
unsigned sz = tgsi_num_tokens(prog) * sizeof(tgsi_token);
const size_t body_pos = source.find("COMP\n");
if (body_pos == std::string::npos) {
r_log = "invalid source";
- throw compile_error();
+ throw build_error();
}
const char *body = &source[body_pos];