Skip to content

Commit d5faf83

Browse files
author
Alexander Batashev
committed
[SYCL] Add tests for MSVC CRT logic
Signed-off-by: Alexander Batashev <[email protected]>
1 parent d64f903 commit d5faf83

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed

clang/test/Driver/sycl-offload.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,12 @@
500500
// CHECK-LINK-SYCL: "{{.*}}link{{(.exe)?}}"
501501
// CHECK-LINK-SYCL: "-defaultlib:sycl.lib"
502502

503+
/// Check sycld.lib is chosen with /MDd and /MTd
504+
// RUN: %clang_cl -fsycl /MDd %s -o %t -### 2>&1 | FileCheck -check-prefix=CHECK-LINK-SYCL-DEBUG %s
505+
// RUN: %clang_cl -fsycl /MTd %s -o %t -### 2>&1 | FileCheck -check-prefix=CHECK-LINK-SYCL-DEBUG %s
506+
// CHECK-LINK-SYCL-DEBUG: "{{.*}}link{{(.exe)?}}"
507+
// CHECK-LINK-SYCL-DEBUG: "-defaultlib:sycld.lib"
508+
503509
/// ###########################################################################
504510

505511
/// test behaviors of -foffload-static-lib=<lib>

sycl/doc/GetStartedWithSYCLCompiler.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ int main() {
362362
translation units.
363363
- SYCL host device is not fully supported.
364364
- SYCL works only with OpenCL implementations supporting out-of-order queues.
365+
- On Windows linking SYCL applications with `/MTd` flag is known to cause crashes.
365366

366367
# Find More
367368

sycl/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(LLVM_BUILD_BINARY_DIRS "${LLVM_BINARY_DIR}/bin/")
33
set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin/")
44
set(CLANG_IN_BUILD "${LLVM_BINARY_DIR}/bin/clang")
55
set(CLANGXX_IN_BUILD "${LLVM_BINARY_DIR}/bin/clang++")
6+
set(CLANGCL_IN_BUILD "${LLVM_BINARY_DIR}/bin/clang-cl")
67

78
get_target_property(SYCL_BINARY_DIR sycl-toolchain BINARY_DIR)
89
get_target_property(SYCL_SOURCE_DIR sycl-toolchain SOURCE_DIR)

sycl/test/lit.cfg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
config.substitutions.append( ('%clang_cc1', ' ' + config.clang + ' -cc1 ') )
6060
config.substitutions.append( ('%clangxx', ' ' + config.clangxx + ' -I'+config.opencl_include ) )
61+
config.substitutions.append( ('%clang_cl', ' ' + config.clang_cl + ' /I '+config.opencl_include ) )
6162
config.substitutions.append( ('%clang', ' ' + config.clang + ' -I'+config.opencl_include ) )
6263
config.substitutions.append( ('%llvm_build_libs_dir', config.llvm_build_libs_dir ) )
6364
config.substitutions.append( ('%opencl_include', config.opencl_include ) )

sycl/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import sys
44

55
config.clang = "@CLANG_IN_BUILD@"
66
config.clangxx = "@CLANGXX_IN_BUILD@"
7+
config.clang_cl = "@CLANGCL_IN_BUILD@"
78
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
89
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
910
config.llvm_build_libs_dir = "@LLVM_BUILD_LIBRARY_DIRS@"

sycl/test/regression/msvc_crt.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %clang_cl -fsycl /MD -o %t1.exe %s
2+
// RUN: %CPU_RUN_PLACEHOLDER %t1.exe
3+
// RUN: %clang_cl -fsycl /MDd -o %t2.exe %s
4+
// RUN: %CPU_RUN_PLACEHOLDER %t2.exe
5+
// RUN: %clang_cl -fsycl /MT -o %t3.exe %s
6+
// RUN: %CPU_RUN_PLACEHOLDER %t3.exe
7+
// REQUIRES: system-windows
8+
//==-------------- msvc_crt.cpp - SYCL MSVC CRT test -----------------------==//
9+
//
10+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
11+
// See https://llvm.org/LICENSE.txt for license information.
12+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
13+
//
14+
//===----------------------------------------------------------------------===//
15+
//
16+
// MSVC provides two different incompatible variants of CRT: debug and release.
17+
// This test checks if clang driver is able to handle this properly.
18+
19+
#include <CL/sycl.hpp>
20+
21+
using namespace cl::sycl;
22+
23+
int main() {
24+
int data[] = {0, 0, 0};
25+
26+
{
27+
buffer<int, 1> b(data, range<1>(3), {property::buffer::use_host_ptr()});
28+
queue q;
29+
q.submit([&](handler &cgh) {
30+
auto B = b.get_access<access::mode::write>(cgh);
31+
cgh.parallel_for<class test>(range<1>(3), [=](id<1> idx) {
32+
B[idx] = 1;
33+
});
34+
});
35+
}
36+
37+
bool isSuccess = true;
38+
39+
for (int i = 0; i < 3; i++)
40+
if (data[i] != 1) isSuccess = false;
41+
42+
if (!isSuccess)
43+
return -1;
44+
45+
return 0;
46+
}

0 commit comments

Comments
 (0)