diff --git a/core/definitions.mk b/core/definitions.mk index f4fc47d5e..f59b78e2d 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1435,7 +1435,8 @@ endif define transform-to-stripped @mkdir -p $(dir $@) @echo "target Strip: $(PRIVATE_MODULE) ($@)" -$(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ $(TARGET_STRIP_EXTRA) +$(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ \ + $(if $(PRIVATE_NO_DEBUGLINK),,$(TARGET_STRIP_EXTRA)) endef define transform-to-stripped-keep-symbols diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk index 08fb17600..cf06a3dfb 100644 --- a/core/dynamic_binary.mk +++ b/core/dynamic_binary.mk @@ -88,18 +88,21 @@ ifeq ($(my_strip_module),) my_strip_module := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_MODULE) endif -ifeq ($(my_strip_module),true) -# Strip the binary -$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) -$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) -$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) - $(transform-to-stripped) -else -ifeq ($(my_strip_module),keep_symbols) -# Strip only the debug frames, but leave the symbol table. $(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) $(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) $(strip_output): PRIVATE_READELF := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_READELF) +ifeq ($(my_strip_module),no_debuglink) +$(strip_output): PRIVATE_NO_DEBUGLINK := true +else +$(strip_output): PRIVATE_NO_DEBUGLINK := +endif + +ifneq ($(filter true no_debuglink,$(my_strip_module)),) +# Strip the binary +$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) + $(transform-to-stripped) +else ifeq ($(my_strip_module),keep_symbols) +# Strip only the debug frames, but leave the symbol table. $(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) $(transform-to-stripped-keep-symbols) @@ -126,7 +129,6 @@ $(strip_output): $(strip_input) @echo "target Unstripped: $(PRIVATE_MODULE) ($@)" $(copy-file-to-target-with-cp) endif -endif endif # my_strip_module diff --git a/core/multi_prebuilt.mk b/core/multi_prebuilt.mk index bc85cea4a..ed2fed686 100644 --- a/core/multi_prebuilt.mk +++ b/core/multi_prebuilt.mk @@ -76,8 +76,7 @@ $(foreach t,$(1), \ ) \ ) \ $(eval LOCAL_MODULE_SUFFIX := $(suffix $(LOCAL_SRC_FILES))) \ - $(if $(filter user,$(TARGET_BUILD_VARIANT)), \ - $(eval LOCAL_STRIP_MODULE := $(8))) \ + $(eval LOCAL_STRIP_MODULE := $(8)) \ $(eval include $(BUILD_PREBUILT)) \ ) endef diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index fc0f56cbf..47e21ef0d 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -39,6 +39,10 @@ ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) # Put the built targets of all shared libraries in a common directory # to simplify the link line. OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES) + ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_STRIP_MODULE),) + # Strip but not try to add debuglink + LOCAL_STRIP_MODULE := no_debuglink + endif endif ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) @@ -59,7 +63,7 @@ LOCAL_BUILT_MODULE_STEM := package.apk LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk endif -ifeq ($(LOCAL_STRIP_MODULE),true) +ifneq ($(filter true no_debuglink,$(LOCAL_STRIP_MODULE)),) ifdef LOCAL_IS_HOST_MODULE $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH)) endif @@ -71,6 +75,7 @@ ifeq ($(LOCAL_STRIP_MODULE),true) endif include $(BUILD_SYSTEM)/dynamic_binary.mk built_module := $(linked_module) + else # LOCAL_STRIP_MODULE not true include $(BUILD_SYSTEM)/base_rules.mk built_module := $(LOCAL_BUILT_MODULE) @@ -112,6 +117,8 @@ $(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries) endif endif +# We need to enclose the above export_includes and built_shared_libraries in +# "LOCAL_STRIP_MODULE not true" because otherwise the rules are defined in dynamic_binary.mk. endif # LOCAL_STRIP_MODULE not true ifeq ($(LOCAL_MODULE_CLASS),APPS)