Skip to content

Commit 0385de4

Browse files
[SYCL] Ignore some symbols during ABI check (#6993)
MSVC and clang-cl have minor differences in how the exported symbols are created under some circumstances. We hit some of them in SYCL RT but we believe they don't affect customers and so could be excluded from the ABI check so that it would pass when the library is compiled with either toolchain. Co-authored-by: Steffen Larsen <steffen.larsen@intel.com>
1 parent 9717cc5 commit 0385de4

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,7 @@
411411
??0gpu_selector@_V1@sycl@@QEAA@$$QEAV012@@Z
412412
??0gpu_selector@_V1@sycl@@QEAA@AEBV012@@Z
413413
??0gpu_selector@_V1@sycl@@QEAA@XZ
414-
??0half@host_half_impl@detail@_V1@sycl@@QEAA@$$QEAV01234@@Z
415414
??0half@host_half_impl@detail@_V1@sycl@@QEAA@AEBM@Z
416-
??0half@host_half_impl@detail@_V1@sycl@@QEAA@AEBV01234@@Z
417415
??0half@host_half_impl@detail@_V1@sycl@@QEAA@G@Z
418416
??0handler@_V1@sycl@@AEAA@V?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@00_N@Z
419417
??0handler@_V1@sycl@@AEAA@V?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@_N@Z

sycl/tools/abi_check.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,52 @@ def check_symbols(ref_path, target_path):
102102
readobj_out = subprocess.check_output([get_llvm_bin_path()+"llvm-readobj",
103103
readobj_opts, target_path])
104104
symbols = parse_readobj_output(readobj_out)
105+
105106
# Presence of _dl_relocate_static_pie depends on whether ld.gold or ld.lld
106107
# is used. Ignore it for the purpose of the library ABI check.
107108
ignore_symbols = ["_dl_relocate_static_pie"]
109+
110+
# In some scenarios MSVC and clang-cl exhibit differences in regards to the exported symbols they generate.
111+
# Some of them happen in the SYCL RT library and we think clang-cl's behavior is more reasonable.
112+
#
113+
# Case 1:
114+
# pi.hpp:
115+
# template <backend BE> __SYCL_EXPORT const plugin &getPlugin();
116+
#
117+
# pi.cpp:
118+
# template <backend BE> const plugin &getPlugin() {
119+
# static const plugin *Plugin = nullptr;
120+
# ...
121+
# }
122+
# // explicit dllexport instantiations.
123+
#
124+
# clang-cl generates exported symbols for the static variables Plugin. These are never referenced
125+
# in the user's headers so cannot be used outside DLL and not exporting them should not affect any
126+
# usage scenario.
127+
#
128+
# In general, the compiler doesn't know if the definition is in the DLL or in the header and inline
129+
# dllexport/dllimport functions have to be supported, hence clang-cl's behavior.
130+
#
131+
# See also https://devblogs.microsoft.com/oldnewthing/20140109-00/?p=2123.
132+
ignore_symbols += ["?Plugin@?1???$getPlugin@$01@pi@detail@_V1@sycl@@YAAEBVplugin@234@XZ@4PEBV5234@EB",
133+
"?Plugin@?1???$getPlugin@$00@pi@detail@_V1@sycl@@YAAEBVplugin@234@XZ@4PEBV5234@EB",
134+
"?Plugin@?1???$getPlugin@$04@pi@detail@_V1@sycl@@YAAEBVplugin@234@XZ@4PEBV5234@EB",
135+
"?Plugin@?1???$getPlugin@$02@pi@detail@_V1@sycl@@YAAEBVplugin@234@XZ@4PEBV5234@EB"]
136+
# Case 2:
137+
# half_type.hpp:
138+
# class __SYCL_EXPORT half {
139+
# ...
140+
# constexpr half(const half &) = default;
141+
# constexpr half(half &&) = default;
142+
# ...
143+
# };
144+
#
145+
# For some reason MSVC creates exported symbols for the constexpr versions of those defaulted ctors
146+
# although it never calls them at use point. Instead, those trivially copyable/moveable objects are
147+
# memcpy/memmove'ed. We don't expect these symbols are ever referenced directly so having or not
148+
# having them won't cause ABI issues.
149+
ignore_symbols += ["??0half@host_half_impl@detail@_V1@sycl@@QEAA@AEBV01234@@Z",
150+
"??0half@host_half_impl@detail@_V1@sycl@@QEAA@$$QEAV01234@@Z"]
108151
symbols = [s for s in symbols if s not in ignore_symbols]
109152

110153
missing_symbols, new_symbols = compare_results(ref_symbols, symbols)

0 commit comments

Comments
 (0)