2012-01-12 23:09:06 +08:00
|
|
|
CLANG := $(HOST_OUT_EXECUTABLES)/clang$(HOST_EXECUTABLE_SUFFIX)
|
2012-03-20 22:00:16 +08:00
|
|
|
CLANG_CXX := $(HOST_OUT_EXECUTABLES)/clang++$(HOST_EXECUTABLE_SUFFIX)
|
2012-05-09 09:43:48 +08:00
|
|
|
LLVM_AS := $(HOST_OUT_EXECUTABLES)/llvm-as$(HOST_EXECUTABLE_SUFFIX)
|
2012-01-12 23:09:06 +08:00
|
|
|
LLVM_LINK := $(HOST_OUT_EXECUTABLES)/llvm-link$(HOST_EXECUTABLE_SUFFIX)
|
|
|
|
|
|
|
|
define do-clang-flags-subst
|
|
|
|
TARGET_GLOBAL_CLANG_FLAGS := $(subst $(1),$(2),$(TARGET_GLOBAL_CLANG_FLAGS))
|
|
|
|
HOST_GLOBAL_CLANG_FLAGS := $(subst $(1),$(2),$(HOST_GLOBAL_CLANG_FLAGS))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define clang-flags-subst
|
|
|
|
$(eval $(call do-clang-flags-subst,$(1),$(2)))
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2012-03-20 22:00:16 +08:00
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS := \
|
|
|
|
-D__compiler_offsetof=__builtin_offsetof \
|
|
|
|
|
2012-01-12 23:09:06 +08:00
|
|
|
CLANG_CONFIG_UNKNOWN_CFLAGS := \
|
2012-03-20 22:00:16 +08:00
|
|
|
-funswitch-loops
|
|
|
|
|
|
|
|
ifeq ($(TARGET_ARCH),arm)
|
2013-03-06 03:07:15 +08:00
|
|
|
RS_TRIPLE := armv7-unknown-linux
|
2012-08-21 19:45:56 +08:00
|
|
|
CLANG_CONFIG_EXTRA_ASFLAGS += \
|
2012-03-20 22:00:16 +08:00
|
|
|
-target arm-linux-androideabi \
|
2012-03-26 18:15:47 +08:00
|
|
|
-nostdlibinc \
|
2012-08-21 19:45:56 +08:00
|
|
|
-B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin
|
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += \
|
|
|
|
$(CLANG_CONFIG_EXTRA_ASFLAGS) \
|
2012-03-20 22:00:16 +08:00
|
|
|
-mllvm -arm-enable-ehabi
|
|
|
|
CLANG_CONFIG_EXTRA_LDFLAGS += \
|
|
|
|
-target arm-linux-androideabi \
|
|
|
|
-B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin
|
|
|
|
CLANG_CONFIG_UNKNOWN_CFLAGS += \
|
|
|
|
-mthumb-interwork \
|
|
|
|
-fgcse-after-reload \
|
|
|
|
-frerun-cse-after-loop \
|
|
|
|
-frename-registers \
|
2012-04-05 15:44:37 +08:00
|
|
|
-fno-builtin-sin \
|
|
|
|
-fno-strict-volatile-bitfields \
|
|
|
|
-fno-align-jumps \
|
2012-03-20 22:00:16 +08:00
|
|
|
-Wa,--noexecstack
|
|
|
|
endif
|
2012-08-16 08:53:29 +08:00
|
|
|
ifeq ($(TARGET_ARCH),mips)
|
2013-03-09 01:02:52 +08:00
|
|
|
RS_TRIPLE := mipsel-unknown-linux
|
2012-08-21 19:45:56 +08:00
|
|
|
CLANG_CONFIG_EXTRA_ASFLAGS += \
|
2012-08-22 01:20:18 +08:00
|
|
|
-target mipsel-linux-androideabi \
|
2012-08-16 08:53:29 +08:00
|
|
|
-nostdlibinc \
|
|
|
|
-B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin
|
2012-08-21 19:45:56 +08:00
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
|
2012-08-16 08:53:29 +08:00
|
|
|
CLANG_CONFIG_EXTRA_LDFLAGS += \
|
2012-08-22 01:20:18 +08:00
|
|
|
-target mipsel-linux-androideabi \
|
2012-08-16 08:53:29 +08:00
|
|
|
-B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin
|
|
|
|
CLANG_CONFIG_UNKNOWN_CFLAGS += \
|
|
|
|
-EL \
|
2012-10-06 04:26:19 +08:00
|
|
|
-mips32 \
|
2012-08-16 08:53:29 +08:00
|
|
|
-mips32r2 \
|
|
|
|
-mhard-float \
|
|
|
|
-fno-strict-volatile-bitfields \
|
|
|
|
-fgcse-after-reload \
|
|
|
|
-frerun-cse-after-loop \
|
|
|
|
-frename-registers \
|
|
|
|
-march=mips32r2 \
|
2012-10-06 04:26:19 +08:00
|
|
|
-mtune=mips32r2 \
|
|
|
|
-march=mips32 \
|
2013-02-08 08:07:01 +08:00
|
|
|
-mtune=mips32 \
|
|
|
|
-msynci
|
2012-08-16 08:53:29 +08:00
|
|
|
endif
|
2012-03-20 22:00:16 +08:00
|
|
|
ifeq ($(TARGET_ARCH),x86)
|
2013-03-06 03:07:15 +08:00
|
|
|
RS_TRIPLE := i686-unknown-linux
|
2012-08-21 19:45:56 +08:00
|
|
|
CLANG_CONFIG_EXTRA_ASFLAGS += \
|
2012-05-17 04:18:39 +08:00
|
|
|
-target i686-linux-android \
|
2012-03-26 18:15:47 +08:00
|
|
|
-nostdlibinc \
|
2012-05-17 04:18:39 +08:00
|
|
|
-B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin
|
2012-08-21 19:45:56 +08:00
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
|
2012-03-20 22:00:16 +08:00
|
|
|
CLANG_CONFIG_EXTRA_LDFLAGS += \
|
2012-05-17 04:18:39 +08:00
|
|
|
-target i686-linux-android \
|
|
|
|
-B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin
|
2012-03-20 22:00:16 +08:00
|
|
|
CLANG_CONFIG_UNKNOWN_CFLAGS += \
|
|
|
|
-finline-limit=300 \
|
|
|
|
-fno-inline-functions-called-once \
|
|
|
|
-mfpmath=sse \
|
|
|
|
-mbionic
|
|
|
|
endif
|
|
|
|
|
2012-04-05 15:44:37 +08:00
|
|
|
CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := external/clang/lib/include $(TARGET_OUT_HEADERS)/clang
|
2012-01-12 23:09:06 +08:00
|
|
|
|
|
|
|
# remove unknown flags to define CLANG_FLAGS
|
|
|
|
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))
|
|
|
|
|
2012-04-05 15:44:37 +08:00
|
|
|
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))
|
|
|
|
|
2012-01-12 23:09:06 +08:00
|
|
|
# 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)
|
2012-03-30 16:15:12 +08:00
|
|
|
|
2012-08-03 20:17:23 +08:00
|
|
|
# clang does not support -Wno-psabi and -Wno-unused-but-set-variable
|
|
|
|
$(call clang-flags-subst,-Wno-psabi,)
|
|
|
|
$(call clang-flags-subst,-Wno-unused-but-set-variable,)
|
|
|
|
|
2013-01-15 05:45:45 +08:00
|
|
|
# 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)
|
|
|
|
|
2013-01-27 17:44:37 +08:00
|
|
|
ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address
|
2012-03-30 16:15:12 +08:00
|
|
|
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
|
|
|
|
ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload
|
|
|
|
ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
|
2012-06-12 05:53:34 +08:00
|
|
|
|
|
|
|
# This allows us to use the superset of functionality that compiler-rt
|
|
|
|
# provides to Clang (for supporting features like -ftrapv).
|
2013-01-27 17:45:59 +08:00
|
|
|
COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
|