Enable building libc with clang.
Bug: 16218205 Change-Id: I024de2044fe016412c7bead22c264e96be4cb39c
This commit is contained in:
parent
9b491470ac
commit
c999f76977
@ -495,6 +495,8 @@ ifneq ($(TARGET_USES_LOGD),false)
|
|||||||
libc_common_cflags += -DTARGET_USES_LOGD
|
libc_common_cflags += -DTARGET_USES_LOGD
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
use_clang := false
|
||||||
|
|
||||||
# Try to catch typical 32-bit assumptions that break with 64-bit pointers.
|
# Try to catch typical 32-bit assumptions that break with 64-bit pointers.
|
||||||
libc_common_cflags += \
|
libc_common_cflags += \
|
||||||
-Werror=pointer-to-int-cast \
|
-Werror=pointer-to-int-cast \
|
||||||
@ -575,6 +577,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_stack_protector
|
LOCAL_MODULE := libc_stack_protector
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
@ -612,6 +615,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes) $(LOCAL_PATH)/tzcode/
|
LOCAL_C_INCLUDES := $(libc_common_c_includes) $(LOCAL_PATH)/tzcode/
|
||||||
LOCAL_MODULE := libc_tzcode
|
LOCAL_MODULE := libc_tzcode
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
@ -646,6 +650,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_dns
|
LOCAL_MODULE := libc_dns
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
@ -674,6 +679,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_freebsd
|
LOCAL_MODULE := libc_freebsd
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
@ -703,6 +709,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_netbsd
|
LOCAL_MODULE := libc_netbsd
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
@ -733,6 +740,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_openbsd
|
LOCAL_MODULE := libc_openbsd
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
@ -763,6 +771,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_gdtoa
|
LOCAL_MODULE := libc_gdtoa
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
@ -784,6 +793,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_bionic
|
LOCAL_MODULE := libc_bionic
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
@ -803,12 +813,31 @@ ifdef TARGET_2ND_ARCH
|
|||||||
LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) := $(call all-S-files-under,arch-$(TARGET_2ND_ARCH)/syscalls)
|
LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) := $(call all-S-files-under,arch-$(TARGET_2ND_ARCH)/syscalls)
|
||||||
endif
|
endif
|
||||||
LOCAL_MODULE := libc_syscalls
|
LOCAL_MODULE := libc_syscalls
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
|
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
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
|
# libc_common.a
|
||||||
# ========================================================
|
# ========================================================
|
||||||
@ -821,6 +850,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_common
|
LOCAL_MODULE := libc_common
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_WHOLE_STATIC_LIBRARIES := \
|
LOCAL_WHOLE_STATIC_LIBRARIES := \
|
||||||
libc_bionic \
|
libc_bionic \
|
||||||
@ -834,6 +864,8 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \
|
|||||||
libc_syscalls \
|
libc_syscalls \
|
||||||
libc_tzcode \
|
libc_tzcode \
|
||||||
|
|
||||||
|
LOCAL_WHOLE_STATIC_LIBRARIES_arm := libc_aeabi
|
||||||
|
|
||||||
ifeq ($(MALLOC_IMPL),jemalloc)
|
ifeq ($(MALLOC_IMPL),jemalloc)
|
||||||
LOCAL_WHOLE_STATIC_LIBRARIES += libjemalloc
|
LOCAL_WHOLE_STATIC_LIBRARIES += libjemalloc
|
||||||
endif
|
endif
|
||||||
@ -874,6 +906,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
|
|
||||||
LOCAL_MODULE := libc_nomalloc
|
LOCAL_MODULE := libc_nomalloc
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
|
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
@ -896,6 +929,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc_malloc
|
LOCAL_MODULE := libc_malloc
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
@ -918,6 +952,7 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
|||||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||||
LOCAL_MODULE := libc
|
LOCAL_MODULE := libc
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
|
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||||
@ -946,6 +981,7 @@ LOCAL_SRC_FILES := \
|
|||||||
bionic/NetdClient.cpp \
|
bionic/NetdClient.cpp \
|
||||||
|
|
||||||
LOCAL_MODULE := libc
|
LOCAL_MODULE := libc
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
LOCAL_REQUIRED_MODULES := tzdata
|
LOCAL_REQUIRED_MODULES := tzdata
|
||||||
|
|
||||||
@ -1016,6 +1052,7 @@ LOCAL_SRC_FILES := \
|
|||||||
bionic/malloc_debug_check.cpp \
|
bionic/malloc_debug_check.cpp \
|
||||||
|
|
||||||
LOCAL_MODULE := libc_malloc_debug_leak
|
LOCAL_MODULE := libc_malloc_debug_leak
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
|
|
||||||
LOCAL_SHARED_LIBRARIES := libc libdl
|
LOCAL_SHARED_LIBRARIES := libc libdl
|
||||||
@ -1048,6 +1085,7 @@ LOCAL_SRC_FILES := \
|
|||||||
bionic/malloc_debug_qemu.cpp \
|
bionic/malloc_debug_qemu.cpp \
|
||||||
|
|
||||||
LOCAL_MODULE := libc_malloc_debug_qemu
|
LOCAL_MODULE := libc_malloc_debug_qemu
|
||||||
|
LOCAL_CLANG := $(use_clang)
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
|
||||||
|
|
||||||
LOCAL_SHARED_LIBRARIES := libc libdl
|
LOCAL_SHARED_LIBRARIES := libc libdl
|
||||||
|
@ -52,7 +52,6 @@ libc_bionic_src_files_arm += \
|
|||||||
arch-arm/bionic/abort_arm.S \
|
arch-arm/bionic/abort_arm.S \
|
||||||
arch-arm/bionic/atomics_arm.c \
|
arch-arm/bionic/atomics_arm.c \
|
||||||
arch-arm/bionic/__bionic_clone.S \
|
arch-arm/bionic/__bionic_clone.S \
|
||||||
arch-arm/bionic/eabi.c \
|
|
||||||
arch-arm/bionic/_exit_with_stack_teardown.S \
|
arch-arm/bionic/_exit_with_stack_teardown.S \
|
||||||
arch-arm/bionic/__get_sp.S \
|
arch-arm/bionic/__get_sp.S \
|
||||||
arch-arm/bionic/libgcc_compat.c \
|
arch-arm/bionic/libgcc_compat.c \
|
||||||
|
@ -25,10 +25,19 @@
|
|||||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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 <stddef.h>
|
||||||
#include <string.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,
|
/* The "C++ ABI for ARM" document states that static C++ constructors,
|
||||||
* which are called from the .init_array, should manually call
|
* 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
|
* variable from the shared object that contains the constructor/destructor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Make this a weak symbol to avoid a multiple definition error when linking
|
// Make this a weak symbol to avoid a multiple definition error when linking with libstdc++-v3.
|
||||||
* with libstdc++-v3. */
|
|
||||||
int __attribute__((weak))
|
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);
|
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
|
* This allows __aeabi_memclr to tail-call __aeabi_memset
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void __aeabi_memset8(void *dest, size_t n, int c) {
|
void __aeabi_memset8(void *dest, size_t n, int c) {
|
||||||
memset(dest, c, n);
|
memset(dest, c, n);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user