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
Change-Id: I43c5f5f0ddc0c2a31918f00b57150dadd8f3f26b
diff --git a/libc/Android.mk b/libc/Android.mk
index 31807dd..d277551 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -515,7 +515,10 @@
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 += \
@@ -751,6 +754,13 @@
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 \
@@ -764,7 +774,6 @@
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 :=
@@ -783,6 +792,13 @@
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 \
@@ -796,7 +812,6 @@
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 :=
@@ -814,6 +829,11 @@
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 4902a0c..a596a48 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