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
39 changes: 21 additions & 18 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5045,24 +5045,27 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA,
if (IsMSVCHostCompiler)
HostCompileArgs.push_back("/external:W0");

// Add default header search directories.
SmallString<128> BaseDir(C.getDriver().Dir);
llvm::sys::path::append(BaseDir, "..", "include");
SmallString<128> SYCLDir(BaseDir);
llvm::sys::path::append(SYCLDir, "sycl");
// This is used to provide our wrappers around STL headers that provide
// additional functions/template specializations when the user includes those
// STL headers in their programs (e.g., <complex>).
SmallString<128> STLWrappersDir(SYCLDir);
llvm::sys::path::append(STLWrappersDir, "stl_wrappers");
// 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(IsMSVCHostCompiler ? "/external:I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(STLWrappersDir));
HostCompileArgs.push_back(IsMSVCHostCompiler ? "/external:I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(BaseDir));
namespace options = clang::driver::options;
if (!TCArgs.hasArg(options::OPT_nostdlibinc, options::OPT_nostdinc)) {
// Add default header search directories.
SmallString<128> BaseDir(C.getDriver().Dir);
llvm::sys::path::append(BaseDir, "..", "include");
SmallString<128> SYCLDir(BaseDir);
llvm::sys::path::append(SYCLDir, "sycl");
// This is used to provide our wrappers around STL headers that provide
// additional functions/template specializations when the user includes
// those STL headers in their programs (e.g., <complex>).
SmallString<128> STLWrappersDir(SYCLDir);
llvm::sys::path::append(STLWrappersDir, "stl_wrappers");
// Add the SYCL specific header directories as system directories for non
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that you have retained the comments from the original code, but could you add some context on why SYCL specific header directories are added as system directories for non MSVC compilers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should go into a separate PR, possibly merging the implementation of host/device toolchains.

// MSVC compilers.
HostCompileArgs.push_back(IsMSVCHostCompiler ? "/external:I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(SYCLDir));
HostCompileArgs.push_back(IsMSVCHostCompiler ? "/external:I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(STLWrappersDir));
HostCompileArgs.push_back(IsMSVCHostCompiler ? "/external:I" : "-isystem");
HostCompileArgs.push_back(TCArgs.MakeArgString(BaseDir));
}

if (!OutputAdded) {
// Add output file to the command line. This is assumed to be prefaced
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ void SYCLInstallationDetector::getSYCLDeviceLibPath(

void SYCLInstallationDetector::addSYCLIncludeArgs(
const ArgList &DriverArgs, ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nobuiltininc))
namespace options = clang::driver::options;
if (DriverArgs.hasArg(options::OPT_nostdlibinc, options::OPT_nostdinc)) {
return;
}
// Add the SYCL header search locations in the specified order.
// ../include/sycl/stl_wrappers
// ../include
Expand Down
9 changes: 9 additions & 0 deletions clang/test/Driver/sycl-nostdinc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %clangxx -fsycl -fsycl-device-only -nostdlibinc -fsyntax-only %s
// RUN: %clangxx -fsycl -fsycl-device-only -nostdinc -fsyntax-only %s

// RUN: %clangxx -fsycl -nostdlibinc -fsyntax-only %s
// RUN: %clangxx -fsycl -nostdinc -fsyntax-only %s

#if __has_include(<sycl/sycl.hpp>)
#error "expected to *not* be able to find SYCL headers"
#endif
Loading