bindings: cxx: drop the re-export guard of visible symbols
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 14 Feb 2023 10:10:56 +0000 (11:10 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 14 Feb 2023 14:56:13 +0000 (15:56 +0100)
commitd8d3a84b2ddfc29670430fc73ff8483a44b8f61e
tree8d743f1a5675d2c9036ff6e4f66b17c1feebfc0d
parent739eaee1280be84f10ef69e9e775de994069e38b
bindings: cxx: drop the re-export guard of visible symbols

The ifdef guard that changes the definition of GPIOD_CXX_API between
"default" and "hidden" is there to prevent libraries that would include
gpiod.hpp from re-exporting libgpiodcxx symbols.

Unfortunately the hidden linkage only works for translation units within
the same ELF object. At static linking time we must always mark the
throwable types as visible or we'll get the following errors:

/usr/bin/ld: tests-chip.o:(.data+0x0): undefined reference to `typeinfo for gpiod::chip_closed'
/usr/bin/ld: tests-line-request.o:(.data+0x0): undefined reference to `typeinfo for gpiod::request_released'
/usr/bin/ld: .libs/gpiod-cxx-test: hidden symbol `_ZTIN5gpiod11chip_closedE' isn't defined
/usr/bin/ld: final link failed: bad value

On top of that we actually WANT to re-export typeinfo for throwable types
as they can be propagated to external callers when an exception is thrown.

The above error can only be triggered on clang. GCC seems to be
incorrectly omitting the "hidden" attribute in this case.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
bindings/cxx/Makefile.am
bindings/cxx/gpiod.hpp