Skip to content

Capture compiler stderr in FindSYCLToolkit.cmake #1889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Maetveis
Copy link

FindSYCLToolkit exectutes the DPC++ compiler using the execute_process CMake command to extract information about the compiler. To help debugging it tries to capture the output of the compilation to a file named Compile.log. However before this patch only the standard output was captured, even though the compiler will log errors to the standard error, and will almost certainly leave stdout empty.

Capture both stderr and stdout to the same file, this is explicitly supported by CMake, execute_process documentation notes:

Added in version 3.3: If the same is named for both OUTPUT_FILE and ERROR_FILE then it will be used for both standard output and standard error pipes.

FindSYCLToolkit exectutes the DPC++ compiler using the `execute_process` CMake command to extract information about the compiler. To help debugging it tries to capture the output of the compilation to a file named Compile.log.
However before this patch only the standard output was captured, even though the compiler will log errors to the standard error, and will almost certainly leave stdout empty.

Capture both stderr and stdout to the same file, this is explicitly supported by CMake, `execute_process` documentation notes:
> Added in version 3.3: If the same <file> is named for both OUTPUT_FILE and ERROR_FILE then it will be used for both standard output and standard error pipes.
@Copilot Copilot AI review requested due to automatic review settings July 30, 2025 10:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves debugging capabilities in the FindSYCLToolkit.cmake module by capturing both standard output and standard error from compiler execution. Previously, only stdout was being captured to the Compile.log file, which missed important error messages that compilers typically write to stderr.

  • Adds ERROR_FILE parameter to capture stderr alongside stdout in the same log file
  • Leverages CMake's built-in capability to merge stdout and stderr into a single file when the same filename is specified for both

Comment on lines +118 to 119
ERROR_FILE ${SYCL_CMPLR_TEST_DIR}/Compile.log
OUTPUT_FILE ${SYCL_CMPLR_TEST_DIR}/Compile.log
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The ERROR_FILE parameter should be placed before OUTPUT_FILE to follow CMake's conventional parameter ordering in execute_process commands.

Suggested change
ERROR_FILE ${SYCL_CMPLR_TEST_DIR}/Compile.log
OUTPUT_FILE ${SYCL_CMPLR_TEST_DIR}/Compile.log
OUTPUT_FILE ${SYCL_CMPLR_TEST_DIR}/Compile.log
ERROR_FILE ${SYCL_CMPLR_TEST_DIR}/Compile.log

Copilot uses AI. Check for mistakes.

@Maetveis
Copy link
Author

It seems like the compile result and output is expected to be printed to the CMake Log, but it cannot be both captured to a file and a variable.

@Maetveis Maetveis marked this pull request as draft July 30, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant