Skip to content

Conversation

upsj
Copy link
Member

@upsj upsj commented Apr 20, 2025

For CUDA/HIP and DPCPP, we create separate copies of the source files using configure_file(...) to apply different CMake file properties to them. For the compiler to report error messages with the correct source file name, this adds a #line preprocessor statement to the top of these generated files.

For CUDA/HIP and DPCPP, we create separate copies of the source files using configure_file(...)
to apply different CMake file properties to them.
For the compiler to report error messages with the correct source file name,
this adds a #line preprocessor statement to the top of these generated files.
@upsj upsj added the 1:ST:ready-for-review This PR is ready for review label Apr 20, 2025
@upsj upsj requested a review from a team April 20, 2025 17:38
@upsj upsj self-assigned this Apr 20, 2025
@ginkgo-bot ginkgo-bot added reg:build This is related to the build system. type:matrix-format This is related to the Matrix formats labels Apr 20, 2025
//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/
Copy link
Member Author

Choose a reason for hiding this comment

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

I am using this weird comment structure to make sure both the original file and the generated file are valid C++ code. The ´#line` directive can start after a comment, but afaik it can't end with a comment, so that needs to be in the next line.

//
// SPDX-License-Identifier: BSD-3-Clause

/*@GKO_PREPROCESSOR_FILENAME_HELPER@*/
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I am missing something, wouldn't this be now after preprocessing be /*/*#line 5 .... */*/ ?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, the above comment clarifies it. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

The actual string will be

/**/
#line 5 "file.cpp"
/**/

@upsj upsj added 1:ST:ready-to-merge This PR is ready to merge. 1:ST:no-changelog-entry Skip the wiki check for changelog update and removed 1:ST:ready-for-review This PR is ready for review labels Apr 20, 2025
@upsj upsj merged commit a598504 into develop Apr 21, 2025
14 of 17 checks passed
@upsj upsj deleted the original_filename_in_generated_code branch April 21, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1:ST:no-changelog-entry Skip the wiki check for changelog update 1:ST:ready-to-merge This PR is ready to merge. reg:build This is related to the build system. type:matrix-format This is related to the Matrix formats

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants