From 762cea46f070e25b33de6f36a54fb7c293f0fee5 Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Mon, 30 Sep 2013 17:10:53 -0700 Subject: [PATCH] Use gnu++11 and gnu99 explicitly for C++/C files. Clang and gcc default to different standards, so we should be explicit about the versions we want to compile for. Change-Id: I65495a2392dd29f36373b94c616c2506173e6033 --- libc/Android.mk | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/libc/Android.mk b/libc/Android.mk index f3a4dcf34..fc61c2710 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -609,6 +609,14 @@ libc_crt_target_cflags += \ -I$(LOCAL_PATH)/include \ -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) +# Define some common conlyflags +libc_common_conlyflags := \ + -std=gnu99 + +# Define some common cppflags +libc_common_cppflags := \ + -std=gnu++11 + # Define some common includes # ======================================================== libc_common_c_includes := \ @@ -756,6 +764,8 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := bionic/__stack_chk_fail.cpp LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector -Werror +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libbionic_ssp LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -773,11 +783,12 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(libc_tzcode_src_files) LOCAL_CFLAGS := \ $(libc_common_cflags) \ - -std=gnu99 \ -DSTD_INSPIRED=1 \ -DTZDIR=\"/system/usr/share/zoneinfo\" \ -DTM_GMTOFF=tm_gmtoff \ -DUSG_COMPAT=1 +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc_tzcode LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -801,6 +812,8 @@ LOCAL_CFLAGS := \ -I$(LOCAL_PATH)/upstream-freebsd \ -I$(LOCAL_PATH)/upstream-freebsd/libc/include \ -include upstream-freebsd/freebsd-compat.h +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc_freebsd LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -824,6 +837,8 @@ LOCAL_CFLAGS := \ -I$(LOCAL_PATH)/upstream-netbsd \ -I$(LOCAL_PATH)/upstream-netbsd/libc/include \ -include upstream-netbsd/netbsd-compat.h +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc_netbsd LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -840,6 +855,8 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(libc_bionic_src_files) LOCAL_CFLAGS := $(libc_common_cflags) -Werror +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc_bionic LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -856,8 +873,9 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(libc_common_src_files) LOCAL_CFLAGS := $(libc_common_cflags) \ - -std=gnu99 \ -I$(LOCAL_PATH)/upstream-netbsd/libc/include # for netbsd private headers +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc_common LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -894,8 +912,9 @@ LOCAL_SRC_FILES := \ LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_CFLAGS := $(libc_common_cflags) \ - -DLIBC_STATIC \ - -std=gnu99 + -DLIBC_STATIC +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_MODULE := libc_nomalloc LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -918,8 +937,9 @@ LOCAL_SRC_FILES := \ bionic/libc_init_static.cpp LOCAL_CFLAGS := $(libc_common_cflags) \ - -DLIBC_STATIC \ - -std=gnu99 + -DLIBC_STATIC +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -940,7 +960,9 @@ include $(CLEAR_VARS) # Since this code is experimental it is disabled by default. # see libc/bionic/pthread_debug.c for details -LOCAL_CFLAGS := $(libc_common_cflags) -std=gnu99 -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=0 +LOCAL_CFLAGS := $(libc_common_cflags) -DPTHREAD_DEBUG -DPTHREAD_DEBUG_ENABLED=0 +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_SRC_FILES := \ @@ -997,6 +1019,8 @@ include $(CLEAR_VARS) LOCAL_CFLAGS := \ $(libc_common_cflags) \ -DMALLOC_LEAK_CHECK +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes) @@ -1028,6 +1052,8 @@ include $(CLEAR_VARS) LOCAL_CFLAGS := \ $(libc_common_cflags) \ -DMALLOC_QEMU_INSTRUMENT +LOCAL_CONLYFLAGS := $(libc_common_conlyflags) +LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_C_INCLUDES := $(libc_common_c_includes)