Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b47d4e9c authored by Dan Willemsen's avatar Dan Willemsen
Browse files

Rewrite link type checking

All the new features are turned off for now, since multiple branches and
products need to be verified before they can be turned on. So everything
should behave the same as today, except for no partition-based
warnings.

Instead of the current link type checks that happen during the build,
run as many as possible immediately after loading all the Android.mk
files. If we're allowing missing dependencies ('mm',
ALLOW_MISSING_DEPENDENCIES, tapas, etc), we'll defer the link type
checks to during the build. If we're not allowing missing dependencies,
we'll produce a better error message to the user about the missing
dependencies.

See core/main.mk for a description of the storage format.

This also remove the partition-based type checking. It hasn't worked all
that well, particularly with ASAN builds. The new VNDK checks will
handle the most pressing cases.

Test: Verify all link_type files and dependencies are the same:
  grep link_type: out/build-aosp_arm64.ninja | sed -E "s/ rule[0-9]+//" | sort
Change-Id: Id643658b9d9e84f99f5db0d526aad88c1f5d3417
parent 4be1d882
Loading
Loading
Loading
Loading
+17 −28
Original line number Diff line number Diff line
@@ -1396,39 +1396,28 @@ endif
## other NDK-built libraries
####################################################

my_link_type := $(intermediates)/link_type
all_link_types: $(my_link_type)
ifdef LOCAL_SDK_VERSION
$(my_link_type): PRIVATE_LINK_TYPE := native:ndk
$(my_link_type): PRIVATE_WARN_TYPES :=
$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk
my_link_type := native:ndk
my_warn_types :=
my_allowed_types := native:ndk
else ifdef LOCAL_USE_VNDK
$(my_link_type): PRIVATE_LINK_TYPE := native:vendor
$(my_link_type): PRIVATE_WARN_TYPES :=
$(my_link_type): PRIVATE_ALLOWED_TYPES := native:vendor
my_link_type := native:vendor
my_warn_types :=
my_allowed_types := native:vendor
else
$(my_link_type): PRIVATE_LINK_TYPE := native:platform
$(my_link_type): PRIVATE_WARN_TYPES :=
$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk native:platform
endif
$(eval $(call link-type-partitions,$(my_link_type)))
my_link_type_deps := $(strip \
   $(foreach l,$(my_whole_static_libraries) $(my_static_libraries), \
     $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
ifneq ($(LOCAL_MODULE_CLASS),HEADER_LIBRARIES)
my_link_type_deps += $(strip \
   $(foreach l,$(my_shared_libraries), \
     $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
my_link_type := native:platform
my_warn_types :=
my_allowed_types := native:ndk native:platform
endif

my_link_deps := $(addprefix STATIC_LIBRARIES:,$(my_whole_static_libraries) $(my_static_libraries))
ifneq ($(filter-out STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
my_link_deps += $(addprefix SHARED_LIBRARIES:,$(my_shared_libraries))
endif
$(my_link_type): PRIVATE_DEPS := $(my_link_type_deps)
$(my_link_type): PRIVATE_MODULE := $(LOCAL_MODULE)
$(my_link_type): PRIVATE_MAKEFILE := $(LOCAL_MODULE_MAKEFILE)
$(my_link_type): $(my_link_type_deps) $(CHECK_LINK_TYPE)
	@echo Check module type: $@
	$(check-link-type)

my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
my_common :=
include $(BUILD_SYSTEM)/link_type.mk

###########################################################
## Common object handling.
@@ -1815,7 +1804,7 @@ export_cflags :=
.KATI_RESTAT: $(export_includes)

# Make sure export_includes gets generated when you are running mm/mmm
$(LOCAL_BUILT_MODULE) : | $(export_includes) $(my_link_type)
$(LOCAL_BUILT_MODULE) : | $(export_includes)

ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
ifneq (,$(filter-out $(LOCAL_PATH)/%,$(my_export_c_include_dirs)))
+0 −38
Original line number Diff line number Diff line
@@ -3134,44 +3134,6 @@ $(strip $(if $(LOCAL_RECORDED_MODULE_TYPE),,
      $(error Invalid module type: $(1))))))
endef

###########################################################
# Link type checking
###########################################################
define check-link-type
$(hide) mkdir -p $(dir $@) && rm -f $@
$(hide) $(CHECK_LINK_TYPE) --makefile $(PRIVATE_MAKEFILE) --module $(PRIVATE_MODULE) \
  --type "$(PRIVATE_LINK_TYPE)" $(addprefix --allowed ,$(PRIVATE_ALLOWED_TYPES)) \
  $(addprefix --warn ,$(PRIVATE_WARN_TYPES)) $(PRIVATE_DEPS)
$(hide) echo "$(PRIVATE_LINK_TYPE)" >$@
endef

define link-type-partitions
ifndef LOCAL_IS_HOST_MODULE
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
ifneq ($(filter $(TARGET_OUT_VENDOR)/%,$(my_module_path)),)
$(1): PRIVATE_LINK_TYPE += partition:vendor
$(1): PRIVATE_WARN_TYPES += partition:data
$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
else ifneq ($(filter $(TARGET_OUT_OEM)/%,$(my_module_path)),)
$(1): PRIVATE_LINK_TYPE += partition:oem
$(1): PRIVATE_WARN_TYPES += partition:data
$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
else ifneq ($(filter $(TARGET_OUT_ODM)/%,$(my_module_path)),)
$(1): PRIVATE_LINK_TYPE += partition:odm
$(1): PRIVATE_WARN_TYPES += partition:data
$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
else ifneq ($(filter $(TARGET_OUT_DATA)/%,$(my_module_path)),)
$(1): PRIVATE_LINK_TYPE += partition:data
$(1): PRIVATE_ALLOWED_TYPES += partition:data partition:vendor partition:oem partition:odm
else
$(1): PRIVATE_WARN_TYPES += partition:vendor partition:oem partition:odm partition:data
endif
else # uninstallable module
$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm partition:data
endif
endif
endef

###########################################################
# Basic math functions for positive integers <= 100
#
+14 −0
Original line number Diff line number Diff line
@@ -78,6 +78,20 @@ $(foreach v,$(ENABLED_VERSIONS), \
# buildspec.mk.default and envsetup.sh.
CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 13

# ---------------------------------------------------------------
# Whether we can expect a full build graph
ALLOW_MISSING_DEPENDENCIES := $(filter true,$(ALLOW_MISSING_DEPENDENCIES))
ifneq ($(TARGET_BUILD_APPS),)
ALLOW_MISSING_DEPENDENCIES := true
endif
ifneq ($(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),)
ALLOW_MISSING_DEPENDENCIES := true
endif
ifneq ($(ONE_SHOT_MAKEFILE),)
ALLOW_MISSING_DEPENDENCIES := true
endif
.KATI_READONLY := ALLOW_MISSING_DEPENDENCIES

# ---------------------------------------------------------------
# The product defaults to generic on hardware
# NOTE: This will be overridden in product_config.mk if make
+9 −21
Original line number Diff line number Diff line
@@ -108,30 +108,18 @@ endif # outer my_prebuilt_jni_libs

# Verify that all included libraries are built against the NDK
ifneq ($(strip $(LOCAL_JNI_SHARED_LIBRARIES)),)
my_link_type := $(call intermediates-dir-for,APPS,$(LOCAL_MODULE))/$(my_2nd_arch_prefix)jni_link_type
all_link_types: $(my_link_type)
my_link_type_deps := $(strip \
  $(foreach l,$(LOCAL_JNI_SHARED_LIBRARIES),\
    $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),,,$(my_2nd_arch_prefix))/link_type))
ifneq ($(LOCAL_SDK_VERSION),)
$(my_link_type): PRIVATE_LINK_TYPE := app:sdk
$(my_link_type): PRIVATE_WARN_TYPES := native:platform
$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk
my_link_type := app:sdk
my_warn_types := native:platform
my_allowed_types := native:ndk
else
$(my_link_type): PRIVATE_LINK_TYPE := app:platform
$(my_link_type): PRIVATE_WARN_TYPES :=
$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk native:platform
my_link_type := app:platform
my_warn_types :=
my_allowed_types := native:ndk native:platform
endif
$(eval $(call link-type-partitions,$(my_link_type)))
$(my_link_type): PRIVATE_DEPS := $(my_link_type_deps)
$(my_link_type): PRIVATE_MODULE := $(LOCAL_MODULE)
$(my_link_type): PRIVATE_MAKEFILE := $(LOCAL_MODULE_MAKEFILE)
$(my_link_type): $(my_link_type_deps) $(CHECK_LINK_TYPE)
	@echo Check JNI module types: $@
	$(check-link-type)

$(LOCAL_BUILT_MODULE): | $(my_link_type)
my_link_deps := $(addprefix SHARED_LIBRARIES:,$(LOCAL_JNI_SHARED_LIBRARIES))

my_link_type :=
my_link_type_deps :=
my_common :=
include $(BUILD_SYSTEM)/link_type.mk
endif
+16 −27
Original line number Diff line number Diff line
@@ -396,35 +396,24 @@ endif # LOCAL_JACK_ENABLED
# Verify that all libraries are safe to use
###########################################################
ifndef LOCAL_IS_HOST_MODULE
my_link_type := $(intermediates.COMMON)/link_type
all_link_types: $(my_link_type)
my_link_type_deps := $(strip \
  $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES),\
    $(call intermediates-dir-for, \
      JAVA_LIBRARIES,$(lib),,COMMON)/link_type) \
  $(foreach lib,$(apk_libraries), \
    $(call intermediates-dir-for, \
      APPS,$(lib),,COMMON)/link_type))
ifeq ($(LOCAL_SDK_VERSION),system_current)
$(my_link_type): PRIVATE_LINK_TYPE := java:system
$(my_link_type): PRIVATE_WARN_TYPES := java:platform
$(my_link_type): PRIVATE_ALLOWED_TYPES := java:sdk java:system
my_link_type := java:system
my_warn_types := java:platform
my_allowed_types := java:sdk java:system
else ifneq ($(LOCAL_SDK_VERSION),)
$(my_link_type): PRIVATE_LINK_TYPE := java:sdk
$(my_link_type): PRIVATE_WARN_TYPES := java:system java:platform
$(my_link_type): PRIVATE_ALLOWED_TYPES := java:sdk
my_link_type := java:sdk
my_warn_types := java:system java:platform
my_allowed_types := java:sdk
else
$(my_link_type): PRIVATE_LINK_TYPE := java:platform
$(my_link_type): PRIVATE_WARN_TYPES :=
$(my_link_type): PRIVATE_ALLOWED_TYPES := java:sdk java:system java:platform
my_link_type := java:platform
my_warn_types :=
my_allowed_types := java:sdk java:system java:platform
endif
$(eval $(call link-type-partitions,$(my_link_type)))
$(my_link_type): PRIVATE_DEPS := $(my_link_type_deps)
$(my_link_type): PRIVATE_MODULE := $(LOCAL_MODULE)
$(my_link_type): PRIVATE_MAKEFILE := $(LOCAL_MODULE_MAKEFILE)
$(my_link_type): $(my_link_type_deps) $(CHECK_LINK_TYPE)
	@echo Check Java library module types: $@
	$(check-link-type)

$(LOCAL_BUILT_MODULE): $(my_link_type)

my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES))
my_link_deps += $(addprefix APPS:,$(apk_libraries))

my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
my_common := COMMON
include $(BUILD_SYSTEM)/link_type.mk
endif  # !LOCAL_IS_HOST_MODULE
Loading