067d781530
Remove the global linker search path, as it can cause spurious build failures. If a library with the same name as a system library is in the process of being written to the directory in the global search path, and the linker may try to read the partially-written built one instead of the system one. We already use full paths to libraries for target builds, do the same for host builds. Also remove the normalize library functions, they are no longer necessary. Test: m -j checkbuild Bug: 31393456 Change-Id: If9fc631e111f568c700fd73e103445c30d7e9d11
85 lines
3.7 KiB
Makefile
85 lines
3.7 KiB
Makefile
###########################################################
|
|
## Standard rules for building an executable file.
|
|
##
|
|
## Additional inputs from base_rules.make:
|
|
## None.
|
|
###########################################################
|
|
|
|
ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
|
|
LOCAL_MODULE_CLASS := EXECUTABLES
|
|
endif
|
|
ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
|
|
LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
|
|
endif
|
|
|
|
$(call target-executable-hook)
|
|
|
|
skip_build_from_source :=
|
|
ifdef LOCAL_PREBUILT_MODULE_FILE
|
|
ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
|
|
include $(BUILD_SYSTEM)/prebuilt_internal.mk
|
|
skip_build_from_source := true
|
|
endif
|
|
endif
|
|
|
|
ifndef skip_build_from_source
|
|
|
|
include $(BUILD_SYSTEM)/dynamic_binary.mk
|
|
|
|
# Check for statically linked libc
|
|
ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
|
|
ifneq ($(filter $(my_static_libraries),libc),)
|
|
$(error $(LOCAL_PATH): $(LOCAL_MODULE) is statically linking libc to dynamic executable, please remove libc from static libs or set LOCAL_FORCE_STATIC_EXECUTABLE := true)
|
|
endif
|
|
endif
|
|
|
|
# Define PRIVATE_ variables from global vars
|
|
my_target_global_ld_dirs :=
|
|
ifeq ($(LOCAL_NO_LIBGCC),true)
|
|
my_target_libgcc :=
|
|
else
|
|
my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a
|
|
endif
|
|
my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a
|
|
ifeq ($(LOCAL_NO_CRT),true)
|
|
my_target_crtbegin_dynamic_o :=
|
|
my_target_crtbegin_static_o :=
|
|
my_target_crtend_o :=
|
|
else
|
|
my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
|
|
my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
|
|
my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
|
|
endif
|
|
ifdef LOCAL_SDK_VERSION
|
|
# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
|
|
# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
|
|
my_target_global_ld_dirs := \
|
|
$(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
|
|
$(my_ndk_sysroot_lib)) \
|
|
$(my_target_global_ld_dirs)
|
|
my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
|
|
my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o)
|
|
my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o)
|
|
my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o)
|
|
endif
|
|
$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs)
|
|
$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
|
|
$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
|
|
$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
|
|
$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o)
|
|
$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o)
|
|
$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o)
|
|
$(linked_module): PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
|
|
$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
|
|
|
|
ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
|
|
$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libgcc) $(my_target_libatomic)
|
|
$(transform-o-to-static-executable)
|
|
$(PRIVATE_POST_LINK_CMD)
|
|
else
|
|
$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libgcc) $(my_target_libatomic)
|
|
$(transform-o-to-executable)
|
|
$(PRIVATE_POST_LINK_CMD)
|
|
endif
|
|
|
|
endif # skip_build_from_source
|