summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-02-04 20:15:00 -0800
committerJeff Brown <jeffbrown@google.com>2011-02-08 16:38:56 -0800
commit703e7c6d50a5bddf0fb057a1a26618e2f7138c31 (patch)
tree5e24b5c6effe4088eb68e29f741ab8f7a33aaec5
parent706408ea9f2450118a76ad9915ac0c5f73209efd (diff)
downloadbuild-703e7c6d50a5bddf0fb057a1a26618e2f7138c31.zip
build-703e7c6d50a5bddf0fb057a1a26618e2f7138c31.tar.gz
build-703e7c6d50a5bddf0fb057a1a26618e2f7138c31.tar.bz2
Build system tweaks for Valgrind.
Added LOCAL_NO_CRT to enable building executables that do not link to the C runtime library. Removed support for LOCAL_MODULE_SUBDIR since it was broken and unused. (Was going to use it but ended up using LOCAL_MODULE_PATH instead.) Change-Id: I3b6f5ab7e5ae6aaa7119899adccece2b4ab1cbb3
-rw-r--r--core/base_rules.mk2
-rw-r--r--core/binary.mk1
-rw-r--r--core/clear_vars.mk1
-rw-r--r--core/combo/TARGET_linux-arm.mk12
-rw-r--r--core/combo/TARGET_linux-sh.mk13
-rw-r--r--core/combo/TARGET_linux-x86.mk13
-rw-r--r--core/definitions.mk1
-rw-r--r--core/dynamic_binary.mk2
8 files changed, 24 insertions, 21 deletions
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 107af9b..1178800 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 88c356a..71b9a46 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 ca70c55..0d2e215 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 e96ebce..6b351fb 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 036ecd7..654539c 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 c234cf6..412ec69 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 b6f4515..6fd4b99 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 0fa7647..005ccf3 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)),)