OSDN Git Service

Don't pass -Wl,--no-undefined to host targets
authorColin Cross <ccross@android.com>
Thu, 20 Oct 2016 19:38:21 +0000 (12:38 -0700)
committerColin Cross <ccross@android.com>
Thu, 20 Oct 2016 23:25:18 +0000 (16:25 -0700)
Host builds were compiling without -Wl,--no-undefined because of an ASAN
issue.  Pass -Wl,--no-undefined for host builds unless sanitzers are
enabled.  Also fix LOCAL_ALLOW_UNDEFINED_SYMBOLS on darwin, where
disallowing undefined symbols is the default.

Test: m -j host
Test: m -j SANITIZE_HOST=address host
Bug: 32305815
Change-Id: I0344c321610c55eb8b2092b01e50e4a93a0e85df

core/binary.mk

index 8467876..0f9ef2f 100644 (file)
@@ -64,10 +64,11 @@ else
   my_native_coverage := false
 endif
 
+my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
+ifdef SANITIZE_HOST
 ifdef LOCAL_IS_HOST_MODULE
 my_allow_undefined_symbols := true
-else
-my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
+endif
 endif
 
 my_ndk_sysroot :=
@@ -625,9 +626,18 @@ endif
 # Certain modules like libdl have to have symbols resolved at runtime and blow
 # up if --no-undefined is passed to the linker.
 ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
-ifeq ($(my_allow_undefined_symbols),)
-  my_ldflags += -Wl,--no-undefined
-endif
+  ifeq ($(my_allow_undefined_symbols),)
+    ifneq ($(HOST_OS),darwin)
+      my_ldflags += -Wl,--no-undefined
+    endif
+  else
+    ifdef LOCAL_IS_HOST_MODULE
+      ifeq ($(HOST_OS),darwin)
+        # darwin defaults to treating undefined symbols as errors
+        my_ldflags += -Wl,-undefined,dynamic_lookup
+      endif
+    endif
+  endif
 endif
 
 ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))