* commit 'ce1422b985383c4cbb485b3ec121eb8d01af12b8': Enable building libc with clang.
This commit is contained in:
		@@ -502,6 +502,8 @@ ifneq ($(TARGET_USES_LOGD),false)
 | 
			
		||||
libc_common_cflags += -DTARGET_USES_LOGD
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
use_clang := false
 | 
			
		||||
 | 
			
		||||
# Try to catch typical 32-bit assumptions that break with 64-bit pointers.
 | 
			
		||||
libc_common_cflags += \
 | 
			
		||||
    -Werror=pointer-to-int-cast \
 | 
			
		||||
@@ -582,6 +584,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_stack_protector
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
@@ -619,6 +622,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes) $(LOCAL_PATH)/tzcode/
 | 
			
		||||
LOCAL_MODULE := libc_tzcode
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
@@ -653,6 +657,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_dns
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
@@ -681,6 +686,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_freebsd
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
@@ -710,6 +716,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_netbsd
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
@@ -740,6 +747,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_openbsd
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
@@ -770,6 +778,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_gdtoa
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
@@ -791,6 +800,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_bionic
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
@@ -810,12 +820,31 @@ ifdef TARGET_2ND_ARCH
 | 
			
		||||
LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) := $(call all-S-files-under,arch-$(TARGET_2ND_ARCH)/syscalls)
 | 
			
		||||
endif
 | 
			
		||||
LOCAL_MODULE := libc_syscalls
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
include $(BUILD_STATIC_LIBRARY)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# ========================================================
 | 
			
		||||
# libc_aeabi.a
 | 
			
		||||
# This is an LP32 ARM-only library that needs to be built with -fno-builtin
 | 
			
		||||
# to avoid infinite recursion. For the other architectures we just build an
 | 
			
		||||
# empty library to keep this makefile simple.
 | 
			
		||||
# ========================================================
 | 
			
		||||
 | 
			
		||||
include $(CLEAR_VARS)
 | 
			
		||||
 | 
			
		||||
LOCAL_SRC_FILES_arm := arch-arm/bionic/__aeabi.c
 | 
			
		||||
LOCAL_MODULE := libc_aeabi
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_CFLAGS := $(libc_common_cflags) -fno-builtin
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
 | 
			
		||||
include $(BUILD_STATIC_LIBRARY)
 | 
			
		||||
 | 
			
		||||
# ========================================================
 | 
			
		||||
# libc_common.a
 | 
			
		||||
# ========================================================
 | 
			
		||||
@@ -828,6 +857,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_common
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_WHOLE_STATIC_LIBRARIES := \
 | 
			
		||||
    libc_bionic \
 | 
			
		||||
@@ -841,6 +871,8 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \
 | 
			
		||||
    libc_syscalls \
 | 
			
		||||
    libc_tzcode \
 | 
			
		||||
 | 
			
		||||
LOCAL_WHOLE_STATIC_LIBRARIES_arm := libc_aeabi
 | 
			
		||||
 | 
			
		||||
ifeq ($(MALLOC_IMPL),jemalloc)
 | 
			
		||||
LOCAL_WHOLE_STATIC_LIBRARIES += libjemalloc
 | 
			
		||||
endif
 | 
			
		||||
@@ -881,6 +913,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
 | 
			
		||||
LOCAL_MODULE := libc_nomalloc
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
@@ -903,6 +936,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_malloc
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
include $(BUILD_STATIC_LIBRARY)
 | 
			
		||||
 | 
			
		||||
@@ -925,6 +959,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 | 
			
		||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
@@ -953,6 +988,7 @@ LOCAL_SRC_FILES := \
 | 
			
		||||
    bionic/NetdClient.cpp \
 | 
			
		||||
 | 
			
		||||
LOCAL_MODULE := libc
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
LOCAL_REQUIRED_MODULES := tzdata
 | 
			
		||||
 | 
			
		||||
@@ -1023,6 +1059,7 @@ LOCAL_SRC_FILES := \
 | 
			
		||||
    bionic/malloc_debug_check.cpp \
 | 
			
		||||
 | 
			
		||||
LOCAL_MODULE := libc_malloc_debug_leak
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
 | 
			
		||||
LOCAL_SHARED_LIBRARIES := libc libdl
 | 
			
		||||
@@ -1055,6 +1092,7 @@ LOCAL_SRC_FILES := \
 | 
			
		||||
    bionic/malloc_debug_qemu.cpp \
 | 
			
		||||
 | 
			
		||||
LOCAL_MODULE := libc_malloc_debug_qemu
 | 
			
		||||
LOCAL_CLANG := $(use_clang)
 | 
			
		||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 | 
			
		||||
 | 
			
		||||
LOCAL_SHARED_LIBRARIES := libc libdl
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,6 @@ libc_bionic_src_files_arm += \
 | 
			
		||||
    arch-arm/bionic/abort_arm.S \
 | 
			
		||||
    arch-arm/bionic/atomics_arm.c \
 | 
			
		||||
    arch-arm/bionic/__bionic_clone.S \
 | 
			
		||||
    arch-arm/bionic/eabi.c \
 | 
			
		||||
    arch-arm/bionic/_exit_with_stack_teardown.S \
 | 
			
		||||
    arch-arm/bionic/__get_sp.S \
 | 
			
		||||
    arch-arm/bionic/libgcc_compat.c \
 | 
			
		||||
 
 | 
			
		||||
@@ -25,10 +25,19 @@
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if defined(__clang__)
 | 
			
		||||
// clang interprets -fno-builtin more loosely than you might expect,
 | 
			
		||||
// and thinks it's okay to still substitute builtins as long as they're
 | 
			
		||||
// named __aeabi_* rather than __builtin_*, which causes infinite
 | 
			
		||||
// recursion if we have the fortified memcpy visible in this file.
 | 
			
		||||
#undef _FORTIFY_SOURCE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
extern int  __cxa_atexit(void (*)(void*), void*, void* );
 | 
			
		||||
extern int __cxa_atexit(void (*)(void*), void*, void*);
 | 
			
		||||
 | 
			
		||||
/* The "C++ ABI for ARM" document states that static C++ constructors,
 | 
			
		||||
 * which are called from the .init_array, should manually call
 | 
			
		||||
@@ -38,11 +47,9 @@ extern int  __cxa_atexit(void (*)(void*), void*, void* );
 | 
			
		||||
 * variable from the shared object that contains the constructor/destructor
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Make this a weak symbol to avoid a multiple definition error when linking
 | 
			
		||||
 * with libstdc++-v3.  */
 | 
			
		||||
// Make this a weak symbol to avoid a multiple definition error when linking with libstdc++-v3.
 | 
			
		||||
int __attribute__((weak))
 | 
			
		||||
__aeabi_atexit (void *object, void (*destructor) (void *), void *dso_handle)
 | 
			
		||||
{
 | 
			
		||||
__aeabi_atexit(void *object, void (*destructor) (void *), void *dso_handle) {
 | 
			
		||||
    return __cxa_atexit(destructor, object, dso_handle);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -73,10 +80,10 @@ void __aeabi_memmove(void *dest, const void *src, size_t n) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * __aeabi_memset has the order of its second and third arguments reversed. 
 | 
			
		||||
 * __aeabi_memset has the order of its second and third arguments reversed.
 | 
			
		||||
 *  This allows __aeabi_memclr to tail-call __aeabi_memset
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
void __aeabi_memset8(void *dest, size_t n, int c) {
 | 
			
		||||
    memset(dest, c, n);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user