Skip to content

Commit 01566b8

Browse files
Robadobptheywood
authored andcommitted
Strip out header finds from preprocessor errors.
1 parent 36d6e3c commit 01566b8

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/flamegpu/detail/JitifyCache.cu

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <string>
1212
#include <unordered_map>
1313
#include <cstdio>
14-
1514
#include "jitify/jitify2.hpp"
1615

1716
#include "flamegpu/version.h"
@@ -412,16 +411,31 @@ std::unique_ptr<jitify2::LinkedProgramData> JitifyCache::buildProgram(
412411

413412
// jitify to create program (with compilation settings)
414413
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);
416415
if (!program.ok()) {
417-
const jitify2::ErrorMsg& compile_error = program->compile_log();
416+
const jitify2::ErrorMsg& compile_error = program.error();
418417
fprintf(stderr, "Failed to load program for agent function (condition) '%s', log:\n%s",
419418
func_name.c_str(), compile_error.c_str());
420419
THROW exception::InvalidAgentFunc("Error loading agent function (or function condition) ('%s'): function had compilation errors:\n%s",
421420
func_name.c_str(), compile_error.c_str());
422421
}
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+
}
423437
// Compile
424-
jitify2::CompiledProgram compiled_program = program->compile({ name_expression });
438+
jitify2::CompiledProgram compiled_program = preprocessed_program->compile({ name_expression });
425439
if (!compiled_program.ok()) {
426440
const jitify2::ErrorMsg& compile_error = compiled_program.error();
427441
fprintf(stderr, "Failed to compile agent function (condition) '%s', log:\n%s",

0 commit comments

Comments
 (0)