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
14 changes: 11 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5282,6 +5282,12 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA,
HostCompileArgs.push_back(TCArgs.MakeArgString(*CWD));
}

// Add /external:W0 for MSVC based compilation. We are using /external:I
// which requires /external:Wn upon usage. Use of /external:W0 disables
// warnings from headers that are included with /external:I.
if (IsMSVCHostCompiler)
HostCompileArgs.push_back("/external:W0");

// Add default header search directories.
SmallString<128> BaseDir(C.getDriver().Dir);
llvm::sys::path::append(BaseDir, "..", "include");
Expand All @@ -5292,11 +5298,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 ? "/external:I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(SYCLDir));
HostCompileArgs.push_back("-I");
HostCompileArgs.push_back(IsMSVCHostCompiler ? "/external:I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(STLWrappersDir));
HostCompileArgs.push_back("-I");
HostCompileArgs.push_back(IsMSVCHostCompiler ? "/external:I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(BaseDir));

if (!OutputAdded) {
Expand Down
13 changes: 11 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,22 @@
// 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: "/external:W0"
// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"
// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"
// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
// HOST_COMPILER_CL: link{{.*}} "[[HOSTOBJ]]"

/// check for additional host options
Expand Down
Loading