_opts.insert({ &dev, opts });
+ compat::string log;
+
try {
auto module = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
compile_program_tgsi(_source) :
compile_program_llvm(_source, dev.ir_format(),
- dev.ir_target(), build_opts(dev)));
+ dev.ir_target(), build_opts(dev),
+ log));
_binaries.insert({ &dev, module });
-
- } catch (build_error &e) {
- _logs.insert({ &dev, e.what() });
+ _logs.insert({ &dev, std::string(log.c_str()) });
+ } catch (const build_error &) {
+ _logs.insert({ &dev, std::string(log.c_str()) });
throw;
}
}
compile(llvm::LLVMContext &llvm_ctx, const std::string &source,
const std::string &name, const std::string &triple,
const std::string &processor, const std::string &opts,
- clang::LangAS::Map& address_spaces) {
+ clang::LangAS::Map& address_spaces, compat::string &r_log) {
clang::CompilerInstance c;
clang::EmitLLVMOnlyAction act(&llvm_ctx);
c.getCodeGenOpts().LinkBitcodeFile = libclc_path;
// Compile the code
- if (!c.ExecuteAction(act))
- throw build_error(log);
+ bool ExecSuccess = c.ExecuteAction(act);
+ r_log = log;
+
+ if (!ExecSuccess)
+ throw build_error();
// Get address spaces map to be able to find kernel argument address space
- memcpy(address_spaces, c.getTarget().getAddressSpaceMap(),
+ memcpy(address_spaces, c.getTarget().getAddressSpaceMap(),
sizeof(address_spaces));
return act.takeModule();
clover::compile_program_llvm(const compat::string &source,
enum pipe_shader_ir ir,
const compat::string &target,
- const compat::string &opts) {
+ const compat::string &opts,
+ compat::string &r_log) {
std::vector<llvm::Function *> kernels;
size_t processor_str_len = std::string(target.begin()).find_first_of("-");
// The input file name must have the .cl extension in order for the
// CompilerInvocation class to recognize it as an OpenCL source file.
llvm::Module *mod = compile(llvm_ctx, source, "input.cl", triple, processor,
- opts, address_spaces);
+ opts, address_spaces, r_log);
find_kernels(mod, kernels);