llvm icon indicating copy to clipboard operation
llvm copied to clipboard

[Driver][SYCL] Compile source file for integration header generation

Open mdtoguchi opened this issue 4 weeks ago • 5 comments

When compiler for preprocessing only, the preprocessing step that occurs does not generate the integration header/footer information that is used during the host compilation step. To generate the integration information in this case, the driver inserts an additional compilation step that creates the files to be consumed at the host step.

The compilation step to produce the integration information is using the generated preprocessed file. For cases where there are build warnings that are emitted during this step, use of -Werror will cause the compilation to fail. These diagnostics are typically suppressed when not performing preprocess only compilations, but due to the fact that the build step against the preprocessed file does not know to suppress the diagnostics from system headers, compilation behaviors are at a disconnect.

To fix this, the behavior when creating a preprocessed file (i.e. when we are using -E and stopping compilation), the driver will now compile the original source file instead of the preprocessed file.

mdtoguchi avatar Dec 03 '25 19:12 mdtoguchi

@intel/dpcpp-clang-driver-reviewers, please take a look

mdtoguchi avatar Dec 05 '25 15:12 mdtoguchi

When compiler for preprocessing only, the preprocessing step that occurs does not generate the integration header/footer information that is used during the host compilation step. To generate the integration information in this case, the driver inserts an additional compilation step that creates the files to be consumed at the host step.

The compilation step to produce the integration information is using the generated preprocessed file. For cases where there are build warnings that are emitted during this step, use of -Werror will cause the compilation to fail. These diagnostics are typically suppressed when not performing preprocess only compilations, but due to the fact that the build step against the preprocessed file does not know to suppress the diagnostics from system headers, compilation behaviors are at a disconnect.

To fix this, the behavior when creating a preprocessed file (i.e. when we are using -E and stopping compilation), the driver will now compile the original source file instead of the preprocessed file.

Just to confirm I understood correctly, when we invoke clang to perform only the preprocessing step using clang -E <sycl-source-file.cpp> , the -fsycl-int-header.h and -fsycl-int-footer integration header/footer header files do not get generated. In order to generate the header/footer files, an additional compilation step is introduced to use the original source file and not the pre-processed code. Question: Device code compilation step typically generates the header/footer files. ie "clang -cc1 -fsycl-is-device .." Is this newly introduced compilation step the device code compilation step?

srividya-sundaram avatar Dec 08 '25 18:12 srividya-sundaram

Just to confirm I understood correctly, when we invoke clang to perform only the preprocessing step using clang -E <sycl-source-file.cpp> , the -fsycl-int-header.h and -fsycl-int-footer integration header/footer header files do not get generated. In order to generate the header/footer files, an additional compilation step is introduced to use the original source file and not the pre-processed code. Question: Device code compilation step typically generates the header/footer files. ie "clang -cc1 -fsycl-is-device .." Is this newly introduced compilation step the device code compilation step?

yes, the new compilation step is the device compilation step. There isn't really a new compilation step being introduced, it has always been there when doing preprocessing only. The difference is just the input file being the source file instead of the preprocessed file.

mdtoguchi avatar Dec 08 '25 21:12 mdtoguchi

When compiler for preprocessing only, the preprocessing step that occurs does not generate the integration header/footer information that is used during the host compilation step. To generate the integration information in this case, the driver inserts an additional compilation step that creates the files to be consumed at the host step.

The compilation step to produce the integration information is using the generated preprocessed file. For cases where there are build warnings that are emitted during this step, use of -Werror will cause the compilation to fail. These diagnostics are typically suppressed when not performing preprocess only compilations, but due to the fact that the build step against the preprocessed file does not know to suppress the diagnostics from system headers, compilation behaviors are at a disconnect.

To fix this, the behavior when creating a preprocessed file (i.e. when we are using -E and stopping compilation), the driver will now compile the original source file instead of the preprocessed file

Can you share why compilation against the preprocessed file does not have the context to suppress these diagnostics from the system headers?

srividya-sundaram avatar Dec 08 '25 22:12 srividya-sundaram

Can you share why compilation against the preprocessed file does not have the context to suppress these diagnostics from the system headers?

As discussed offline, the issue deals with how the generated preprocessed file does not have the informational tags that contain information about the file/header that was pulled into the preprocessed source.

mdtoguchi avatar Dec 10 '25 20:12 mdtoguchi

not have the informational tags that contain information about the file/header that was pulled into the preprocessed source

Thanks for following up on this offline.

srividya-sundaram avatar Dec 11 '25 19:12 srividya-sundaram

@intel/llvm-gatekeepers, this is ready for merge - thanks!

mdtoguchi avatar Dec 11 '25 21:12 mdtoguchi