From e7c59f9e2041812c597ff1c8689d47d1bfd32883 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 17 Dec 2013 20:47:06 -0800 Subject: [PATCH] Fix compilation of crtbegin.c and pthread_debug.cpp. Because there was no default := for the aarch64 libc_crt_target_cflags, the += was causing libc_crt_target_cflags to be recursively-defined variable, which meant that when we were compiling crtbegin.c LOCAL_PATH would be bionic/tests/ and we'd have -Ibionic/tests/include/ and find none of our include files. Also fix linking of pthread_debug.cpp, at least in the disabled mode. The enabled mode was already broken for all architectures, and continues to be broken after this change. It's been broken for long enough that we might want to just remove it... (aarch64 is using the FSF linker where arm uses the gold linker.) Change-Id: I7db2e386694f6933db043138e6e97e5ae54d4174 --- libc/Android.mk | 41 ++++++++++++++++++++--------------------- libc/bionic/pthread_debug.cpp | 37 ++++++++++++++++++++----------------- tests/Android.mk | 2 +- 3 files changed, 41 insertions(+), 39 deletions(-) diff --git a/libc/Android.mk b/libc/Android.mk index 94664d13b..7c098a8af 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -605,10 +605,16 @@ ifneq ($(BOARD_MALLOC_ALIGNMENT),) libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT) endif +# crtbrand.c needs and a #define for the platform SDK version. +libc_crt_target_cflags := \ + -I$(LOCAL_PATH)/include \ + -I$(LOCAL_PATH)/arch-$(TARGET_ARCH)/include \ + -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) \ + ifeq ($(TARGET_ARCH),arm) libc_common_cflags += -DSOFTFLOAT libc_common_cflags += -fstrict-aliasing - libc_crt_target_cflags := -mthumb-interwork + libc_crt_target_cflags += -mthumb-interwork endif # arm ifeq ($(TARGET_ARCH),mips) @@ -616,16 +622,16 @@ ifeq ($(TARGET_ARCH),mips) libc_common_cflags += -DSOFTFLOAT endif libc_common_cflags += -fstrict-aliasing - libc_crt_target_cflags := $(TARGET_GLOBAL_CFLAGS) + libc_crt_target_cflags += $(TARGET_GLOBAL_CFLAGS) endif # mips ifeq ($(TARGET_ARCH),x86) - libc_crt_target_cflags := -m32 + libc_crt_target_cflags += -m32 libc_crt_target_ldflags := -melf_i386 endif # x86 ifeq ($(TARGET_ARCH),x86_64) - libc_crt_target_cflags := -m64 + libc_crt_target_cflags += -m64 libc_crt_target_ldflags := -melf_x86_64 endif # x86_64 @@ -636,12 +642,6 @@ else libc_common_cflags += -DANDROID_SMP=0 endif -# crtbrand.c needs and a #define for the platform SDK version. -libc_crt_target_cflags += \ - -I$(LOCAL_PATH)/include \ - -I$(LOCAL_PATH)/arch-$(TARGET_ARCH)/include \ - -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) \ - # Define some common conlyflags libc_common_conlyflags := \ -std=gnu99 @@ -684,7 +684,7 @@ ifeq ($(TARGET_ARCH),arm) endif ifeq ($(TARGET_ARCH),mips) libc_crt_target_so_cflags := -fPIC -libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.c + libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.c endif ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64)) libc_crt_target_so_cflags := -fPIC @@ -907,7 +907,7 @@ include $(BUILD_STATIC_LIBRARY) # ======================================================== # libc_bionic.a - home-grown C library code # ======================================================== -# + include $(CLEAR_VARS) LOCAL_SRC_FILES := $(libc_bionic_src_files) @@ -1022,12 +1022,14 @@ LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_SRC_FILES := \ - $(libc_arch_dynamic_src_files) \ - $(libc_static_common_src_files) \ - bionic/dlmalloc.c \ - bionic/malloc_debug_common.cpp \ - bionic/pthread_debug.cpp \ - bionic/libc_init_dynamic.cpp + $(libc_arch_dynamic_src_files) \ + $(libc_static_common_src_files) \ + bionic/dlmalloc.c \ + bionic/malloc_debug_common.cpp \ + bionic/debug_mapinfo.cpp \ + bionic/debug_stacktrace.cpp \ + bionic/pthread_debug.cpp \ + bionic/libc_init_dynamic.cpp \ ifeq ($(TARGET_ARCH),arm) LOCAL_NO_CRT := true @@ -1103,8 +1105,6 @@ include $(BUILD_SHARED_LIBRARY) # ======================================================== # libc_malloc_debug_qemu.so # ======================================================== -#TODO: We do not build this library for now -ifneq ($(TARGET_ARCH),aarch64) include $(CLEAR_VARS) LOCAL_CFLAGS := \ @@ -1130,7 +1130,6 @@ LOCAL_MODULE_TAGS := eng debug include $(BUILD_SHARED_LIBRARY) -endif #!aarch64 endif #!user diff --git a/libc/bionic/pthread_debug.cpp b/libc/bionic/pthread_debug.cpp index 79a193d6c..f01f04026 100644 --- a/libc/bionic/pthread_debug.cpp +++ b/libc/bionic/pthread_debug.cpp @@ -91,6 +91,8 @@ the lock, so we actually do most of our deadlock prediction work after the lock has been acquired. */ +#if PTHREAD_DEBUG_ENABLED + // ============================================================================= // log functions // ============================================================================= @@ -658,23 +660,6 @@ static MutexInfo* get_most_recently_locked() { /****************************************************************************/ -/* pthread_debug_init() is called from libc_init_dynamic() just - * after system properties have been initialized - */ - -extern "C" __LIBC_HIDDEN__ void pthread_debug_init() { - char env[PROP_VALUE_MAX]; - if (__system_property_get("debug.libc.pthread", env)) { - int level = atoi(env); - if (level) { - LOGI("pthread deadlock detection level %d enabled for pid %d (%s)", - level, getpid(), __progname); - hashmap_init(&sMutexMap); - sPthreadDebugLevel = level; - } - } -} - /* * See if we were allowed to grab the lock at this time. We do it * *after* acquiring the lock, rather than before, so that we can @@ -712,3 +697,21 @@ extern "C" __LIBC_HIDDEN__ void pthread_debug_mutex_unlock_check(pthread_mutex_t remove_most_recently_locked(object); mutex_unlock_checked(object); } + +#endif // PTHREAD_DEBUG_ENABLED + +// Called from libc_init_dynamic() just after system properties have been initialized. +extern "C" __LIBC_HIDDEN__ void pthread_debug_init() { +#if PTHREAD_DEBUG_ENABLED + char env[PROP_VALUE_MAX]; + if (__system_property_get("debug.libc.pthread", env)) { + int level = atoi(env); + if (level) { + LOGI("pthread deadlock detection level %d enabled for pid %d (%s)", + level, getpid(), __progname); + hashmap_init(&sMutexMap); + sPthreadDebugLevel = level; + } + } +#endif +} diff --git a/tests/Android.mk b/tests/Android.mk index a342be777..0a4db9134 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -14,7 +14,7 @@ # limitations under the License. # -ifneq ($(BUILD_TINY_ANDROID), true) +ifneq ($(BUILD_TINY_ANDROID),true) LOCAL_PATH := $(call my-dir) -- 2.11.0