Enable toc optimization for host builds
The toc optimization had been disabled for host builds to ensure that
the timestamp of the final binary changed whenever its implementation
changed, in order to support rerunning host tools that were modified
during incremental builds. However, only the final install rule must be
re-run to update the timestamp, and not the link rule.
Update the shared library install dependencies to use normal
dependencies instead of order-only dependencies for host modules, and
then enable the the toc optimization for host modules. If the
implementation of a library changes it will be reinstalled, and
libraries or binaries that depend on it will also be reinstalled.
Bug: 26015464
Test: m -j; touch art/disassembler/disassembler_x86.cc; m -j, verify
out/host/linux-x86/bin/oatdump is updated
Change-Id: I0a14decc1994eb55ad269d841943aef66e320c63
diff --git a/core/main.mk b/core/main.mk
index fee2995..de77927 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -660,6 +660,14 @@
$(1): | $(2)
endef
+# Use a normal dependency instead of an order-only dependency when installing
+# host dynamic binaries so that the timestamp of the final binary always
+# changes, even if the toc optimization has skipped relinking the binary
+# and its dependant shared libraries.
+define add-required-host-so-deps
+$(1): $(2)
+endef
+
$(foreach m,$(ALL_MODULES), \
$(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
$(if $(r), \
@@ -702,7 +710,9 @@
$(if $(3),$(eval deps := $(addprefix host_cross_,$(deps))))\
$(eval r := $(filter $($(root))/%,$(call module-installed-files,\
$(deps))))\
- $(eval $(call add-required-deps,$(word 2,$(p)),$(r)))\
+ $(if $(filter $(1),HOST_),\
+ $(eval $(call add-required-host-so-deps,$(word 2,$(p)),$(r))),\
+ $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))\
$(eval ALL_MODULES.$(mod).REQUIRED += $(deps)))
endef