endif
# Clang build support.
-# Target builds use GCC by default.
-ART_TARGET_CLANG := false
+
+# Host.
ART_HOST_CLANG := false
ifneq ($(WITHOUT_HOST_CLANG),true)
# By default, host builds use clang for better warnings.
ART_HOST_CLANG := true
endif
-# enable ART_TARGET_CLANG for ARM64
-ifneq (,$(filter $(TARGET_ARCH),arm64))
-ART_TARGET_CLANG := true
-endif
+# Clang on the target: only enabled for ARM64. Target builds use GCC by default.
+ART_TARGET_CLANG :=
+ART_TARGET_CLANG_arm :=
+ART_TARGET_CLANG_arm64 := true
+ART_TARGET_CLANG_mips :=
+ART_TARGET_CLANG_x86 :=
+ART_TARGET_CLANG_x86_64 :=
+
+define set-target-local-clang-vars
+ LOCAL_CLANG := $(ART_TARGET_CLANG)
+ $(foreach arch,$(ART_SUPPORTED_ARCH),
+ ifneq ($$(ART_TARGET_CLANG_$(arch)),)
+ LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
+ endif)
+endef
# directory used for dalvik-cache on device
ART_DALVIK_CACHE_DIR := /data/dalvik-cache
-Wstrict-aliasing \
-fstrict-aliasing
+ART_TARGET_CLANG_CFLAGS :=
+ART_TARGET_CLANG_CFLAGS_arm :=
+ART_TARGET_CLANG_CFLAGS_arm64 :=
+ART_TARGET_CLANG_CFLAGS_mips :=
+ART_TARGET_CLANG_CFLAGS_x86 :=
+ART_TARGET_CLANG_CFLAGS_x86_64 :=
+
# these are necessary for Clang ARM64 ART builds
-ifeq ($(ART_TARGET_CLANG), true)
-art_cflags += \
+ART_TARGET_CLANG_CFLAGS_arm64 += \
-Wno-implicit-exception-spec-mismatch \
-DNVALGRIND \
-Wno-unused-value
-endif
ifeq ($(ART_SMALL_MODE),true)
art_cflags += -DART_SMALL_MODE=1
-O3
# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
-ifeq ($(ART_TARGET_CLANG),true)
-art_non_debug_cflags += \
- -fno-vectorize
-endif
+ART_TARGET_CLANG_CFLAGS_arm64 += \
+ -fno-vectorize
art_debug_cflags := \
-O1 \
ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
+# $(1): ndebug_or_debug
+define set-target-local-cflags-vars
+ LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
+ LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
+ art_target_cflags_ndebug_or_debug := $(1)
+ ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
+ LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
+ else
+ LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
+ endif
+
+ # TODO: Also set when ART_TARGET_CLANG_$(arch)!=false and ART_TARGET_CLANG==true
+ $(foreach arch,$(ART_SUPPORTED_ARCH),
+ ifeq ($$(ART_TARGET_CLANG_$(arch)),true)
+ LOCAL_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch))
+ endif)
+endef
+
ART_BUILD_TARGET := false
ART_BUILD_HOST := false
ART_BUILD_NDEBUG := false
LOCAL_CFLAGS := $(ART_EXECUTABLES_CFLAGS)
ifeq ($$(art_target_or_host),target)
- LOCAL_CLANG := $(ART_TARGET_CLANG)
- LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
- LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
- ifeq ($$(art_ndebug_or_debug),debug)
- LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
- else
- LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
- endif
+ $(call set-target-local-clang-vars)
+ $(call set-target-local-cflags-vars,$(6))
else # host
LOCAL_CLANG := $(ART_HOST_CLANG)
LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
LOCAL_CFLAGS := $(ART_TEST_CFLAGS)
include external/libcxx/libcxx.mk
ifeq ($$(art_target_or_host),target)
- LOCAL_CLANG := $(ART_TARGET_CLANG)
- LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
- LOCAL_CFLAGS_x86 := $(ART_TARGET_CFLAGS_x86)
+ $(call set-target-local-clang-vars)
+ $(call set-target-local-cflags-vars,debug)
LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libz libcutils libvixl
LOCAL_STATIC_LIBRARIES += libgtest_libc++
LOCAL_MODULE_PATH_32 := $(ART_NATIVETEST_OUT)/$(ART_TARGET_ARCH_32)
LOCAL_MODULE_PATH_64 := $(ART_NATIVETEST_OUT)/$(ART_TARGET_ARCH_64)
LOCAL_MULTILIB := both
include $(BUILD_EXECUTABLE)
-
+
ART_TARGET_GTEST_EXECUTABLES$(ART_PHONY_TEST_TARGET_SUFFIX) += $(ART_NATIVETEST_OUT)/$(TARGET_ARCH)/$$(LOCAL_MODULE)
art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.libarttest.mk
include external/libcxx/libcxx.mk
ifeq ($$(art_target_or_host),target)
- LOCAL_CLANG := $(ART_TARGET_CLANG)
- LOCAL_CFLAGS := $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
- LOCAL_CFLAGS_x86 := $(ART_TARGET_CFLAGS_x86)
+ $(call set-target-local-clang-vars)
+ $(call set-target-local-cflags-vars,debug)
LOCAL_SHARED_LIBRARIES += libdl libcutils
LOCAL_STATIC_LIBRARIES := libgtest
LOCAL_MULTILIB := both
LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
ifeq ($$(art_ndebug_or_debug),ndebug)
LOCAL_MODULE := libart-compiler
+ LOCAL_SHARED_LIBRARIES += libart
else # debug
LOCAL_MODULE := libartd-compiler
+ LOCAL_SHARED_LIBRARIES += libartd
endif
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS := $$(LIBART_COMPILER_CFLAGS)
include external/libcxx/libcxx.mk
ifeq ($$(art_target_or_host),target)
- LOCAL_CLANG := $(ART_TARGET_CLANG)
- LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
+ $(call set-target-local-clang-vars)
+ $(call set-target-local-cflags-vars,$(2))
else # host
LOCAL_CLANG := $(ART_HOST_CLANG)
LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
+ ifeq ($$(art_ndebug_or_debug),debug)
+ LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
+ else
+ LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
+ endif
endif
# TODO: clean up the compilers and remove this.
LOCAL_CFLAGS += -Wno-unused-parameter
- LOCAL_SHARED_LIBRARIES += liblog
- ifeq ($$(art_ndebug_or_debug),debug)
- ifeq ($$(art_target_or_host),target)
- LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
- else # host
- LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
- endif
- LOCAL_SHARED_LIBRARIES += libartd
- else
- ifeq ($$(art_target_or_host),target)
- LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
- else # host
- LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
- endif
- LOCAL_SHARED_LIBRARIES += libart
- endif
ifeq ($(ART_USE_PORTABLE_COMPILER),true)
LOCAL_SHARED_LIBRARIES += libLLVM
LOCAL_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
LOCAL_SRC_FILES := $$(LIBART_DISASSEMBLER_SRC_FILES)
ifeq ($$(art_target_or_host),target)
- LOCAL_CLANG := $(ART_TARGET_CLANG)
- LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
+ $(call set-target-local-clang-vars)
+ $(call set-target-local-cflags-vars,$(2))
else # host
LOCAL_CLANG := $(ART_HOST_CLANG)
LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
+ ifeq ($$(art_ndebug_or_debug),debug)
+ LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
+ else
+ LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
+ endif
endif
LOCAL_SHARED_LIBRARIES += liblog
ifeq ($$(art_ndebug_or_debug),debug)
- ifeq ($$(art_target_or_host),target)
- LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
- else # host
- LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
- endif
LOCAL_SHARED_LIBRARIES += libartd
else
- ifeq ($$(art_target_or_host),target)
- LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
- else # host
- LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
- endif
LOCAL_SHARED_LIBRARIES += libart
endif
# $(1): target or host
# $(2): ndebug or debug
-# $(3): true or false for LOCAL_CLANG
define build-libart
ifneq ($(1),target)
ifneq ($(1),host)
$$(error expected ndebug or debug for argument 2, received $(2))
endif
endif
- ifneq ($(3),true)
- ifneq ($(3),false)
- $$(error expected true or false for argument 3, received $(3))
- endif
- endif
art_target_or_host := $(1)
art_ndebug_or_debug := $(2)
- art_clang := $(3)
include $(CLEAR_VARS)
LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
$(foreach arch,$(ART_SUPPORTED_ARCH),
LOCAL_LDFLAGS_$(arch) := $$(LIBART_TARGET_LDFLAGS_$(arch)))
- ifeq ($$(art_clang),false)
- LOCAL_SRC_FILES += $(LIBART_GCC_ONLY_SRC_FILES)
- else
- LOCAL_CLANG := true
- endif
+ # Clang usage
ifeq ($$(art_target_or_host),target)
- LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
+ $(call set-target-local-clang-vars)
+ $(call set-target-local-cflags-vars,$(2))
+ # TODO: Loop with ifeq, ART_TARGET_CLANG
+ ifneq ($$(ART_TARGET_CLANG_$(TARGET_ARCH)),true)
+ LOCAL_SRC_FILES_$(TARGET_ARCH) += $(LIBART_GCC_ONLY_SRC_FILES)
+ endif
+ ifneq ($$(ART_TARGET_CLANG_$(TARGET_2ND_ARCH)),true)
+ LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) += $(LIBART_GCC_ONLY_SRC_FILES)
+ endif
else # host
+ LOCAL_CLANG := $(ART_HOST_CLANG)
+ ifeq ($(ART_HOST_CLANG),false)
+ LOCAL_SRC_FILES += $(LIBART_GCC_ONLY_SRC_FILES)
+ endif
LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
- endif
- ifeq ($$(art_ndebug_or_debug),debug)
- ifeq ($$(art_target_or_host),target)
- LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
- else # host
+ ifeq ($$(art_ndebug_or_debug),debug)
LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
LOCAL_LDLIBS += $(ART_HOST_DEBUG_LDLIBS)
LOCAL_STATIC_LIBRARIES := libgtest_host
- endif
- else
- ifeq ($$(art_target_or_host),target)
- LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
- else # host
+ else
LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
endif
endif
+
LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
LOCAL_C_INCLUDES += art/sigchainlib
# they are used to cross compile for the target.
ifeq ($(WITH_HOST_DALVIK),true)
ifeq ($(ART_BUILD_NDEBUG),true)
- $(eval $(call build-libart,host,ndebug,$(ART_HOST_CLANG)))
+ $(eval $(call build-libart,host,ndebug))
endif
ifeq ($(ART_BUILD_DEBUG),true)
- $(eval $(call build-libart,host,debug,$(ART_HOST_CLANG)))
+ $(eval $(call build-libart,host,debug))
endif
endif
ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
- $(eval $(call build-libart,target,ndebug,$(ART_TARGET_CLANG)))
+ $(eval $(call build-libart,target,ndebug))
endif
ifeq ($(ART_BUILD_TARGET_DEBUG),true)
- $(eval $(call build-libart,target,debug,$(ART_TARGET_CLANG)))
+ $(eval $(call build-libart,target,debug))
endif