Skip to content

[Driver][SYCL] Pass as system headers for external SYCL host compilation #18449

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

Merged
merged 2 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5292,11 +5292,13 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA,
// STL headers in their programs (e.g., <complex>).
SmallString<128> STLWrappersDir(SYCLDir);
llvm::sys::path::append(STLWrappersDir, "stl_wrappers");
HostCompileArgs.push_back("-I");
// Add the SYCL specific header directories as system directories for non
// MSVC compilers.
HostCompileArgs.push_back(IsMSVCHostCompiler ? "-I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(SYCLDir));
HostCompileArgs.push_back("-I");
HostCompileArgs.push_back(IsMSVCHostCompiler ? "-I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(STLWrappersDir));
HostCompileArgs.push_back("-I");
HostCompileArgs.push_back(IsMSVCHostCompiler ? "-I" : "-isystem");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use /external:I for MSVC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like we can. I double checked our release support matrix, and the releases we support doesn't require the additional /external:experimental flag.

HostCompileArgs.push_back(TCArgs.MakeArgString(BaseDir));

if (!OutputAdded) {
Expand Down
12 changes: 10 additions & 2 deletions clang/test/Driver/sycl-host-compiler-old-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
// RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-host-compiler=/some/dir/g++ %s -### 2>&1 \
// RUN: | FileCheck -check-prefix=HOST_COMPILER %s
// HOST_COMPILER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer={{.*}}"
// HOST_COMPILER: g++{{.*}} "-c" "-include" "[[INTHEADER]]" "-iquote" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"{{.*}} "-o" "[[HOSTOBJ:.+\.o]]"{{.*}}
// HOST_COMPILER: g++{{.*}} "-c" "-include" "[[INTHEADER]]"
// HOST_COMPILER-SAME: "-iquote"
// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"
// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"
// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
// HOST_COMPILER-SAME: "-o" "[[HOSTOBJ:.+\.o]]"
// HOST_COMPILER: ld{{.*}} "[[HOSTOBJ]]"

// RUN: %clang_cl -fsycl --no-offload-new-driver -fsycl-host-compiler=/some/dir/cl %s -### 2>&1 \
// RUN: | FileCheck -check-prefix=HOST_COMPILER_CL %s
// HOST_COMPILER_CL: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer={{.*}}"
// HOST_COMPILER_CL: cl{{.*}} "-c" "-Fo[[HOSTOBJ:.+\.obj]]" "-FI" "[[INTHEADER]]"{{.*}} "-I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"{{.*}}
// HOST_COMPILER_CL: cl{{.*}} "-c" "-Fo[[HOSTOBJ:.+\.obj]]" "-FI" "[[INTHEADER]]"
// HOST_COMPILER_CL-SAME: "-I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"
// HOST_COMPILER_CL-SAME: "-I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"
// HOST_COMPILER_CL-SAME: "-I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
// HOST_COMPILER_CL: link{{.*}} "[[HOSTOBJ]]"

/// check for additional host options
Expand Down