diff --git a/core/base_rules.mk b/core/base_rules.mk index 107af9bab9..1178800616 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -202,7 +202,7 @@ ifdef LOCAL_UNINSTALLABLE_MODULE $(error $(LOCAL_PATH): Illegal use of LOCAL_UNINSTALLABLE_MODULE) endif else - LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_MODULE_SUBDIR)$(LOCAL_INSTALLED_MODULE_STEM) + LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM) endif # Assemble the list of targets to create PRIVATE_ variables for. diff --git a/core/binary.mk b/core/binary.mk index 88c356a391..71b9a46d05 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -539,6 +539,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(LOCAL_NO_CRT) # this is really the way to get the files onto the command line instead # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work diff --git a/core/clear_vars.mk b/core/clear_vars.mk index ca70c55f01..0d2e2159ae 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -105,6 +105,7 @@ LOCAL_BUILD_HOST_DEX:= LOCAL_DEX_PREOPT:= LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,full LOCAL_PROTOC_FLAGS:= +LOCAL_NO_CRT:= # Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to # iterate over thousands of entries every time. diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index e96ebce4d6..6b351fb9ea 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -237,7 +237,7 @@ $(hide) $(PRIVATE_CXX) \ -Wl,-shared,-Bsymbolic \ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ $(PRIVATE_ALL_OBJECTS) \ - $(PRIVATE_TARGET_CRTBEGIN_SO_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \ -Wl,--whole-archive \ $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ -Wl,--no-whole-archive \ @@ -248,7 +248,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_LDFLAGS) \ $(PRIVATE_TARGET_FDO_LIB) \ $(PRIVATE_TARGET_LIBGCC) \ - $(PRIVATE_TARGET_CRTEND_SO_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) endef define transform-o-to-executable-inner @@ -260,14 +260,14 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ $(TARGET_GLOBAL_LD_DIRS) \ -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ - $(TARGET_CRTBEGIN_DYNAMIC_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \ $(PRIVATE_ALL_OBJECTS) \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ $(TARGET_FDO_LIB) \ $(TARGET_LIBGCC) \ - $(TARGET_CRTEND_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) endef define transform-o-to-static-executable-inner @@ -275,7 +275,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ -Wl,--gc-sections \ -o $@ \ $(TARGET_GLOBAL_LD_DIRS) \ - $(TARGET_CRTBEGIN_STATIC_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \ $(TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ $(PRIVATE_ALL_OBJECTS) \ @@ -286,5 +286,5 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ $(TARGET_FDO_LIB) \ $(TARGET_LIBGCC) \ -Wl,--end-group \ - $(TARGET_CRTEND_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) endef diff --git a/core/combo/TARGET_linux-sh.mk b/core/combo/TARGET_linux-sh.mk index 036ecd799c..654539c8e6 100644 --- a/core/combo/TARGET_linux-sh.mk +++ b/core/combo/TARGET_linux-sh.mk @@ -105,6 +105,7 @@ TARGET_C_INCLUDES := \ TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o + TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o @@ -119,7 +120,7 @@ $(hide) $(PRIVATE_CXX) \ -Wl,--gc-sections -Wl,-z,norelro \ -Wl,-shared,-Bsymbolic \ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ - $(PRIVATE_TARGET_CRTBEGIN_SO_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \ $(PRIVATE_ALL_OBJECTS) \ -Wl,--whole-archive \ $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ @@ -130,7 +131,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_LDFLAGS) \ $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \ $(PRIVATE_TARGET_LIBGCC) \ - $(PRIVATE_TARGET_CRTEND_SO_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) endef define transform-o-to-executable-inner @@ -142,13 +143,13 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \ $(TARGET_GLOBAL_LD_DIRS) \ -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ - $(TARGET_CRTBEGIN_DYNAMIC_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \ $(PRIVATE_ALL_OBJECTS) \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(PRIVATE_LDFLAGS) \ $(TARGET_LIBGCC) \ $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \ - $(TARGET_CRTEND_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) endef define transform-o-to-static-executable-inner @@ -156,11 +157,11 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \ -Wl,--gc-sections -Wl,-z,norelro \ -o $@ \ $(TARGET_GLOBAL_LD_DIRS) \ - $(TARGET_CRTBEGIN_STATIC_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \ $(PRIVATE_LDFLAGS) \ $(PRIVATE_ALL_OBJECTS) \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(TARGET_LIBGCC) \ $(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \ - $(TARGET_CRTEND_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) endef diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk index c234cf623f..412ec697ff 100644 --- a/core/combo/TARGET_linux-x86.mk +++ b/core/combo/TARGET_linux-x86.mk @@ -107,7 +107,6 @@ TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o - TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o @@ -123,7 +122,7 @@ $(hide) $(PRIVATE_CXX) \ -shared -Bsymbolic \ $(TARGET_GLOBAL_CFLAGS) \ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ - $(PRIVATE_TARGET_CRTBEGIN_SO_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \ $(PRIVATE_ALL_OBJECTS) \ -Wl,--whole-archive \ $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ @@ -133,7 +132,7 @@ $(hide) $(PRIVATE_CXX) \ -o $@ \ $(PRIVATE_LDFLAGS) \ $(PRIVATE_TARGET_LIBGCC) \ - $(PRIVATE_TARGET_CRTEND_SO_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) endef @@ -147,12 +146,12 @@ $(hide) $(PRIVATE_CXX) \ $(TARGET_GLOBAL_LD_DIRS) \ -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ - $(TARGET_CRTBEGIN_DYNAMIC_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \ $(PRIVATE_ALL_OBJECTS) \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(PRIVATE_LDFLAGS) \ $(TARGET_LIBGCC) \ - $(TARGET_CRTEND_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) endef define transform-o-to-static-executable-inner @@ -161,14 +160,14 @@ $(hide) $(PRIVATE_CXX) \ -nostdlib -Bstatic \ -o $@ \ $(TARGET_GLOBAL_LD_DIRS) \ - $(TARGET_CRTBEGIN_STATIC_O) \ + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \ $(PRIVATE_LDFLAGS) \ $(PRIVATE_ALL_OBJECTS) \ -Wl,--start-group \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(TARGET_LIBGCC) \ -Wl,--end-group \ - $(TARGET_CRTEND_O) + $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) endef endif #simulator diff --git a/core/definitions.mk b/core/definitions.mk index b6f4515486..6fd4b998d3 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -716,6 +716,7 @@ define dump-module-variables @echo PRIVATE_ALL_STATIC_LIBRARIES=$(PRIVATE_ALL_STATIC_LIBRARIES); @echo PRIVATE_ALL_WHOLE_STATIC_LIBRARIES=$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES); @echo PRIVATE_ALL_OBJECTS=$(PRIVATE_ALL_OBJECTS); +@echo PRIVATE_NO_CRT=$(PRIVATE_NO_CRT); endef ########################################################### diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk index 0fa7647d24..005ccf3ecf 100644 --- a/core/dynamic_binary.mk +++ b/core/dynamic_binary.mk @@ -94,7 +94,7 @@ prelink_input := $(compress_output) # The output of the prelink step is the binary we want to use # for symbolic debugging; the prelink step may move sections # around, so we have to use this version. -prelink_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_MODULE_SUBDIR)$(LOCAL_BUILT_MODULE_STEM) +prelink_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_BUILT_MODULE_STEM) # Skip prelinker if it is FDO instrumentation build. ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)