Allow clang to build host binaries.
Change-Id: I7e4f9dc6f69a97cfefdfa2ed55c5d7b8ad496da7
This commit is contained in:
@@ -118,9 +118,6 @@ endif
|
|||||||
|
|
||||||
my_compiler_dependencies :=
|
my_compiler_dependencies :=
|
||||||
ifeq ($(strip $(LOCAL_CLANG)),true)
|
ifeq ($(strip $(LOCAL_CLANG)),true)
|
||||||
LOCAL_CFLAGS += $(CLANG_CONFIG_EXTRA_CFLAGS)
|
|
||||||
LOCAL_ASFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
|
|
||||||
LOCAL_LDFLAGS += $(CLANG_CONFIG_EXTRA_LDFLAGS)
|
|
||||||
my_compiler_dependencies := $(CLANG) $(CLANG_CXX)
|
my_compiler_dependencies := $(CLANG) $(CLANG_CXX)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -162,16 +159,40 @@ my_target_c_includes := $(TARGET_C_INCLUDES)
|
|||||||
endif # LOCAL_SDK_VERSION
|
endif # LOCAL_SDK_VERSION
|
||||||
|
|
||||||
ifeq ($(LOCAL_CLANG),true)
|
ifeq ($(LOCAL_CLANG),true)
|
||||||
my_target_global_cflags := $(TARGET_GLOBAL_CLANG_FLAGS)
|
my_target_global_cflags := $(CLANG_TARGET_GLOBAL_CFLAGS)
|
||||||
|
my_target_global_cppflags := $(CLANG_TARGET_GLOBAL_CPPFLAGS)
|
||||||
|
my_target_global_ldflags := $(CLANG_TARGET_GLOBAL_LDFLAGS)
|
||||||
my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
|
my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
|
||||||
else
|
else
|
||||||
my_target_global_cflags := $(TARGET_GLOBAL_CFLAGS)
|
my_target_global_cflags := $(TARGET_GLOBAL_CFLAGS)
|
||||||
|
my_target_global_cppflags := $(TARGET_GLOBAL_CPPFLAGS)
|
||||||
|
my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
|
||||||
endif # LOCAL_CLANG
|
endif # LOCAL_CLANG
|
||||||
|
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(TARGET_GLOBAL_CPPFLAGS)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
|
||||||
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
|
||||||
|
|
||||||
|
ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
|
||||||
|
ifeq ($(LOCAL_CLANG),true)
|
||||||
|
my_host_global_cflags := $(CLANG_HOST_GLOBAL_CFLAGS)
|
||||||
|
my_host_global_cppflags := $(CLANG_HOST_GLOBAL_CPPFLAGS)
|
||||||
|
my_host_global_ldflags := $(CLANG_HOST_GLOBAL_LDFLAGS)
|
||||||
|
my_host_c_includes := $(HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES)
|
||||||
|
else
|
||||||
|
my_host_global_cflags := $(HOST_GLOBAL_CFLAGS)
|
||||||
|
my_host_global_cppflags := $(HOST_GLOBAL_CPPFLAGS)
|
||||||
|
my_host_global_ldflags := $(HOST_GLOBAL_LDFLAGS)
|
||||||
|
my_host_c_includes := $(HOST_C_INCLUDES)
|
||||||
|
endif # LOCAL_CLANG
|
||||||
|
|
||||||
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
|
||||||
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
|
||||||
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
|
||||||
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
|
||||||
|
endif # LOCAL_IS_HOST_MODULE
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
## Define PRIVATE_ variables used by multiple module types
|
## Define PRIVATE_ variables used by multiple module types
|
||||||
@@ -257,12 +278,11 @@ normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
|
|||||||
# Read the values from something like TARGET_arm_CFLAGS or
|
# Read the values from something like TARGET_arm_CFLAGS or
|
||||||
# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
|
# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
|
||||||
# actually used (although they are usually empty).
|
# actually used (although they are usually empty).
|
||||||
ifeq ($(strip $(LOCAL_CLANG)),true)
|
|
||||||
arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CLANG_CFLAGS)
|
|
||||||
normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CLANG_CFLAGS)
|
|
||||||
else
|
|
||||||
arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS)
|
arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS)
|
||||||
normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS)
|
normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS)
|
||||||
|
ifeq ($(strip $(LOCAL_CLANG)),true)
|
||||||
|
arm_objects_cflags := $(call convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
|
||||||
|
normal_objects_cflags := $(call convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -751,6 +771,14 @@ endif
|
|||||||
###########################################################
|
###########################################################
|
||||||
# Rule-specific variable definitions
|
# Rule-specific variable definitions
|
||||||
###########################################################
|
###########################################################
|
||||||
|
|
||||||
|
ifeq ($(LOCAL_CLANG),true)
|
||||||
|
LOCAL_CFLAGS := $(call convert-to-$(my_host)clang-flags,$(LOCAL_CFLAGS))
|
||||||
|
LOCAL_CPPFLAGS := $(call convert-to-$(my_host)clang-flags,$(LOCAL_CPPFLAGS))
|
||||||
|
LOCAL_ASFLAGS := $(call convert-to-$(my_host)clang-flags,$(LOCAL_ASFLAGS))
|
||||||
|
LOCAL_LDFLAGS := $(call convert-to-$(my_host)clang-flags,$(LOCAL_LDFLAGS))
|
||||||
|
endif
|
||||||
|
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS)
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
|
||||||
|
@@ -1032,11 +1032,11 @@ $(hide) $(PRIVATE_CXX) \
|
|||||||
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
||||||
$(filter-out $(PRIVATE_C_INCLUDES), \
|
$(filter-out $(PRIVATE_C_INCLUDES), \
|
||||||
$(HOST_PROJECT_INCLUDES) \
|
$(HOST_PROJECT_INCLUDES) \
|
||||||
$(HOST_C_INCLUDES)))) \
|
$(PRIVATE_HOST_C_INCLUDES)))) \
|
||||||
-c \
|
-c \
|
||||||
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
||||||
$(HOST_GLOBAL_CFLAGS) \
|
$(PRIVATE_HOST_GLOBAL_CFLAGS) \
|
||||||
$(HOST_GLOBAL_CPPFLAGS) \
|
$(PRIVATE_HOST_GLOBAL_CPPFLAGS) \
|
||||||
) \
|
) \
|
||||||
$(PRIVATE_CFLAGS) \
|
$(PRIVATE_CFLAGS) \
|
||||||
$(PRIVATE_CPPFLAGS) \
|
$(PRIVATE_CPPFLAGS) \
|
||||||
@@ -1060,10 +1060,10 @@ $(hide) $(PRIVATE_CC) \
|
|||||||
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
||||||
$(filter-out $(PRIVATE_C_INCLUDES), \
|
$(filter-out $(PRIVATE_C_INCLUDES), \
|
||||||
$(HOST_PROJECT_INCLUDES) \
|
$(HOST_PROJECT_INCLUDES) \
|
||||||
$(HOST_C_INCLUDES)))) \
|
$(PRIVATE_HOST_C_INCLUDES)))) \
|
||||||
-c \
|
-c \
|
||||||
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
||||||
$(HOST_GLOBAL_CFLAGS) \
|
$(PRIVATE_HOST_GLOBAL_CFLAGS) \
|
||||||
) \
|
) \
|
||||||
$(1) \
|
$(1) \
|
||||||
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
||||||
@@ -1207,7 +1207,7 @@ $(hide) $(PRIVATE_CXX) \
|
|||||||
$(PRIVATE_LDFLAGS) \
|
$(PRIVATE_LDFLAGS) \
|
||||||
$(HOST_GLOBAL_LD_DIRS) \
|
$(HOST_GLOBAL_LD_DIRS) \
|
||||||
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
||||||
$(HOST_GLOBAL_LDFLAGS) \
|
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
|
||||||
) \
|
) \
|
||||||
$(PRIVATE_ALL_OBJECTS) \
|
$(PRIVATE_ALL_OBJECTS) \
|
||||||
-Wl,--whole-archive \
|
-Wl,--whole-archive \
|
||||||
@@ -1367,7 +1367,7 @@ $(hide) $(PRIVATE_CXX) \
|
|||||||
$(HOST_GLOBAL_LD_DIRS) \
|
$(HOST_GLOBAL_LD_DIRS) \
|
||||||
$(PRIVATE_LDFLAGS) \
|
$(PRIVATE_LDFLAGS) \
|
||||||
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
||||||
$(HOST_GLOBAL_LDFLAGS) \
|
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
|
||||||
-fPIE -pie \
|
-fPIE -pie \
|
||||||
) \
|
) \
|
||||||
-o $@ \
|
-o $@ \
|
||||||
|
@@ -39,7 +39,11 @@ include $(BUILD_SYSTEM)/dynamic_binary.mk
|
|||||||
|
|
||||||
# Define PRIVATE_ variables from global vars
|
# Define PRIVATE_ variables from global vars
|
||||||
my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS)
|
my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS)
|
||||||
|
ifeq ($(LOCAL_CLANG),true)
|
||||||
|
my_target_global_ldflags := $(CLANG_TARGET_GLOBAL_LDFLAGS)
|
||||||
|
else
|
||||||
my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
|
my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
|
||||||
|
endif
|
||||||
my_target_fdo_lib := $(TARGET_FDO_LIB)
|
my_target_fdo_lib := $(TARGET_FDO_LIB)
|
||||||
my_target_libgcc := $(TARGET_LIBGCC)
|
my_target_libgcc := $(TARGET_LIBGCC)
|
||||||
my_target_crtbegin_dynamic_o := $(TARGET_CRTBEGIN_DYNAMIC_O)
|
my_target_crtbegin_dynamic_o := $(TARGET_CRTBEGIN_DYNAMIC_O)
|
||||||
|
@@ -3,35 +3,39 @@ CLANG_CXX := $(HOST_OUT_EXECUTABLES)/clang++$(HOST_EXECUTABLE_SUFFIX)
|
|||||||
LLVM_AS := $(HOST_OUT_EXECUTABLES)/llvm-as$(HOST_EXECUTABLE_SUFFIX)
|
LLVM_AS := $(HOST_OUT_EXECUTABLES)/llvm-as$(HOST_EXECUTABLE_SUFFIX)
|
||||||
LLVM_LINK := $(HOST_OUT_EXECUTABLES)/llvm-link$(HOST_EXECUTABLE_SUFFIX)
|
LLVM_LINK := $(HOST_OUT_EXECUTABLES)/llvm-link$(HOST_EXECUTABLE_SUFFIX)
|
||||||
|
|
||||||
define do-clang-flags-subst
|
# Clang flags for all host or target rules
|
||||||
TARGET_GLOBAL_CLANG_FLAGS := $(subst $(1),$(2),$(TARGET_GLOBAL_CLANG_FLAGS))
|
CLANG_CONFIG_EXTRA_ASFLAGS :=
|
||||||
HOST_GLOBAL_CLANG_FLAGS := $(subst $(1),$(2),$(HOST_GLOBAL_CLANG_FLAGS))
|
CLANG_CONFIG_EXTRA_CPPFLAGS :=
|
||||||
endef
|
CLANG_CONFIG_EXTRA_LDFLAGS :=
|
||||||
|
|
||||||
define clang-flags-subst
|
|
||||||
$(eval $(call do-clang-flags-subst,$(1),$(2)))
|
|
||||||
endef
|
|
||||||
|
|
||||||
|
|
||||||
CLANG_CONFIG_EXTRA_CFLAGS := \
|
CLANG_CONFIG_EXTRA_CFLAGS := \
|
||||||
-D__compiler_offsetof=__builtin_offsetof \
|
-D__compiler_offsetof=__builtin_offsetof
|
||||||
|
|
||||||
CLANG_CONFIG_UNKNOWN_CFLAGS := \
|
CLANG_CONFIG_UNKNOWN_CFLAGS := \
|
||||||
-funswitch-loops
|
-funswitch-loops \
|
||||||
|
-Wno-psabi \
|
||||||
|
-Wno-unused-but-set-variable \
|
||||||
|
-Wno-unused-but-set-parameter
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH),arm)
|
# Clang flags for all host rules
|
||||||
RS_TRIPLE := armv7-none-linux-gnueabi
|
CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
|
||||||
CLANG_CONFIG_EXTRA_ASFLAGS += \
|
CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
|
||||||
-target arm-linux-androideabi \
|
CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
|
||||||
-nostdlibinc \
|
CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
|
||||||
-B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin
|
|
||||||
CLANG_CONFIG_EXTRA_CFLAGS += \
|
# Clang flags for all target rules
|
||||||
$(CLANG_CONFIG_EXTRA_ASFLAGS) \
|
CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
|
||||||
|
CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
|
||||||
|
CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
|
||||||
|
CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
|
||||||
|
|
||||||
|
# ARM
|
||||||
|
llvm_arch := arm
|
||||||
|
CLANG_CONFIG_arm_EXTRA_ASFLAGS :=
|
||||||
|
CLANG_CONFIG_arm_EXTRA_CFLAGS := \
|
||||||
-mllvm -arm-enable-ehabi
|
-mllvm -arm-enable-ehabi
|
||||||
CLANG_CONFIG_EXTRA_LDFLAGS += \
|
CLANG_CONFIG_arm_EXTRA_LDFLAGS :=
|
||||||
-target arm-linux-androideabi \
|
CLANG_CONFIG_arm_UNKNOWN_CFLAGS := \
|
||||||
-B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin
|
|
||||||
CLANG_CONFIG_UNKNOWN_CFLAGS += \
|
|
||||||
-mthumb-interwork \
|
-mthumb-interwork \
|
||||||
-fgcse-after-reload \
|
-fgcse-after-reload \
|
||||||
-frerun-cse-after-loop \
|
-frerun-cse-after-loop \
|
||||||
@@ -40,18 +44,18 @@ ifeq ($(TARGET_ARCH),arm)
|
|||||||
-fno-strict-volatile-bitfields \
|
-fno-strict-volatile-bitfields \
|
||||||
-fno-align-jumps \
|
-fno-align-jumps \
|
||||||
-Wa,--noexecstack
|
-Wa,--noexecstack
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_ARCH),mips)
|
CLANG_CONFIG_arm_HOST_TRIPLE :=
|
||||||
RS_TRIPLE := mipsel-unknown-linux
|
CLANG_CONFIG_arm_TARGET_TRIPLE := arm-linux-androideabi
|
||||||
CLANG_CONFIG_EXTRA_ASFLAGS += \
|
|
||||||
-target mipsel-linux-androideabi \
|
include $(BUILD_SYSTEM)/llvm_config_define_clang_flags.mk
|
||||||
-nostdlibinc \
|
|
||||||
-B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin
|
# MIPS
|
||||||
CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
|
llvm_arch := mips
|
||||||
CLANG_CONFIG_EXTRA_LDFLAGS += \
|
CLANG_CONFIG_mips_EXTRA_ASFLAGS :=
|
||||||
-target mipsel-linux-androideabi \
|
CLANG_CONFIG_mips_EXTRA_CFLAGS :=
|
||||||
-B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin
|
CLANG_CONFIG_mips_EXTRA_LDFLAGS :=
|
||||||
CLANG_CONFIG_UNKNOWN_CFLAGS += \
|
CLANG_CONFIG_mips_UNKNOWN_CFLAGS := \
|
||||||
-EL \
|
-EL \
|
||||||
-mips32 \
|
-mips32 \
|
||||||
-mips32r2 \
|
-mips32r2 \
|
||||||
@@ -66,64 +70,69 @@ ifeq ($(TARGET_ARCH),mips)
|
|||||||
-mtune=mips32 \
|
-mtune=mips32 \
|
||||||
-msynci \
|
-msynci \
|
||||||
-mno-fused-madd
|
-mno-fused-madd
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_ARCH),x86)
|
CLANG_CONFIG_mips_HOST_TRIPLE :=
|
||||||
RS_TRIPLE := i686-unknown-linux
|
CLANG_CONFIG_mips_TARGET_TRIPLE := mipsel-linux-android
|
||||||
CLANG_CONFIG_EXTRA_ASFLAGS += \
|
|
||||||
-target i686-linux-android \
|
include $(BUILD_SYSTEM)/llvm_config_define_clang_flags.mk
|
||||||
-msse3 \
|
|
||||||
-nostdlibinc \
|
# X86
|
||||||
-B$(TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin
|
llvm_arch := x86
|
||||||
CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
|
CLANG_CONFIG_x86_EXTRA_ASFLAGS := \
|
||||||
CLANG_CONFIG_EXTRA_LDFLAGS += \
|
-msse3
|
||||||
-target i686-linux-android \
|
CLANG_CONFIG_x86_EXTRA_CFLAGS :=
|
||||||
-B$(TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin
|
CLANG_CONFIG_x86_EXTRA_LDFLAGS :=
|
||||||
CLANG_CONFIG_UNKNOWN_CFLAGS += \
|
CLANG_CONFIG_x86_UNKNOWN_CFLAGS := \
|
||||||
-finline-limit=300 \
|
-finline-limit=300 \
|
||||||
-fno-inline-functions-called-once \
|
-fno-inline-functions-called-once \
|
||||||
-mfpmath=sse \
|
-mfpmath=sse \
|
||||||
-mbionic
|
-mbionic
|
||||||
|
|
||||||
|
ifeq ($(HOST_OS),linux)
|
||||||
|
CLANG_CONFIG_x86_HOST_TRIPLE := i686-linux-gnu
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGET_ARCH),x86_64)
|
ifeq ($(HOST_OS),darwin)
|
||||||
RS_TRIPLE := x86_64-unknown-linux
|
CLANG_CONFIG_x86_HOST_TRIPLE := i686-apple-darwin
|
||||||
CLANG_CONFIG_EXTRA_ASFLAGS += \
|
endif
|
||||||
-target x86_64-linux-android \
|
ifeq ($(HOST_OS),windows)
|
||||||
-nostdlibinc \
|
CLANG_CONFIG_x86_HOST_TRIPLE := i686-pc-mingw32
|
||||||
-B$(TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin
|
endif
|
||||||
CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
|
|
||||||
CLANG_CONFIG_EXTRA_LDFLAGS += \
|
CLANG_CONFIG_x86_TARGET_TRIPLE := i686-linux-android
|
||||||
-target x86_64-linux-android \
|
CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX := \
|
||||||
-B$(TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin
|
$(TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin
|
||||||
CLANG_CONFIG_UNKNOWN_CFLAGS += \
|
|
||||||
|
include $(BUILD_SYSTEM)/llvm_config_define_clang_flags.mk
|
||||||
|
|
||||||
|
# X86_64
|
||||||
|
llvm_arch := x86_64
|
||||||
|
CLANG_CONFIG_x86_64_EXTRA_ASFLAGS := \
|
||||||
|
CLANG_CONFIG_x86_64_EXTRA_CFLAGS :=
|
||||||
|
CLANG_CONFIG_x86_64_EXTRA_LDFLAGS := \
|
||||||
|
CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS := \
|
||||||
-finline-limit=300 \
|
-finline-limit=300 \
|
||||||
-fno-inline-functions-called-once \
|
-fno-inline-functions-called-once \
|
||||||
-mfpmath=sse \
|
-mfpmath=sse \
|
||||||
-mbionic
|
-mbionic
|
||||||
|
|
||||||
|
ifeq ($(HOST_OS),linux)
|
||||||
|
CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-linux-gnu
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(HOST_OS),darwin)
|
||||||
|
CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-apple-darwin
|
||||||
|
endif
|
||||||
|
ifeq ($(HOST_OS),windows)
|
||||||
|
CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-pc-mingw64
|
||||||
|
endif
|
||||||
|
CLANG_CONFIG_x86_64_TARGET_TRIPLE := x86_64-linux-android
|
||||||
|
|
||||||
|
include $(BUILD_SYSTEM)/llvm_config_define_clang_flags.mk
|
||||||
|
|
||||||
|
# Clang compiler-specific libc headers
|
||||||
|
CLANG_CONFIG_EXTRA_HOST_C_INCLUDES := external/clang/lib/include
|
||||||
CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := external/clang/lib/include $(TARGET_OUT_HEADERS)/clang
|
CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := external/clang/lib/include $(TARGET_OUT_HEADERS)/clang
|
||||||
|
|
||||||
# remove unknown flags to define CLANG_FLAGS
|
# Address sanitizer clang config
|
||||||
TARGET_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_GLOBAL_CFLAGS))
|
|
||||||
HOST_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(HOST_GLOBAL_CFLAGS))
|
|
||||||
|
|
||||||
TARGET_arm_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_arm_CFLAGS))
|
|
||||||
TARGET_thumb_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_thumb_CFLAGS))
|
|
||||||
|
|
||||||
# llvm does not yet support -march=armv5e nor -march=armv5te, fall back to armv5 or armv5t
|
|
||||||
$(call clang-flags-subst,-march=armv5te,-march=armv5t)
|
|
||||||
$(call clang-flags-subst,-march=armv5e,-march=armv5)
|
|
||||||
|
|
||||||
# clang does not support -Wno-psabi, -Wno-unused-but-set-variable, and
|
|
||||||
# -Wno-unused-but-set-parameter
|
|
||||||
$(call clang-flags-subst,-Wno-psabi,)
|
|
||||||
$(call clang-flags-subst,-Wno-unused-but-set-variable,)
|
|
||||||
$(call clang-flags-subst,-Wno-unused-but-set-parameter,)
|
|
||||||
|
|
||||||
# clang does not support -mcpu=cortex-a15 yet - fall back to armv7-a for now
|
|
||||||
$(call clang-flags-subst,-mcpu=cortex-a15,-march=armv7-a)
|
|
||||||
|
|
||||||
ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address
|
ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address
|
||||||
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
|
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
|
||||||
ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload
|
ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload
|
||||||
@@ -132,3 +141,56 @@ ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
|
|||||||
# This allows us to use the superset of functionality that compiler-rt
|
# This allows us to use the superset of functionality that compiler-rt
|
||||||
# provides to Clang (for supporting features like -ftrapv).
|
# provides to Clang (for supporting features like -ftrapv).
|
||||||
COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
|
COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
|
||||||
|
|
||||||
|
# Macros to convert gcc flags to clang flags
|
||||||
|
define subst-clang-incompatible-flags
|
||||||
|
$(subst -march=armv5te,-march=armv5t,\
|
||||||
|
$(subst -march=armv5e,-march=armv5,\
|
||||||
|
$(subst -mcpu=cortex-a15,-march=armv7-a,\
|
||||||
|
$(1))))
|
||||||
|
endef
|
||||||
|
|
||||||
|
define convert-to-host-clang-flags
|
||||||
|
$(strip \
|
||||||
|
$(call subst-clang-incompatible-flags,\
|
||||||
|
$(filter-out $(CLANG_CONFIG_$(HOST_ARCH)_UNKNOWN_CFLAGS),\
|
||||||
|
$(1))))
|
||||||
|
endef
|
||||||
|
|
||||||
|
define convert-to-clang-flags
|
||||||
|
$(strip \
|
||||||
|
$(call subst-clang-incompatible-flags,\
|
||||||
|
$(filter-out $(CLANG_CONFIG_$(TARGET_ARCH)_UNKNOWN_CFLAGS),\
|
||||||
|
$(1))))
|
||||||
|
endef
|
||||||
|
|
||||||
|
# Define clang global flags
|
||||||
|
define get-clang-host-global-flags
|
||||||
|
$(call convert-to-host-clang-flags,$(HOST_GLOBAL_$(1))) $(CLANG_CONFIG_$(HOST_ARCH)_HOST_EXTRA_$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
|
define get-clang-global-flags
|
||||||
|
$(call convert-to-clang-flags,$(TARGET_GLOBAL_$(1))) $(CLANG_CONFIG_$(TARGET_ARCH)_TARGET_EXTRA_$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
|
CLANG_HOST_GLOBAL_CFLAGS := $(call get-clang-host-global-flags,CFLAGS)
|
||||||
|
CLANG_HOST_GLOBAL_CPPFLAGS := $(call get-clang-host-global-flags,CPPFLAGS)
|
||||||
|
CLANG_HOST_GLOBAL_LDFLAGS := $(call get-clang-host-global-flags,LDFLAGS)
|
||||||
|
|
||||||
|
CLANG_TARGET_GLOBAL_CFLAGS := $(call get-clang-global-flags,CFLAGS)
|
||||||
|
CLANG_TARGET_GLOBAL_CPPFLAGS := $(call get-clang-global-flags,CPPFLAGS)
|
||||||
|
CLANG_TARGET_GLOBAL_LDFLAGS := $(call get-clang-global-flags,LDFLAGS)
|
||||||
|
|
||||||
|
# Renderscript clang target triple
|
||||||
|
ifeq ($(TARGET_ARCH),arm)
|
||||||
|
RS_TRIPLE := armv7-none-linux-gnueabi
|
||||||
|
endif
|
||||||
|
ifeq ($(TARGET_ARCH),mips)
|
||||||
|
RS_TRIPLE := mipsel-unknown-linux
|
||||||
|
endif
|
||||||
|
ifeq ($(TARGET_ARCH),x86)
|
||||||
|
RS_TRIPLE := i686-unknown-linux
|
||||||
|
endif
|
||||||
|
ifeq ($(TARGET_ARCH),x86_64)
|
||||||
|
RS_TRIPLE := x86_64-unknown-linux
|
||||||
|
endif
|
||||||
|
76
core/llvm_config_define_clang_flags.mk
Normal file
76
core/llvm_config_define_clang_flags.mk
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
ifeq ($(strip $(llvm_arch)),)
|
||||||
|
$(error "$$(llvm_arch) should be defined.")
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(strip $(CLANG_CONFIG_$(llvm_arch)_TARGET_TRIPLE)),)
|
||||||
|
$(error "$$(CLANG_CONFIG_$(llvm_arch)_TARGET_TRIPLE) should be defined.")
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(strip $(CLANG_CONFIG_$(llvm_arch)_TARGET_TOOLCHAIN_PREFIX)),)
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_TARGET_TOOLCHAIN_PREFIX := \
|
||||||
|
$(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_$(llvm_arch)_TARGET_TRIPLE)/bin
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Include common unknown flags
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_UNKNOWN_CFLAGS += \
|
||||||
|
$(CLANG_CONFIG_UNKNOWN_CFLAGS)
|
||||||
|
|
||||||
|
# Clang extra flags for host
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_HOST_EXTRA_ASFLAGS := \
|
||||||
|
$(CLANG_CONFIG_EXTRA_ASFLAGS) \
|
||||||
|
$(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_EXTRA_ASFLAGS)
|
||||||
|
|
||||||
|
ifneq ($(strip $(CLANG_CONFIG_$(llvm_arch)_HOST_TRIPLE)),)
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_HOST_EXTRA_ASFLAGS += \
|
||||||
|
-target $(CLANG_CONFIG_$(llvm_arch)_HOST_TRIPLE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_HOST_EXTRA_CFLAGS := \
|
||||||
|
$(CLANG_CONFIG_EXTRA_CFLAGS) \
|
||||||
|
$(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_EXTRA_CFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_HOST_EXTRA_ASFLAGS)
|
||||||
|
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_HOST_EXTRA_CPPFLAGS := \
|
||||||
|
$(CLANG_CONFIG_EXTRA_CPPFLAGS) \
|
||||||
|
$(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_EXTRA_CPPFLAGS)
|
||||||
|
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_HOST_EXTRA_LDFLAGS := \
|
||||||
|
$(CLANG_CONFIG_EXTRA_LDFLAGS) \
|
||||||
|
$(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_EXTRA_LDFLAGS)
|
||||||
|
|
||||||
|
ifneq ($(strip $(CLANG_CONFIG_$(llvm_arch)_HOST_TRIPLE)),)
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_HOST_EXTRA_LDFLAGS += \
|
||||||
|
-target $(CLANG_CONFIG_$(llvm_arch)_HOST_TRIPLE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Clang extra flags for target
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_TARGET_EXTRA_ASFLAGS := \
|
||||||
|
$(CLANG_CONFIG_EXTRA_ASFLAGS) \
|
||||||
|
$(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_EXTRA_ASFLAGS) \
|
||||||
|
-target $(CLANG_CONFIG_$(llvm_arch)_TARGET_TRIPLE) \
|
||||||
|
-B$(CLANG_CONFIG_$(llvm_arch)_TARGET_TOOLCHAIN_PREFIX)
|
||||||
|
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_TARGET_EXTRA_CFLAGS := \
|
||||||
|
$(CLANG_CONFIG_EXTRA_CFLAGS) \
|
||||||
|
$(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_EXTRA_CFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_TARGET_EXTRA_ASFLAGS)
|
||||||
|
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_TARGET_EXTRA_CPPFLAGS := \
|
||||||
|
$(CLANG_CONFIG_EXTRA_CPPFLAGS) \
|
||||||
|
$(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_EXTRA_CPPFLAGS)
|
||||||
|
|
||||||
|
CLANG_CONFIG_$(llvm_arch)_TARGET_EXTRA_LDFLAGS := \
|
||||||
|
$(CLANG_CONFIG_EXTRA_LDFLAGS) \
|
||||||
|
$(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
|
||||||
|
$(CLANG_CONFIG_$(llvm_arch)_EXTRA_LDFLAGS) \
|
||||||
|
-target $(CLANG_CONFIG_$(llvm_arch)_TARGET_TRIPLE) \
|
||||||
|
-B$(CLANG_CONFIG_$(llvm_arch)_TARGET_TOOLCHAIN_PREFIX)
|
||||||
|
|
||||||
|
llvm_arch :=
|
@@ -52,7 +52,11 @@ include $(BUILD_SYSTEM)/dynamic_binary.mk
|
|||||||
|
|
||||||
# Define PRIVATE_ variables from global vars
|
# Define PRIVATE_ variables from global vars
|
||||||
my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS)
|
my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS)
|
||||||
|
ifeq ($(LOCAL_CLANG),true)
|
||||||
|
my_target_global_ldflags := $(CLANG_TARGET_GLOBAL_LDFLAGS)
|
||||||
|
else
|
||||||
my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
|
my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
|
||||||
|
endif
|
||||||
my_target_fdo_lib := $(TARGET_FDO_LIB)
|
my_target_fdo_lib := $(TARGET_FDO_LIB)
|
||||||
my_target_libgcc := $(TARGET_LIBGCC)
|
my_target_libgcc := $(TARGET_LIBGCC)
|
||||||
my_target_crtbegin_so_o := $(TARGET_CRTBEGIN_SO_O)
|
my_target_crtbegin_so_o := $(TARGET_CRTBEGIN_SO_O)
|
||||||
|
Reference in New Issue
Block a user