There are conditions when the HAVE_THREAD_LOCAL macro is undefined what causes the -logthreadnames option does not work -- instead of thread names empty strings [] only are printed in the debug.log file.
This PR does not exposes the -logthreadnames option in such cases.
This is a backport of core#18665