Skip to content

[SYCL] Warning if use sycl without dynamic C++ RT on Windows #2501

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
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
81 changes: 50 additions & 31 deletions sycl/include/CL/sycl/stl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,53 @@
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

template < class T, class Alloc = std::allocator<T> >
using vector_class = std::vector<T, Alloc>;

using string_class = std::string;

template <class Sig>
using function_class = std::function<Sig>;

using mutex_class = std::mutex;

template <class T, class Deleter = std::default_delete<T>>
using unique_ptr_class = std::unique_ptr<T, Deleter>;

template <class T>
using shared_ptr_class = std::shared_ptr<T>;

template <class T>
using weak_ptr_class = std::weak_ptr<T>;

template <class T>
using hash_class = std::hash<T>;

using exception_ptr_class = std::exception_ptr;

template <typename T, typename... ArgsT>
unique_ptr_class<T> make_unique_ptr(ArgsT &&... Args) {
return unique_ptr_class<T>(new T(std::forward<ArgsT>(Args)...));
}
} // sycl
} // cl

#if defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)
// SYCL library is designed such a way that STL objects cross DLL boundary,
// which is guaranteed to work properly only when the application uses the same
// C++ runtime that SYCL library uses.
// The appplications using sycl.dll must be linked with dynamic/release C++ MSVC
// runtime, i.e. be compiled with /MD switch. Similarly, the applications using
// sycld.dll must be linked with dynamic/debug C++ runtime and be compiled with
// /MDd switch.
// Compiler automatically adds /MD or /MDd when -fsycl switch is used.
// The options /MD and /MDd that make the code to use dynamic runtime also
// define the _DLL macro.
#if defined(_MSC_VER)
#pragma message( \
"SYCL library is designed to work safely with dynamic C++ runtime." \
"Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, " \
"or -fsycl switch to set C++ runtime automatically.")
#else
#warning "SYCL library is designed to work safely with dynamic C++ runtime."\
"Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, "\
"or -fsycl switch to set C++ runtime automatically."
#endif
#endif // defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)

template <class T, class Alloc = std::allocator<T>>
using vector_class = std::vector<T, Alloc>;

using string_class = std::string;

template <class Sig> using function_class = std::function<Sig>;

using mutex_class = std::mutex;

template <class T, class Deleter = std::default_delete<T>>
using unique_ptr_class = std::unique_ptr<T, Deleter>;

template <class T> using shared_ptr_class = std::shared_ptr<T>;

template <class T> using weak_ptr_class = std::weak_ptr<T>;

template <class T> using hash_class = std::hash<T>;

using exception_ptr_class = std::exception_ptr;

template <typename T, typename... ArgsT>
unique_ptr_class<T> make_unique_ptr(ArgsT &&... Args) {
return unique_ptr_class<T>(new T(std::forward<ArgsT>(Args)...));
}

} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/aspects.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %t.out

//==--------------- aspects.cpp - SYCL device test ------------------------==//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/buffer/buffer_ctad.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics

#include <CL/sycl.hpp>
Expand Down
10 changes: 2 additions & 8 deletions sycl/test/basic_tests/context.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %RUN_ON_HOST %t.out

//==--------------- context.cpp - SYCL context test ------------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// This test performs basic check of the SYCL context class.

#include <sycl/sycl.hpp>
#include <iostream>
Expand Down
10 changes: 2 additions & 8 deletions sycl/test/basic_tests/device.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %RUN_ON_HOST %t.out

//==--------------- device.cpp - SYCL device test --------------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// This test performs basic check of the SYCL device class.

#include <CL/sycl.hpp>
#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/id_ctad.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics
//==--------------- id_ctad.cpp - SYCL id CTAD test ----------------------==//
//
Expand Down
4 changes: 2 additions & 2 deletions sycl/test/basic_tests/implicit_conversion_error.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to change this test as it is compile-time check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new static_assert at stl.hpp is emitted on Windows when a) user does not use -fsycl and b) when such compilation would potentially lead to linking with static RT.
I will check if there is any difference in compilation macros with/with -fsyntax-only and if that difference usable in stl.hpp to not give an error with -fsyntax-only.

//==-- implicit_conversion_error.cpp - Unintended implicit conversion check --==//
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
//=- implicit_conversion_error.cpp - Unintended implicit conversion check -=//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
5 changes: 3 additions & 2 deletions sycl/test/basic_tests/marray/marray.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include
// RUN: %t.out
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %RUN_ON_HOST %t.out

//==--------------- marray.cpp - SYCL marray test --------------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand Down
12 changes: 4 additions & 8 deletions sycl/test/basic_tests/property_list.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// RUN: %clangxx %s -o %t.out -lsycl -I%sycl_include
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %RUN_ON_HOST %t.out
//
// CHECK: PASSED
//==--------------- property_list.cpp - SYCL property list test ------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// This test performs basic check of the SYCL property_list class.

#include <CL/sycl.hpp>
#include <iostream>

Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/range_ctad.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics
//==--------------- range_ctad.cpp - SYCL range CTAD test ----------------------==//
//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/range_error.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning -fsyntax-only
// RUN: %clangxx -fsycl -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning -fsyntax-only
//==--------------- range_error.cpp - SYCL range error test ----------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/reduction_known_identity.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics

// This test performs basic checks of has_known_identity and known_identity
Expand Down
6 changes: 3 additions & 3 deletions sycl/test/basic_tests/stdcpp_compat.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -c -o %t.out
// RUN: %clangxx -std=c++14 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
// RUN: %clangxx -std=c++20 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
// RUN: %clangxx -fsycl -std=c++14 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
// RUN: %clangxx -fsycl -std=c++17 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
// RUN: %clangxx -fsycl -std=c++20 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
// expected-no-diagnostics

#include <CL/sycl.hpp>
4 changes: 2 additions & 2 deletions sycl/test/basic_tests/valid_kernel_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//

// The test checks that the types can be used to pass kernel parameters by value
// RUN: %clangxx -fsyntax-only %s -I %sycl_include -Wno-sycl-strict -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only %s -Wno-sycl-strict -Xclang -verify-ignore-unexpected=note,warning

// Check that the test can be compiled with device compiler as well.
// RUN: %clangxx -fsycl-device-only -fsyntax-only %s -I %sycl_include -Wno-sycl-strict
// RUN: %clangxx -fsycl-device-only -fsyntax-only %s -Wno-sycl-strict

#include <CL/sycl.hpp>

Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/vectors/ctad.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -std=c++17 -I %sycl_include -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics
//==--------------- ctad.cpp - SYCL vector CTAD test --------------------==//
//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/vectors/vectors.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %t.out
//==--------------- vectors.cpp - SYCL vectors test ------------------------==//
//
Expand Down
3 changes: 1 addition & 2 deletions sycl/test/esimd/vadd.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TODO ESIMD enable host device under -fsycl
// RUN: %clangxx -I %sycl_include %s -o %t.out -lsycl
// RUN: %clangxx -fsycl %s -o %t.out
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not catching it, but there is a regression for this test. BTW, I'm not sure how it slipped through the CI.
This test fails with:

InvalidFunctionCall: Unexpected llvm intrinsic:
 llvm.genx.local.id.v3i32 [Src: /iusers/dbakhval/github/llvm/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp:2782 false ]

As of today, we still require -fsycl-explicit-simd flag for ESIMD code. I submitted #3457 to fix this.

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, I'm not sure how it slipped through the CI.

This casts shadow on CI validation and ESIMD feature validation in particular. @DenisBakhvalov, could you investigate why this regression happened, please? Could it be a conflict between commits?

// RUN: %RUN_ON_HOST %t.out

// Check that the code compiles with -O0 and -g
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/multi_ptr/ctad.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics
//==--------------- ctad.cpp - SYCL multi_ptr CTAD test --------------------==//
//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/on-device/extensions/intel-ext-device.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=level_zero:gpu %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl:gpu %t.out
//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/regression/macro_conflict.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsyntax-only -I %sycl_include -Xclang -verify %s -o %t.out -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -o %t.out -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics
//
//===----------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/regression/sub-group-store-const-ref.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics
//
//==-- sub-group-store-const-ref.cpp ---------------------------------------==//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/regression/unable-to-redeclare-device.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsyntax-only -Xclang -verify -DCL_TARGET_OPENCL_VERSION=220 %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -DCL_TARGET_OPENCL_VERSION=220 %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics
//
//==-- unable-to-redeclare-device.cpp --------------------------------------==//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/regression/vec-to-half.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang -O0 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clang -fsycl -O0 -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics

#include <CL/sycl.hpp>
Expand Down
10 changes: 6 additions & 4 deletions sycl/test/separate-compile/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
//
// >> ---- compile src1
// >> device compilation...
// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_a.h %s -c -o a_kernel.bc -I %sycl_include -Wno-sycl-strict
// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_a.h %s -c -o a_kernel.bc -Wno-sycl-strict
// >> host compilation...
// RUN: %clangxx -include sycl_ihdr_a.h -g -c %s -o a.o -I %sycl_include -Wno-sycl-strict
// Driver automatically adds -D_DLL and -D_MT on Windows with -fsycl.
// Add those defines required for Windows and harmless for Linux.
// RUN: %clangxx -D_DLL -D_MT -include sycl_ihdr_a.h -g -c %s -o a.o -I %sycl_include -Wno-sycl-strict
//
// >> ---- compile src2
// >> device compilation...
// RUN: %clangxx -DB_CPP=1 -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_b.h %s -c -o b_kernel.bc -I %sycl_include -Wno-sycl-strict
// RUN: %clangxx -DB_CPP=1 -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_b.h %s -c -o b_kernel.bc -Wno-sycl-strict
// >> host compilation...
// RUN: %clangxx -DB_CPP=1 -include sycl_ihdr_b.h -g -c %s -o b.o -I %sycl_include -Wno-sycl-strict
// RUN: %clangxx -DB_CPP=1 -D_DLL -D_MT -include sycl_ihdr_b.h -g -c %s -o b.o -I %sycl_include -Wno-sycl-strict
//
// >> ---- bundle .o with .spv
// >> run bundler
Expand Down