You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SYCL] Add linker script to limit exported symbols (#955)
Template function instantiations from libstdc++ headers are exported
from libsycl.so as weak symbols by default, and they become a part of
libsycl.so ABI. This includes libstdc++ internal functions
(e.g. classes defined in std::__detail namespace), which, unlike
standard C++ classes (like std::vector), are not forward-compatible.
Host program is also compiled with libstdc++ headers, so it may also
contain the same weak symbols.
When libsycl.so is loaded by a host program, loader resolves its
symbols for internal libstdc++ functions to the corresponding symbols
in the host program. They may be incompatible, (e.g. when the host
program is compiled with different version of libstdc++), so
libsycl.so is going to crash or execute incorrectly.
Linker script limits symbols that we actually export from the
library. Template function instantiations become local, so loader will
no longer attempt to resolve them.
This patch does not use extern "C++" matcher for C++ functions,
because vtable and typeinfo symbols make extern "C++" patterns more
complicated than patterns against mangled names.
With extern "C++" we have to match for "vtable for cl::sycl::foo", but
not match for "vtable for std::__internal<cl::sycl::foo>".
Also cleanup functions that were never meant to be exported.
Signed-off-by: Andrew Savonichev <[email protected]>
0 commit comments