From 81fe2b16dc3ac8f17719964d3d01e92e2dc3cc4c Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Thu, 4 Sep 2014 15:19:52 -0700 Subject: [PATCH] Enable clang compilation with libc but not linker. Clang is still disabled for x86 and x86_64 long double code, for x86_64 special assembly instruction, and the linker module. BUG: 17163651 BUG: 17302991 BUG: 17403674 (cherry picked from commit b58db8b083ce41798a5310616e4f20885cec611f) Change-Id: I916c05056d37a9c287b0a5ae3b1a209d98c8f70e --- libc/Android.mk | 26 +++++++++++++++++++++++--- linker/linker_executable.mk | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/libc/Android.mk b/libc/Android.mk index 9c5e785ae..fe1f31577 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -503,7 +503,10 @@ ifneq ($(TARGET_USES_LOGD),false) libc_common_cflags += -DTARGET_USES_LOGD endif -use_clang := false +use_clang := $(USE_CLANG_PLATFORM_BUILD) +ifeq ($(use_clang),) + use_clang := false +endif # Try to catch typical 32-bit assumptions that break with 64-bit pointers. libc_common_cflags += \ @@ -733,6 +736,13 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(libc_upstream_openbsd_src_files) +ifneq (,$(filter $(TARGET_ARCH),x86 x86_64)) + # Clang has wrong long double size or LDBL_MANT_DIG, http://b/17163651. + LOCAL_CLANG := false +else + LOCAL_CLANG := $(use_clang) +endif + LOCAL_CFLAGS := \ $(libc_common_cflags) \ -Wno-sign-compare -Wno-uninitialized -Wno-unused-parameter \ @@ -746,7 +756,6 @@ 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 := @@ -765,6 +774,13 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES_32 := $(libc_upstream_openbsd_gdtoa_src_files_32) LOCAL_SRC_FILES_64 := $(libc_upstream_openbsd_gdtoa_src_files_64) +ifneq (,$(filter $(TARGET_ARCH),x86 x86_64)) + # Clang has wrong long double size or LDBL_MANT_DIG, http://b/17163651. + LOCAL_CLANG := false +else + LOCAL_CLANG := $(use_clang) +endif + LOCAL_CFLAGS := \ $(libc_common_cflags) \ -Wno-sign-compare -Wno-uninitialized \ @@ -778,7 +794,6 @@ 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 := @@ -796,6 +811,11 @@ LOCAL_SRC_FILES := $(libc_bionic_src_files) LOCAL_CFLAGS := $(libc_common_cflags) \ -Wframe-larger-than=2048 \ +ifeq ($(TARGET_ARCH),x86_64) + # Clang assembler has problem with ssse3-strcmp-slm.S, http://b/17302991 + LOCAL_CLANG_ASFLAGS += -no-integrated-as +endif + LOCAL_CONLYFLAGS := $(libc_common_conlyflags) LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) diff --git a/linker/linker_executable.mk b/linker/linker_executable.mk index 4902a0cc5..a596a4805 100644 --- a/linker/linker_executable.mk +++ b/linker/linker_executable.mk @@ -9,6 +9,8 @@ LOCAL_MODULE_CLASS := EXECUTABLES LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX) +# Clang calls /usr/bin/ld: unrecognized option '--icf=safe', http://b/17403674. +LOCAL_CLANG := false include $(BUILD_SYSTEM)/dynamic_binary.mk # See build/core/executable_internal.mk