From fadceb83e99bdd6b6c4c9293e302f0397e6243d5 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Fri, 13 Dec 2024 11:51:21 -0500 Subject: [PATCH] common: Use C ABI for exported lexer functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Observed issue ============== When examining the ABI changes between liblttng-ctl.so in lttng-tools 2.13 and liblttng-ctl.so in lttng-tools 2.14, a large number of functions were flagged as removed and added. To produce the diff: ``` abidw stable-2.13/src/lib/lttng-ctl/.libs/liblttng-ctl.so.0.0.0 \ > liblttng-ctl-stable-2.13.xml abidw master/src/lib/lttng-ctl/.libs/liblttng-ctl.so.0.0.0 > liblttng-ctl-master.xml abidiff \ liblttng-ctl-stable-2.13.xml \ liblttng-ctl-master.xml ``` Example of the removed and added functions (cut before brevity): ``` 31 Removed functions: ... [D] 'function void lttng_yyset_in(FILE*, yyscan_t)' {lttng_yyset_in} [D] 'function void lttng_yyset_lineno(int, yyscan_t)' {lttng_yyset_lineno} [D] 'function void lttng_yyset_lval(yyscan_t)' {lttng_yyset_lval} [D] 'function void lttng_yyset_out(FILE*, yyscan_t)' {lttng_yyset_out} 42 Added functions: ... [A] 'function void lttng_yyset_in(FILE*, yyscan_t)' {_Z14lttng_yyset_inP8_IO_FILEPv} [A] 'function void lttng_yyset_lineno(int, yyscan_t)' {_Z18lttng_yyset_linenoiPv} [A] 'function void lttng_yyset_lval(yyscan_t)' {_Z16lttng_yyset_lvalP7YYSTYPEPv} [A] 'function void lttng_yyset_out(FILE*, yyscan_t)' {_Z15lttng_yyset_outP8_IO_FILEPv} [A] 'method void std::__cxx11::basic_string, std::allocator >::_M_construct(const char*, const char*, std::forward_iterator_tag)' {_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_ M_constructIPKcEEvT_S8_St20forward_iterator_tag} [A] 'method void std::__cxx11::basic_string, std::allocator >::_M_construct( char*, char*, std::forward_iterator_tag)' {_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT _S7_St20forward_iterator_tag} [A] 'method void std::vector >::_M_realloc_append()' {_ZNSt6vectorIiSaIiEE17_M _realloc_appendIJRKiEEEvDpOT_} [A] 'method void std::vector >::reserve(std::__new_allocator::size_type)' {_ZNSt6vect orIiSaIiEE7reserveEm} ``` Cause ===== The lexer is now compiled with C++; however, the exported functions that are explicitly marked for exportation (and end up globally visible in liblttng-ctl), are not marked to use the C ABI. Solution ======== Mark the exports with `extern "C" {...}` when compiling C++. Known drawbacks =============== None Change-Id: I33caf05bc09315d4286682e222ee8648857e510b Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- src/common/filter/filter-lexer.lpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/filter/filter-lexer.lpp b/src/common/filter/filter-lexer.lpp index 12164af01..381abf66c 100644 --- a/src/common/filter/filter-lexer.lpp +++ b/src/common/filter/filter-lexer.lpp @@ -124,6 +124,10 @@ L\" BEGIN(string_lit); return STRING_LITERAL_START; . return ERROR; %% +#ifdef __cplusplus +extern "C" { +#endif + /* * The lexer symbols were (e.g. lttng_yy_create_buffer) were mistakenly * exported in the past, so must stay exported. Since it is difficult to tweak @@ -335,3 +339,7 @@ void lttng_yyset_out(FILE *_out_str, yyscan_t yyscanner) { return yyset_out(_out_str, yyscanner); } + +#ifdef __cplusplus +} +#endif -- 2.39.5