Homec4science

googletest: Add GTEST_API_ attribute to ThreadLocal class.

Authored by Manoj Gupta <manojgupta@google.com> on Oct 17 2017, 20:01.

Description

googletest: Add GTEST_API_ attribute to ThreadLocal class.

ThreadLocal class needs to be have default visibility.
Root cause is gtest uses typeinfo for the ThreadLocal class.
The problem manifests When gtest/gmock are built as a shared library
with libc++. When a class is used in typeinfo, it must have default
visibility.

There is an explanation about typeinfo and visibility here:
https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html

When libc++ is used with gtest in shared library mode, any tests
that are compiled with -fvisibility=hidden and exercise the
macro EXPECT_CALL, it results in an abort like:
[ FATAL ] /usr/include/gtest/internal/gtest-port.h:1394::
Condition typeid(*base) == typeid(Derived) failed.
This is because the typeinfo for ThreadLocal class is not visible.
Therefore, linker failed to match it to the shared library symbol, creating a
new symbol instead.

This fixes https://github.com/google/googletest/issues/1207.

Details

Committed
Manoj Gupta <manojgupta@google.com>Oct 20 2017, 23:41
Pushed
trottetDec 4 2019, 13:52
Parents
R9484:69e48e92de43: Merge pull request #1300 from gennadiycivil/master
Branches
Unknown
Tags
Unknown

Event Timeline

Manoj Gupta <manojgupta@google.com> committed R9484:1beff241c359: googletest: Add GTEST_API_ attribute to ThreadLocal class. (authored by Manoj Gupta <manojgupta@google.com>).Oct 20 2017, 23:41