Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/occa/internal/modes/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ namespace occa {
if (commandExitCode) {
OCCA_FORCE_ERROR(
"Error compiling [" << kernelName << "],"
" Command: [" << sCommand << ']'
" Command: [" << sCommand << "] exited with code " << commandExitCode << "\n"
<< "Output:\n\n"
<< commandOutput << "\n"
);
Expand Down
26 changes: 17 additions & 9 deletions src/occa/internal/modes/dpcpp/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,25 @@ namespace occa
}

const std::string &sCommand = command.str();
if (verbose)
{
io::stdout << sCommand << '\n';
if (verbose) {
io::stdout << "Compiling [" << kernelName << "]\n" << sCommand << "\n";
}

const int compileError = system(sCommand.c_str());

if (compileError)
{
OCCA_FORCE_ERROR("Error compiling [" << kernelName << "],"
<< " Command: ["<< sCommand << ']');
std::string commandOutput;
const int commandExitCode = sys::call(
sCommand.c_str(),
commandOutput
);

if (commandExitCode) {
OCCA_FORCE_ERROR(
"Error compiling [" << kernelName << "],"
" Command: [" << sCommand << "] exited with code " << commandExitCode << "\n\n"
<< "Output:\n\n"
<< commandOutput << "\n"
);
} else if (verbose) {
io::stdout << "Output:\n\n" << commandOutput << "\n";
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/occa/internal/modes/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ namespace occa {
if (commandExitCode) {
OCCA_FORCE_ERROR(
"Error compiling [" << kernelName << "],"
" Command: [" << sCommand << "]\n"
" Command: [" << sCommand << "] exited with code " << commandExitCode << "\n\n"
<< "Output:\n\n"
<< commandOutput << "\n"
);
Expand Down
8 changes: 4 additions & 4 deletions src/occa/internal/modes/metal/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ namespace occa {

const std::string airCommand = command.str();
if (verbose) {
io::stdout << "Compiling [" << kernelName << "]\n" << airCommand << "\n";
io::stdout << "Compiling Air Binary [" << kernelName << "]\n" << airCommand << "\n";
}

std::string commandOutput;
Expand All @@ -172,7 +172,7 @@ namespace occa {
if (commandExitCode) {
OCCA_FORCE_ERROR(
"Error compiling [" << kernelName << "],"
" Command: [" << airCommand << ']'
" Command: [" << airCommand << "] exited with code " << commandExitCode << "\n\n"
<< "Output:\n\n"
<< commandOutput << "\n"
);
Expand All @@ -198,7 +198,7 @@ namespace occa {

const std::string metallibCommand = command.str();
if (verbose) {
io::stdout << metallibCommand << '\n';
io::stdout << "Compiling Metallib [" << kernelName << "]\n" << metallibCommand << "\n";
}

std::string commandOutput;
Expand All @@ -210,7 +210,7 @@ namespace occa {
if (commandExitCode) {
OCCA_FORCE_ERROR(
"Error compiling [" << kernelName << "],"
" Command: [" << metallibCommand << ']'
" Command: [" << metallibCommand << "] exited with code " << commandExitCode << "\n\n"
<< "Output:\n\n"
<< commandOutput << "\n"
);
Expand Down
11 changes: 9 additions & 2 deletions src/occa/internal/utils/sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ namespace occa {
int call(const std::string &cmdline) {
#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))
FILE *fp = popen(cmdline.c_str(), "r");
if (!fp) return errno;
return pclose(fp);
#else
FILE *fp = _popen(cmdline.c_str(), "r");
if (!fp) return errno;
return _pclose(fp);
#endif
}
Expand All @@ -193,8 +195,13 @@ namespace occa {
FILE *fp = _popen(cmdline.c_str(), "r");
#endif

size_t lineBytes = 512;
char lineBuffer[512];
if (!fp) {
output = "Failed to launch process";
return errno;
}

const size_t lineBytes = 512;
char lineBuffer[lineBytes];

output = "";
while (fgets(lineBuffer, lineBytes, fp)) {
Expand Down