Hi!
On Dec 27, Davi Arnaut wrote:
> Sergei Golubchik wrote:
> > On Dec 27, Davi Arnaut wrote:
> >> Sergei Golubchik wrote:
> >>
> > I mean either one of the three:
> >
> > 1. *only* __cxa_demangle check in configure, that is only
> > AC_CHECK_FUNC(__cxa_demangle). No weak symbols, no nothing. Only
> >
> > #ifdef HAVE_CXA_DEMANGLE
> > return __cxa_demangle(mangled_name, NULL, NULL, status);
> > #endif
>
> The configure check for __cxa_demangle is for a *configure* time check
> to hopefully ensure that in the future (runtime) we will use the
> intended API/ABI (__cxa_demangle might be implemented with a different
> "signature" in some other libraries).
Exactly. That why I wrote
"
Or - if you really believe that it's widespread to have libraries with
and without __cxa_demangle on systems where the same mysqld binary can
be run (and thus runtime detection is necessary)
"
I personally don't think it's the case. We don't do runtime detection of
other functions, everything is checked at compile time and if configure
has found fconvert() for example, the binary will expect it to exist, no
runtime detection for fconvert() there.
So, I believe the same rule could be applied to __cxa_demangle. And on
every system where the same mysqld binary can be run we can expect
__cxa_demangle to be present (or absent), and there is no need to
support the set of systems that differ *only* in __cxa_demangle
existence and are completely identical otherwise.
But if you are sure it's an important use case - ok, go on with runtime
detection.
> > 2. Only __weak__ check, and in the code you do
> >
> > char *__cxa_demangle(const char *mangled_name, char *output_buffer,
> > unsigned int *length, int *status)
> __attribute__((__weak__))
> > {
> > return mangled_name;
> > }
> >
> > and then use __cxa_demangle without any checks.
>
> This won't work the way you think.
Yes, not exactly. But moving __cxa_demangle to a separate library (or to
libmysys, for example) it'll work exactly as I wrote above.
Runtime detection the way you've implemented it is discouraged, see
http://docsun.cites.uiuc.edu/sun_docs/C/solaris_9/SUNWdev/LLM/p7.html
(by the way, using dlsym() as described in the url above is an option too,
but it'll need extra magic around to work in static builds)
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Developer
/_/ /_/\_, /___/\___\_\___/ MySQL GmbH, Dachauer Str. 37, D-80335 München
<___/ Geschäftsführer: Kaj Arnö - HRB
München 162140