Skip to content

Commit 2bb0cf7

Browse files
authored
[Driver][SYCL] Improve -std setting behaviors for Windows (#2461)
When using -std:arg on Windows, the std setting was not being applied to the device compilation. Make needed adjustements to allow this which is due to the -std option differences in regards to Windows.
1 parent 14e227c commit 2bb0cf7

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,10 +4056,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
40564056
// device toolchain.
40574057
bool UseSYCLTriple = IsSYCLDevice && (!IsSYCL || IsSYCLOffloadDevice);
40584058

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

40654065
// C++ is not supported for IAMCU.
@@ -5174,7 +5174,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
51745174
/*Joined=*/true);
51755175
else if (IsWindowsMSVC)
51765176
ImplyVCPPCXXVer = true;
5177-
else if (IsSYCL)
5177+
5178+
if (IsSYCL && types::isCXX(InputType) &&
5179+
!Args.hasArg(options::OPT__SLASH_std))
51785180
// For DPC++, we default to -std=c++17 for all compilations. Use of -std
51795181
// on the command line will override.
51805182
CmdArgs.push_back("-std=c++17");
@@ -5758,12 +5760,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
57585760
}
57595761

57605762
if (LanguageStandard.empty()) {
5761-
if (IsMSVC2015Compatible)
5762-
if (IsSYCL)
5763-
// For DPC++, C++17 is the default.
5764-
LanguageStandard = "-std=c++17";
5765-
else
5766-
LanguageStandard = "-std=c++14";
5763+
if (IsSYCL)
5764+
// For DPC++, C++17 is the default.
5765+
LanguageStandard = "-std=c++17";
5766+
else if (IsMSVC2015Compatible)
5767+
LanguageStandard = "-std=c++14";
57675768
else
57685769
LanguageStandard = "-std=c++11";
57695770
}

clang/test/Driver/sycl-offload.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,9 @@
898898
// -std=c++17 override check
899899
// RUN: %clangxx -### -c -fsycl -std=c++14 -xc++ %s 2>&1 | FileCheck -check-prefix=CHECK-STD-OVR %s
900900
// RUN: %clang_cl -### -c -fsycl /std:c++14 -TP %s 2>&1 | FileCheck -check-prefix=CHECK-STD-OVR %s
901-
// CHECK-STD-OVR: clang{{.*}} "-std=c++14"
901+
// CHECK-STD-OVR: clang{{.*}} "-emit-llvm-bc" {{.*}} "-std=c++14"
902+
// CHECK-STD-OVR: clang{{.*}} "-fsyntax-only" {{.*}} "-std=c++14"
903+
// CHECK-STD-OVR: clang{{.*}} "-emit-obj" {{.*}} "-std=c++14"
902904
// CHECK-STD-OVR-NOT: clang{{.*}} "-std=c++17"
903905

904906
// TODO: SYCL specific fail - analyze and enable

0 commit comments

Comments
 (0)