diff --git a/opencl/opencl-aot/source/main.cpp b/opencl/opencl-aot/source/main.cpp index 9f4b1240c14ed..536ad7905f945 100644 --- a/opencl/opencl-aot/source/main.cpp +++ b/opencl/opencl-aot/source/main.cpp @@ -604,9 +604,13 @@ int main(int Argc, char *Argv[]) { } if (!CompilerBuildLog.empty()) { - logs() << "\n" - << CmdToCmdInfoMap[OptCommand].first << " log:\n" - << CompilerBuildLog << '\n'; + std::string CompilerBuildLogMessage = "\n" + + CmdToCmdInfoMap[OptCommand].first + + " log:\n" + CompilerBuildLog + '\n'; + if (!ErrorMessage.empty()) + std::cerr << CompilerBuildLogMessage; + else + logs() << CompilerBuildLogMessage; } if (clFailed(CLErr)) {