From e6388c68f3839ca9964458869eaccfd4051d009e Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 1 Oct 2024 09:51:44 -0700 Subject: [PATCH 1/8] Add C++ linkage specification to SYCL assert headers --- sycl/include/sycl/stl_wrappers/assert.h | 2 ++ sycl/include/sycl/stl_wrappers/cassert | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sycl/include/sycl/stl_wrappers/assert.h b/sycl/include/sycl/stl_wrappers/assert.h index 67395dc7095d6..bf59456943940 100644 --- a/sycl/include/sycl/stl_wrappers/assert.h +++ b/sycl/include/sycl/stl_wrappers/assert.h @@ -10,6 +10,7 @@ // according to the current state of NDEBUG each time that is // included. +extern "C++" { #if defined(__has_include_next) #include_next #else @@ -42,3 +43,4 @@ __devicelib_assert_fail(const char *, const char *, int32_t, const char *, #endif #endif #endif +} diff --git a/sycl/include/sycl/stl_wrappers/cassert b/sycl/include/sycl/stl_wrappers/cassert index f91cf8b632984..a35c969c9e0c8 100644 --- a/sycl/include/sycl/stl_wrappers/cassert +++ b/sycl/include/sycl/stl_wrappers/cassert @@ -10,6 +10,7 @@ // according to the current state of NDEBUG each time that is // included. +extern "C++" { #if defined(__has_include_next) #include_next #else @@ -42,3 +43,4 @@ __devicelib_assert_fail(const char *, const char *, int32_t, const char *, #endif #endif #endif +} From 3e80979adf47653dc969d331d0ed9cbd5217484a Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 1 Oct 2024 12:11:47 -0700 Subject: [PATCH 2/8] Add tests for assert headers linkage specifications --- .../basic_tests/assert_header_with_c_linkage.cpp | 14 ++++++++++++++ .../basic_tests/cassert_header_with_c_linkage.cpp | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 sycl/test/basic_tests/assert_header_with_c_linkage.cpp create mode 100644 sycl/test/basic_tests/cassert_header_with_c_linkage.cpp diff --git a/sycl/test/basic_tests/assert_header_with_c_linkage.cpp b/sycl/test/basic_tests/assert_header_with_c_linkage.cpp new file mode 100644 index 0000000000000..169c4adc26975 --- /dev/null +++ b/sycl/test/basic_tests/assert_header_with_c_linkage.cpp @@ -0,0 +1,14 @@ +// RUN: %clangxx -fsycl -c %s + +// Verify that compilation works when assert.h is wrapped by a C linkage +// specification. + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +} +#endif diff --git a/sycl/test/basic_tests/cassert_header_with_c_linkage.cpp b/sycl/test/basic_tests/cassert_header_with_c_linkage.cpp new file mode 100644 index 0000000000000..b31b16a553a38 --- /dev/null +++ b/sycl/test/basic_tests/cassert_header_with_c_linkage.cpp @@ -0,0 +1,14 @@ +// RUN: %clangxx -fsycl -c %s + +// Verify that compilation works when cassert is wrapped by a C linkage +// specification. + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +} +#endif From 7b771702b997016bcff40532b628aa87af8c6903 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 1 Oct 2024 12:13:40 -0700 Subject: [PATCH 3/8] Add tests for assert headers linkage specifications --- sycl/test/basic_tests/assert_header_with_c_linkage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/test/basic_tests/assert_header_with_c_linkage.cpp b/sycl/test/basic_tests/assert_header_with_c_linkage.cpp index 169c4adc26975..2df19a6615942 100644 --- a/sycl/test/basic_tests/assert_header_with_c_linkage.cpp +++ b/sycl/test/basic_tests/assert_header_with_c_linkage.cpp @@ -1,7 +1,7 @@ // RUN: %clangxx -fsycl -c %s -// Verify that compilation works when assert.h is wrapped by a C linkage -// specification. +// Verify that compilation works when assert.h is wrapped by a C linkage +// specification. #ifdef __cplusplus extern "C" { From 73ce7a882469617f3bb730c7aefe96a4b5790110 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 1 Oct 2024 12:23:06 -0700 Subject: [PATCH 4/8] Merge the two tests into one --- .../basic_tests/assert_header_with_c_linkage.cpp | 9 +++++++-- .../basic_tests/cassert_header_with_c_linkage.cpp | 14 -------------- 2 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 sycl/test/basic_tests/cassert_header_with_c_linkage.cpp diff --git a/sycl/test/basic_tests/assert_header_with_c_linkage.cpp b/sycl/test/basic_tests/assert_header_with_c_linkage.cpp index 2df19a6615942..9ca0350b3330e 100644 --- a/sycl/test/basic_tests/assert_header_with_c_linkage.cpp +++ b/sycl/test/basic_tests/assert_header_with_c_linkage.cpp @@ -1,13 +1,18 @@ -// RUN: %clangxx -fsycl -c %s +// RUN: %clangxx -fsycl -DASSERT -c %s +// RUN: %clangxx -fsycl -DCASSERT -c %s -// Verify that compilation works when assert.h is wrapped by a C linkage +// Verify that compilation works when assert.h/cassert is wrapped by a C linkage // specification. #ifdef __cplusplus extern "C" { #endif +#if defined(ASSERT) #include +#elif defined(CASSERT) +#include +#endif #ifdef __cplusplus } diff --git a/sycl/test/basic_tests/cassert_header_with_c_linkage.cpp b/sycl/test/basic_tests/cassert_header_with_c_linkage.cpp deleted file mode 100644 index b31b16a553a38..0000000000000 --- a/sycl/test/basic_tests/cassert_header_with_c_linkage.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clangxx -fsycl -c %s - -// Verify that compilation works when cassert is wrapped by a C linkage -// specification. - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef __cplusplus -} -#endif From a9c030c1af6ff813b3bbf8bbd15792142cf5f7fd Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Wed, 2 Oct 2024 08:41:27 -0400 Subject: [PATCH 5/8] Update assert.h --- sycl/include/sycl/stl_wrappers/assert.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/stl_wrappers/assert.h b/sycl/include/sycl/stl_wrappers/assert.h index bf59456943940..4c92488976901 100644 --- a/sycl/include/sycl/stl_wrappers/assert.h +++ b/sycl/include/sycl/stl_wrappers/assert.h @@ -10,13 +10,13 @@ // according to the current state of NDEBUG each time that is // included. -extern "C++" { #if defined(__has_include_next) #include_next #else #include <../ucrt/assert.h> #endif +extern "C++" { #ifdef __SYCL_DEVICE_ONLY__ #include From ae60749ba20640ff48a22e991a204bec8b50bc1c Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Wed, 2 Oct 2024 08:42:17 -0400 Subject: [PATCH 6/8] Update cassert --- sycl/include/sycl/stl_wrappers/cassert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/stl_wrappers/cassert b/sycl/include/sycl/stl_wrappers/cassert index a35c969c9e0c8..64eb839582652 100644 --- a/sycl/include/sycl/stl_wrappers/cassert +++ b/sycl/include/sycl/stl_wrappers/cassert @@ -10,13 +10,13 @@ // according to the current state of NDEBUG each time that is // included. -extern "C++" { #if defined(__has_include_next) #include_next #else #include <../include/cassert> #endif +extern "C++" { #ifdef __SYCL_DEVICE_ONLY__ #include From ad2bacca6a9f3988b39a7f4f6188cccdbaaff621 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Wed, 2 Oct 2024 08:42:41 -0400 Subject: [PATCH 7/8] Update assert_header_with_c_linkage.cpp --- sycl/test/basic_tests/assert_header_with_c_linkage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/test/basic_tests/assert_header_with_c_linkage.cpp b/sycl/test/basic_tests/assert_header_with_c_linkage.cpp index 9ca0350b3330e..c5a81d9730134 100644 --- a/sycl/test/basic_tests/assert_header_with_c_linkage.cpp +++ b/sycl/test/basic_tests/assert_header_with_c_linkage.cpp @@ -1,5 +1,5 @@ -// RUN: %clangxx -fsycl -DASSERT -c %s -// RUN: %clangxx -fsycl -DCASSERT -c %s +// RUN: %clangxx -fsycl -DASSERT -fsyntax-only %s +// RUN: %clangxx -fsycl -DCASSERT -fsyntax-only %s // Verify that compilation works when assert.h/cassert is wrapped by a C linkage // specification. From 486806542b461017221feadbd9ed310b6adffcfa Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Wed, 2 Oct 2024 08:43:24 -0400 Subject: [PATCH 8/8] Update assert.h --- sycl/include/sycl/stl_wrappers/assert.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/stl_wrappers/assert.h b/sycl/include/sycl/stl_wrappers/assert.h index 4c92488976901..8156eaa5edb3d 100644 --- a/sycl/include/sycl/stl_wrappers/assert.h +++ b/sycl/include/sycl/stl_wrappers/assert.h @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// // Must not be guarded. C++ standard says the macro assert is redefined -// according to the current state of NDEBUG each time that is +// according to the current state of NDEBUG each time that is // included. #if defined(__has_include_next)