Skip to content

[Driver][SYCL] Improve -std setting behaviors for Windows #2461

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
Sep 17, 2020
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
19 changes: 10 additions & 9 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4056,10 +4056,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// device toolchain.
bool UseSYCLTriple = IsSYCLDevice && (!IsSYCL || IsSYCLOffloadDevice);

// Adjust IsWindowsXYZ for CUDA/HIP compilations. Even when compiling in
// Adjust IsWindowsXYZ for CUDA/HIP/SYCL compilations. Even when compiling in
// device mode (i.e., getToolchain().getTriple() is NVPTX/AMDGCN, not
// Windows), we need to pass Windows-specific flags to cc1.
if (IsCuda || IsHIP)
if (IsCuda || IsHIP || IsSYCL)
IsWindowsMSVC |= AuxTriple && AuxTriple->isWindowsMSVCEnvironment();

// C++ is not supported for IAMCU.
Expand Down Expand Up @@ -5171,7 +5171,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
/*Joined=*/true);
else if (IsWindowsMSVC)
ImplyVCPPCXXVer = true;
else if (IsSYCL)

if (IsSYCL && types::isCXX(InputType) &&
!Args.hasArg(options::OPT__SLASH_std))
// For DPC++, we default to -std=c++17 for all compilations. Use of -std
// on the command line will override.
CmdArgs.push_back("-std=c++17");
Expand Down Expand Up @@ -5753,12 +5755,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}

if (LanguageStandard.empty()) {
if (IsMSVC2015Compatible)
if (IsSYCL)
// For DPC++, C++17 is the default.
LanguageStandard = "-std=c++17";
else
LanguageStandard = "-std=c++14";
if (IsSYCL)
// For DPC++, C++17 is the default.
LanguageStandard = "-std=c++17";
else if (IsMSVC2015Compatible)
LanguageStandard = "-std=c++14";
else
LanguageStandard = "-std=c++11";
}
Expand Down
4 changes: 3 additions & 1 deletion clang/test/Driver/sycl-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,9 @@
// -std=c++17 override check
// RUN: %clangxx -### -c -fsycl -std=c++14 -xc++ %s 2>&1 | FileCheck -check-prefix=CHECK-STD-OVR %s
// RUN: %clang_cl -### -c -fsycl /std:c++14 -TP %s 2>&1 | FileCheck -check-prefix=CHECK-STD-OVR %s
// CHECK-STD-OVR: clang{{.*}} "-std=c++14"
// CHECK-STD-OVR: clang{{.*}} "-emit-llvm-bc" {{.*}} "-std=c++14"
// CHECK-STD-OVR: clang{{.*}} "-fsyntax-only" {{.*}} "-std=c++14"
// CHECK-STD-OVR: clang{{.*}} "-emit-obj" {{.*}} "-std=c++14"
// CHECK-STD-OVR-NOT: clang{{.*}} "-std=c++17"

// TODO: SYCL specific fail - analyze and enable
Expand Down