|
11 | 11 | #include <string>
|
12 | 12 | #include <unordered_map>
|
13 | 13 | #include <cstdio>
|
14 |
| - |
15 | 14 | #include "jitify/jitify2.hpp"
|
16 | 15 |
|
17 | 16 | #include "flamegpu/version.h"
|
@@ -412,16 +411,31 @@ std::unique_ptr<jitify2::LinkedProgramData> JitifyCache::buildProgram(
|
412 | 411 |
|
413 | 412 | // jitify to create program (with compilation settings)
|
414 | 413 | const std::string program_name = func_name + "_program"; // Does this name actually matter?
|
415 |
| - jitify2::PreprocessedProgram program = jitify2::Program(program_name, kernel_src, headers)->preprocess(options); |
| 414 | + jitify2::Program program = jitify2::Program(program_name, kernel_src, headers); |
416 | 415 | if (!program.ok()) {
|
417 |
| - const jitify2::ErrorMsg& compile_error = program->compile_log(); |
| 416 | + const jitify2::ErrorMsg& compile_error = program.error(); |
418 | 417 | fprintf(stderr, "Failed to load program for agent function (condition) '%s', log:\n%s",
|
419 | 418 | func_name.c_str(), compile_error.c_str());
|
420 | 419 | THROW exception::InvalidAgentFunc("Error loading agent function (or function condition) ('%s'): function had compilation errors:\n%s",
|
421 | 420 | func_name.c_str(), compile_error.c_str());
|
422 | 421 | }
|
| 422 | + jitify2::PreprocessedProgram preprocessed_program = program->preprocess(options); |
| 423 | + if (!preprocessed_program.ok()) { |
| 424 | + const jitify2::ErrorMsg& compile_error = preprocessed_program.error(); |
| 425 | + const char* currentPos = compile_error.c_str(); |
| 426 | + const char* lastPos = currentPos; |
| 427 | + while ((currentPos = strstr(currentPos, "Found #include"))) { |
| 428 | + lastPos = currentPos++; |
| 429 | + } |
| 430 | + currentPos = strstr(lastPos, "\n"); |
| 431 | + currentPos++; |
| 432 | + fprintf(stderr, "Failed to load program for agent function (condition) '%s', log:\n%s", |
| 433 | + func_name.c_str(), currentPos); |
| 434 | + THROW exception::InvalidAgentFunc("Error loading agent function (or function condition) ('%s'): function had compilation errors:\n%s", |
| 435 | + func_name.c_str(), currentPos); |
| 436 | + } |
423 | 437 | // Compile
|
424 |
| - jitify2::CompiledProgram compiled_program = program->compile({ name_expression }); |
| 438 | + jitify2::CompiledProgram compiled_program = preprocessed_program->compile({ name_expression }); |
425 | 439 | if (!compiled_program.ok()) {
|
426 | 440 | const jitify2::ErrorMsg& compile_error = compiled_program.error();
|
427 | 441 | fprintf(stderr, "Failed to compile agent function (condition) '%s', log:\n%s",
|
|
0 commit comments