Skip to content

Commit

Permalink
Fix dynamic_cast across dlopen boundaries.
Browse files Browse the repository at this point in the history
Enabling _LIBCXX_DYNAMIC_FALLBACK allows type_info objects to be equal
if their strings are equal, not just their addresses. This is very
common on Android where libraries are loaded with dlopen via
System.loadLibrary.

This behavior matches libsupc++, which always does a string compare to
preserve compatibility for plugin architectures that behave similarly.

Gory details are in the bug.

Test: ndk/run_tests.py --filter dynamic_cast_dlopen
Bug: android/ndk#533
Change-Id: I26cbf8d260cb7fb924580db6b346b42f39d5c2ed
  • Loading branch information
DanAlbert committed Oct 5, 2017
1 parent f9dea50 commit dc179ca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ libcxxabi_includes := \
libcxxabi_cflags := -D__STDC_FORMAT_MACROS
libcxxabi_cppflags := -std=c++11 -Wno-unknown-attributes

# Enabling _LIBCXX_DYNAMIC_FALLBACK allows type_info objects to be equal if
# their strings are equal, not just their addresses. This is very common on
# Android where libraries are loaded as RTLD_LOCAL via System.loadLibrary.
#
# This behavior matches libsupc++, which always does a string compare to
# preserve compatibility for plugin architectures that behave similarly.
#
# https://github.com/android-ndk/ndk/issues/533
libcxxabi_cppflags += -D_LIBCXX_DYNAMIC_FALLBACK

ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
use_llvm_unwinder := true
libcxxabi_cppflags += -DLIBCXXABI_USE_LLVM_UNWINDER=1
Expand Down

0 comments on commit dc179ca

Please sign in to comment.