2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Standard rules for building any target-side binaries
|
|
|
|
## with dynamic linkage (dynamic libraries or executables
|
|
|
|
## that link with dynamic libraries)
|
|
|
|
##
|
|
|
|
## Files including this file must define a rule to build
|
|
|
|
## the target $(linked_module).
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# This constraint means that we can hard-code any $(TARGET_*) variables.
|
|
|
|
ifdef LOCAL_IS_HOST_MODULE
|
|
|
|
$(error This file should not be used to build host binaries. Included by (or near) $(lastword $(filter-out config/%,$(MAKEFILE_LIST))))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# The name of the target file, without any path prepended.
|
2014-03-21 20:27:37 +01:00
|
|
|
# This duplicates logic from base_rules.mk because we need to
|
|
|
|
# know its results before base_rules.mk is included.
|
|
|
|
include $(BUILD_SYSTEM)/configure_module_stem.mk
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2014-12-18 23:53:52 +01:00
|
|
|
intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
# Define the target that is the unmodified output of the linker.
|
|
|
|
# The basename of this target must be the same as the final output
|
|
|
|
# binary name, because it's used to set the "soname" in the binary.
|
|
|
|
# The includer of this file will define a rule to build this target.
|
2017-05-19 23:20:02 +02:00
|
|
|
linked_module := $(intermediates)/LINKED/$(notdir $(my_installed_module_stem))
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
|
|
|
|
|
|
|
|
# Because TARGET_SYMBOL_FILTER_FILE depends on ALL_ORIGINAL_DYNAMIC_BINARIES,
|
|
|
|
# the linked_module rules won't necessarily inherit the PRIVATE_
|
|
|
|
# variables from LOCAL_BUILT_MODULE. This tells binary.make to explicitly
|
|
|
|
# define the PRIVATE_ variables for linked_module as well as for
|
|
|
|
# LOCAL_BUILT_MODULE.
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
|
|
|
|
|
|
|
|
###################################
|
2018-05-25 00:13:19 +02:00
|
|
|
include $(BUILD_SYSTEM)/use_lld_setup.mk
|
2009-03-04 04:28:42 +01:00
|
|
|
include $(BUILD_SYSTEM)/binary.mk
|
|
|
|
###################################
|
|
|
|
|
2019-09-05 23:27:02 +02:00
|
|
|
ifdef LOCAL_INJECT_BSSL_HASH
|
|
|
|
inject_module := $(intermediates)/INJECT_BSSL_HASH/$(notdir $(my_installed_module_stem))
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(inject_module)
|
|
|
|
$(inject_module): $(SOONG_HOST_OUT)/bin/bssl_inject_hash
|
|
|
|
$(inject_module): $(linked_module)
|
|
|
|
@echo "target inject BSSL hash: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(SOONG_HOST_OUT)/bin/bssl_inject_hash -in-object $< -o $@
|
|
|
|
else
|
|
|
|
inject_module := $(linked_module)
|
|
|
|
endif
|
|
|
|
|
2011-03-14 19:44:57 +01:00
|
|
|
###########################################################
|
|
|
|
## Store a copy with symbols for symbolic debugging
|
|
|
|
###########################################################
|
2013-11-14 02:56:20 +01:00
|
|
|
ifeq ($(LOCAL_UNSTRIPPED_PATH),)
|
2014-01-24 00:09:04 +01:00
|
|
|
my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
|
|
|
|
else
|
|
|
|
my_unstripped_path := $(LOCAL_UNSTRIPPED_PATH)
|
2013-11-14 02:56:20 +01:00
|
|
|
endif
|
2019-09-05 23:27:02 +02:00
|
|
|
symbolic_input := $(inject_module)
|
2014-05-20 23:43:51 +02:00
|
|
|
symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
|
2016-03-01 02:52:39 +01:00
|
|
|
$(symbolic_output) : $(symbolic_input)
|
2011-03-14 19:44:57 +01:00
|
|
|
@echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
|
|
|
|
2015-09-24 10:40:52 +02:00
|
|
|
###########################################################
|
|
|
|
## Store breakpad symbols
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
|
2015-09-25 03:12:33 +02:00
|
|
|
my_breakpad_path := $(TARGET_OUT_BREAKPAD)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
|
2019-09-05 23:27:02 +02:00
|
|
|
breakpad_input := $(inject_module)
|
2015-09-24 10:40:52 +02:00
|
|
|
breakpad_output := $(my_breakpad_path)/$(my_installed_module_stem).sym
|
2017-08-30 23:58:33 +02:00
|
|
|
$(breakpad_output) : $(breakpad_input) | $(BREAKPAD_DUMP_SYMS) $(PRIVATE_READELF)
|
2015-09-24 10:40:52 +02:00
|
|
|
@echo "target breakpad: $(PRIVATE_MODULE) ($@)"
|
|
|
|
@mkdir -p $(dir $@)
|
2017-08-30 23:58:33 +02:00
|
|
|
$(hide) if $(PRIVATE_READELF) -S $< > /dev/null 2>&1 ; then \
|
|
|
|
$(BREAKPAD_DUMP_SYMS) -c $< > $@ ; \
|
|
|
|
else \
|
|
|
|
echo "skipped for non-elf file."; \
|
|
|
|
touch $@; \
|
|
|
|
fi
|
2015-09-24 10:40:52 +02:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(breakpad_output)
|
|
|
|
endif
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Strip
|
|
|
|
###########################################################
|
2021-04-28 04:43:33 +02:00
|
|
|
strip_input := $(inject_module)
|
2015-05-02 03:12:29 +02:00
|
|
|
strip_output := $(LOCAL_BUILT_MODULE)
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2021-04-28 04:43:33 +02:00
|
|
|
# Use an order-only dependency to ensure the unstripped file in the symbols
|
|
|
|
# directory is copied when the module is built, but does not force the
|
|
|
|
# module to be rebuilt when the symbols directory is cleaned by installclean.
|
|
|
|
$(strip_output): | $(symbolic_output)
|
|
|
|
|
2016-03-02 05:14:52 +01:00
|
|
|
my_strip_module := $(firstword \
|
|
|
|
$(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
|
|
|
|
$(LOCAL_STRIP_MODULE))
|
2014-03-16 20:43:49 +01:00
|
|
|
ifeq ($(my_strip_module),)
|
2016-04-27 01:08:00 +02:00
|
|
|
my_strip_module := mini-debug-info
|
|
|
|
endif
|
|
|
|
|
2018-09-08 08:15:46 +02:00
|
|
|
ifeq ($(my_strip_module),false)
|
|
|
|
my_strip_module :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
my_strip_args :=
|
2016-04-27 01:08:00 +02:00
|
|
|
ifeq ($(my_strip_module),mini-debug-info)
|
2018-09-08 08:15:46 +02:00
|
|
|
my_strip_args += --keep-mini-debug-info
|
|
|
|
else ifeq ($(my_strip_module),keep_symbols)
|
|
|
|
my_strip_args += --keep-symbols
|
2009-03-04 04:28:42 +01:00
|
|
|
endif
|
2018-09-08 08:15:46 +02:00
|
|
|
|
|
|
|
ifeq (,$(filter no_debuglink mini-debug-info,$(my_strip_module)))
|
|
|
|
ifneq ($(TARGET_BUILD_VARIANT),user)
|
|
|
|
my_strip_args += --add-gnu-debuglink
|
|
|
|
endif
|
2016-04-27 01:08:00 +02:00
|
|
|
endif
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2018-11-08 01:33:11 +01:00
|
|
|
ifeq ($($(my_prefix)OS),darwin)
|
|
|
|
# llvm-strip does not support Darwin Mach-O yet.
|
|
|
|
my_strip_args += --use-gnu-strip
|
2014-08-21 02:12:32 +02:00
|
|
|
endif
|
|
|
|
|
2018-09-08 08:15:46 +02:00
|
|
|
valid_strip := mini-debug-info keep_symbols true no_debuglink
|
|
|
|
ifneq (,$(filter-out $(valid_strip),$(my_strip_module)))
|
|
|
|
$(call pretty-error,Invalid strip value $(my_strip_module), only one of $(valid_strip) allowed)
|
2014-08-11 01:19:04 +02:00
|
|
|
endif
|
2018-09-08 08:15:46 +02:00
|
|
|
|
|
|
|
ifneq (,$(my_strip_module))
|
|
|
|
$(strip_output): PRIVATE_STRIP_ARGS := $(my_strip_args)
|
|
|
|
$(strip_output): PRIVATE_TOOLS_PREFIX := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)TOOLS_PREFIX)
|
|
|
|
$(strip_output): $(strip_input) $(SOONG_STRIP_PATH)
|
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Strip: $(PRIVATE_MODULE) ($@)"
|
|
|
|
CLANG_BIN=$(LLVM_PREBUILTS_PATH) \
|
|
|
|
CROSS_COMPILE=$(PRIVATE_TOOLS_PREFIX) \
|
|
|
|
XZ=$(XZ) \
|
2020-01-27 22:52:28 +01:00
|
|
|
$(SOONG_STRIP_PATH) -i $< -o $@ -d $@.strip.d $(PRIVATE_STRIP_ARGS)
|
|
|
|
$(call include-depfile,$(strip_output).strip.d,$(strip_output))
|
2014-03-18 22:50:09 +01:00
|
|
|
else
|
2018-09-08 08:15:46 +02:00
|
|
|
# Don't strip the binary, just copy it. We can't skip this step
|
|
|
|
# because a copy of the binary must appear at LOCAL_BUILT_MODULE.
|
|
|
|
$(strip_output): $(strip_input)
|
2009-03-04 04:28:42 +01:00
|
|
|
@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
2014-03-16 20:43:49 +01:00
|
|
|
endif # my_strip_module
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2013-01-28 19:58:01 +01:00
|
|
|
$(cleantarget): PRIVATE_CLEAN_FILES += \
|
|
|
|
$(linked_module) \
|
2019-09-05 23:27:02 +02:00
|
|
|
$(inject_module) \
|
2015-09-24 10:40:52 +02:00
|
|
|
$(breakpad_output) \
|
2015-04-21 01:59:05 +02:00
|
|
|
$(symbolic_output) \
|
|
|
|
$(strip_output)
|