Hi,
Sergei Golubchik wrote:
> 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.
Stretching your point a bit :)
> 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.
OK, but as you may remember, the point of runtime detection is to work
around the fact that we don't link to stdc++, if things weren't so messy
I would go for a compile time check only, but we have several problems:
1. sql/stacktrace.c is a C file
2. cxxabi.h is only on the search path of a C++ compiler
3. autoconf C++ snippets are linked to stdc++
4. link of mysqld will fail
5. mysqld linked with gnu stdc++ fails with others STL's
Working around this details only make things more complicated to a point
where the simpler runtime detection is preferable. I'm not saying we
should detect at runtime all functions, this is a very special case.
I know we can work around the above, but I don't want to complicate
things even more. With the autoconf check and the runtime one we allow
the user to move the binary around different machines/libraries or to
disable the runtime check by tweaking HAVE_ABI_CXA_DEMANGLE.
But if you see any technical problem in having the above...
>>> 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.
OK, next year when I return from my vacation I will give some thought on
this.
> 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
If the compiler optimizes this away it will break a hell lot of code.
Regards,
--
Davi Arnaut, Software Engineer
MySQL Inc, www.mysql.com
Are you MySQL certified? www.mysql.com/certification