Skip to content

Commit ce26ac0

Browse files
authored
[SYCL][ABI-break] Update sycl::exception to be SYCL2020 compliant (#9210)
SYCL2020 requires `sycl::exception` to virtually inherit from `std::exception`, which is an ABI-breaking change. Additionally, this PR removes two constructors that are not used anymore. --------- Signed-off-by: Maronas, Marcos <[email protected]>
1 parent 3cb2e1e commit ce26ac0

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ set(SYCL_MAJOR_VERSION 7)
3636
set(SYCL_MINOR_VERSION 0)
3737
set(SYCL_PATCH_VERSION 0)
3838

39-
set(SYCL_DEV_ABI_VERSION 0)
39+
set(SYCL_DEV_ABI_VERSION 1)
4040
if (SYCL_ADD_DEV_VERSION_POSTFIX)
4141
set(SYCL_VERSION_POSTFIX "-${SYCL_DEV_ABI_VERSION}")
4242
endif()

sycl/include/sycl/exception.hpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ class __SYCL_EXPORT SYCLCategory : public std::error_category {
6161
// Derive from std::exception so uncaught exceptions are printed in c++ default
6262
// exception handler.
6363
/// \ingroup sycl_api
64-
class __SYCL_EXPORT exception : public std::exception {
64+
class __SYCL_EXPORT exception : public virtual std::exception {
6565
public:
6666
__SYCL2020_DEPRECATED("The version of an exception constructor which takes "
6767
"no arguments is deprecated.")
6868
exception() = default;
69+
virtual ~exception();
6970

7071
exception(std::error_code, const char *Msg);
7172

@@ -105,16 +106,6 @@ class __SYCL_EXPORT exception : public std::exception {
105106
std::error_code MErrC = make_error_code(sycl::errc::invalid);
106107

107108
protected:
108-
// these two constructors are no longer used. Kept for ABI compatability.
109-
exception(const char *Msg, const pi_int32 PIErr,
110-
std::shared_ptr<context> Context = nullptr)
111-
: exception(std::string(Msg), PIErr, Context) {}
112-
exception(const std::string &Msg, const pi_int32 PIErr,
113-
std::shared_ptr<context> Context = nullptr)
114-
: MMsg(std::make_shared<std::string>(Msg + " " +
115-
detail::codeToString(PIErr))),
116-
MPIErr(PIErr), MContext(Context) {}
117-
118109
// base constructors used by SYCL 1.2.1 exception subclasses
119110
exception(std::error_code ec, const char *Msg, const pi_int32 PIErr,
120111
std::shared_ptr<context> Context = nullptr)

sycl/source/exception.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ exception::exception(std::error_code EC, std::shared_ptr<context> SharedPtrCtx,
6565
detail::GlobalHandler::instance().TraceEventXPTI(MMsg->c_str());
6666
}
6767

68+
exception::~exception() {}
69+
6870
const std::error_code &exception::code() const noexcept { return MErrC; }
6971

7072
const std::error_category &exception::category() const noexcept {

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4050,6 +4050,9 @@ _ZN4sycl3_V19exceptionC2ESt10error_codeSt10shared_ptrINS0_7contextEERKNSt7__cxx1
40504050
_ZN4sycl3_V19exceptionC2EiRKNSt3_V214error_categoryE
40514051
_ZN4sycl3_V19exceptionC2EiRKNSt3_V214error_categoryEPKc
40524052
_ZN4sycl3_V19exceptionC2EiRKNSt3_V214error_categoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
4053+
_ZN4sycl3_V19exceptionD0Ev
4054+
_ZN4sycl3_V19exceptionD1Ev
4055+
_ZN4sycl3_V19exceptionD2Ev
40534056
_ZN4sycl3_V19kernel_idC1EPKc
40544057
_ZN4sycl3_V19kernel_idC2EPKc
40554058
_ZNK4sycl3_V112cpu_selectorclERKNS0_6deviceE

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,9 @@
458458
??0event@_V1@sycl@@QEAA@PEAU_cl_event@@AEBVcontext@12@@Z
459459
??0event@_V1@sycl@@QEAA@XZ
460460
??0exception@_V1@sycl@@IEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
461-
??0exception@_V1@sycl@@IEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HV?$shared_ptr@Vcontext@_V1@sycl@@@4@@Z
462-
??0exception@_V1@sycl@@IEAA@PEBDHV?$shared_ptr@Vcontext@_V1@sycl@@@std@@@Z
463461
??0exception@_V1@sycl@@IEAA@Verror_code@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@HV?$shared_ptr@Vcontext@_V1@sycl@@@4@@Z
464462
??0exception@_V1@sycl@@IEAA@Verror_code@std@@PEBDHV?$shared_ptr@Vcontext@_V1@sycl@@@4@@Z
465463
??0exception@_V1@sycl@@IEAA@Verror_code@std@@V?$shared_ptr@Vcontext@_V1@sycl@@@4@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@@Z
466-
??0exception@_V1@sycl@@QEAA@$$QEAV012@@Z
467464
??0exception@_V1@sycl@@QEAA@AEBV012@@Z
468465
??0exception@_V1@sycl@@QEAA@HAEBVerror_category@std@@@Z
469466
??0exception@_V1@sycl@@QEAA@HAEBVerror_category@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@@Z
@@ -661,7 +658,6 @@
661658
??4device_selector@_V1@sycl@@QEAAAEAV012@AEBV012@@Z
662659
??4event@_V1@sycl@@QEAAAEAV012@$$QEAV012@@Z
663660
??4event@_V1@sycl@@QEAAAEAV012@AEBV012@@Z
664-
??4exception@_V1@sycl@@QEAAAEAV012@$$QEAV012@@Z
665661
??4exception@_V1@sycl@@QEAAAEAV012@AEBV012@@Z
666662
??4exception_list@_V1@sycl@@QEAAAEAV012@$$QEAV012@@Z
667663
??4exception_list@_V1@sycl@@QEAAAEAV012@AEBV012@@Z
@@ -747,6 +743,8 @@
747743
??_7gpu_selector@_V1@sycl@@6B@
748744
??_7host_selector@_V1@sycl@@6B@
749745
??_7image_impl@detail@_V1@sycl@@6B@
746+
??_8exception@_V1@sycl@@7B@
747+
??_Dexception@_V1@sycl@@QEAAXXZ
750748
??_Fcontext@_V1@sycl@@QEAAXXZ
751749
??_Fqueue@_V1@sycl@@QEAAXXZ
752750
?Clear@exception_list@_V1@sycl@@AEAAXXZ

0 commit comments

Comments
 (0)