Skip to content

Commit 72bb235

Browse files
committed
errc and cleanup.
1 parent 95982af commit 72bb235

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

sycl/source/detail/jit_compiler.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,58 +1210,42 @@ std::vector<uint8_t> jit_compiler::compileSYCL(
12101210
std::back_inserter(UserArgsView),
12111211
[](const auto &Arg) { return Arg.c_str(); });
12121212

1213-
// CP --
1214-
// Redirect stderr to a string stream
1215-
// std::stringstream error_stream;
1216-
// the commented code below doesn't work, because ClangTool uses llvm::outs()
1217-
// and llvm::errs().
1218-
// std::streambuf *old_stderr = std::cerr.rdbuf();
1219-
// std::streambuf *old_stdout = std::cout.rdbuf();
1220-
// std::cerr.rdbuf(error_stream.rdbuf());
1221-
// std::cout.rdbuf(error_stream.rdbuf());
1222-
1223-
// freopen("error_log.txt", "w", stderr); // <-- this works, but doesn't
1224-
// capture in a std::string.
1225-
12261213
// Redirect stderr to a string stream.
12271214
#ifdef _WIN32
12281215
HANDLE read_pipe, write_pipe;
12291216
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
12301217
if (!CreatePipe(&read_pipe, &write_pipe, &sa, 0)) {
1231-
throw sycl::exception(sycl::errc::runtime, "Failed to create pipe");
1218+
throw sycl::exception(sycl::errc::build, "Failed to create pipe");
12321219
}
12331220

12341221
HANDLE saved_stderr = GetStdHandle(STD_ERROR_HANDLE);
12351222
HANDLE saved_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
12361223
if (!SetStdHandle(STD_ERROR_HANDLE, write_pipe) ||
12371224
!SetStdHandle(STD_OUTPUT_HANDLE, write_pipe)) {
1238-
throw sycl::exception(sycl::errc::runtime,
1225+
throw sycl::exception(sycl::errc::build,
12391226
"Failed to redirect stderr/stdout");
12401227
}
12411228
#else
12421229
int pipefd[2];
12431230
if (pipe(pipefd) == -1) {
1244-
throw sycl::exception(sycl::errc::runtime, "Failed to create pipe");
1231+
throw sycl::exception(sycl::errc::build, "Failed to create pipe");
12451232
}
12461233

12471234
int saved_stderr = dup(fileno(stderr));
12481235
int saved_stdout = dup(fileno(stdout));
12491236
if (dup2(pipefd[1], fileno(stderr)) == -1 ||
12501237
dup2(pipefd[1], fileno(stdout)) == -1) {
1251-
throw sycl::exception(sycl::errc::runtime,
1238+
throw sycl::exception(sycl::errc::build,
12521239
"Failed to redirect stderr/stdout");
12531240
}
12541241
close(pipefd[1]);
12551242
#endif
12561243

12571244
std::stringstream error_stream;
12581245

1246+
// Compile it!
12591247
auto Result = CompileSYCLHandle(SourceFile, IncludeFilesView, UserArgsView);
12601248

1261-
// Restore stderr/stdout
1262-
// std::cerr.rdbuf(old_stderr);
1263-
// std::cout.rdbuf(old_stdout);
1264-
12651249
// Restore stderr/stdout.
12661250
#ifdef _WIN32
12671251
SetStdHandle(STD_ERROR_HANDLE, saved_stderr);

0 commit comments

Comments
 (0)