Skip to content

Commit

Permalink
Hide libgcc in all binaries.
Browse files Browse the repository at this point in the history
It seems we can't guarantee the link order of our libraries (objects,
then static libraries, then shared libraries) in cmake, which
prevents us from ensuring that libunwind is used with libc++ in the
event that some other library is exporting an unwinder.

The best we can do without patching cmake (and until the new unwinder
is available) is hide libgcc in any new libraries we build. This
can't protect us from libraries built without this patch (or with
build systems we don't control), but it will at least protect us from
ourselves.

Patch this in both ndk-build and cmake. ndk-build doesn't have the
same problems that cmake does, but libraries built by ndk-build can
cause problems for cmake. Standalone toolchains are also affected by
this. I'll fix them in a follow up patch.

Test: Built the test cast attached to the bug, libgcc is hidden.
Bug: android/ndk#379
Change-Id: I3406c7e49f7194231bfe1e5f921a3e51d875dc84
  • Loading branch information
DanAlbert committed May 4, 2017
1 parent dd762af commit fa471fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/cmake/android.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ elseif(ANDROID_STL MATCHES "^c\\+\\+_")
set(ANDROID_STL_PREFIX llvm-libc++)
if(ANDROID_ABI MATCHES "^armeabi")
list(APPEND ANDROID_LINKER_FLAGS
-Wl,--exclude-libs,libunwind.a)
-Wl,--exclude-libs,libunwind.a -Wl,--exclude-libs,libgcc.a)
endif()
list(APPEND ANDROID_COMPILER_FLAGS_CXX
-std=c++11)
Expand Down
2 changes: 1 addition & 1 deletion build/core/default-build-commands.mk
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ cmd-strip = $(PRIVATE_STRIP) --strip-unneeded $(call host-path,$1)
# The command objcopy --add-gnu-debuglink= will be needed for Valgrind
cmd-add-gnu-debuglink = $(PRIVATE_OBJCOPY) --add-gnu-debuglink=$(strip $(call host-path,$2)) $(call host-path,$1)

TARGET_LIBGCC = -lgcc
TARGET_LIBGCC = -lgcc -Wl,--exclude-libs,libgcc.a
TARGET_LDLIBS := -lc -lm

#
Expand Down

0 comments on commit fa471fb

Please sign in to comment.