1 CLANG := $(HOST_OUT_EXECUTABLES)/clang$(HOST_EXECUTABLE_SUFFIX) 2 CLANG_CXX := $(HOST_OUT_EXECUTABLES)/clang++$(HOST_EXECUTABLE_SUFFIX) 3 LLVM_AS := $(HOST_OUT_EXECUTABLES)/llvm-as$(HOST_EXECUTABLE_SUFFIX) 4 LLVM_LINK := $(HOST_OUT_EXECUTABLES)/llvm-link$(HOST_EXECUTABLE_SUFFIX) 5 6 define do-clang-flags-subst 7 TARGET_GLOBAL_CLANG_FLAGS := $(subst $(1),$(2),$(TARGET_GLOBAL_CLANG_FLAGS)) 8 HOST_GLOBAL_CLANG_FLAGS := $(subst $(1),$(2),$(HOST_GLOBAL_CLANG_FLAGS)) 9 endef 10 11 define clang-flags-subst 12 $(eval $(call do-clang-flags-subst,$(1),$(2))) 13 endef 14 15 16 CLANG_CONFIG_EXTRA_CFLAGS := \ 17 -D__compiler_offsetof=__builtin_offsetof \ 18 19 CLANG_CONFIG_UNKNOWN_CFLAGS := \ 20 -funswitch-loops 21 22 ifeq ($(TARGET_ARCH),arm) 23 RS_TRIPLE := armv7-none-linux-gnueabi 24 CLANG_CONFIG_EXTRA_ASFLAGS += \ 25 -target arm-linux-androideabi \ 26 -nostdlibinc \ 27 -B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin 28 CLANG_CONFIG_EXTRA_CFLAGS += \ 29 $(CLANG_CONFIG_EXTRA_ASFLAGS) \ 30 -mllvm -arm-enable-ehabi 31 CLANG_CONFIG_EXTRA_LDFLAGS += \ 32 -target arm-linux-androideabi \ 33 -B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin 34 CLANG_CONFIG_UNKNOWN_CFLAGS += \ 35 -mthumb-interwork \ 36 -fgcse-after-reload \ 37 -frerun-cse-after-loop \ 38 -frename-registers \ 39 -fno-builtin-sin \ 40 -fno-strict-volatile-bitfields \ 41 -fno-align-jumps \ 42 -Wa,--noexecstack 43 endif 44 ifeq ($(TARGET_ARCH),mips) 45 RS_TRIPLE := mipsel-unknown-linux 46 CLANG_CONFIG_EXTRA_ASFLAGS += \ 47 -target mipsel-linux-androideabi \ 48 -nostdlibinc \ 49 -B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin 50 CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS) 51 CLANG_CONFIG_EXTRA_LDFLAGS += \ 52 -target mipsel-linux-androideabi \ 53 -B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin 54 CLANG_CONFIG_UNKNOWN_CFLAGS += \ 55 -EL \ 56 -mips32 \ 57 -mips32r2 \ 58 -mhard-float \ 59 -fno-strict-volatile-bitfields \ 60 -fgcse-after-reload \ 61 -frerun-cse-after-loop \ 62 -frename-registers \ 63 -march=mips32r2 \ 64 -mtune=mips32r2 \ 65 -march=mips32 \ 66 -mtune=mips32 \ 67 -msynci \ 68 -mno-fused-madd 69 endif 70 ifeq ($(TARGET_ARCH),x86) 71 RS_TRIPLE := i686-unknown-linux 72 CLANG_CONFIG_EXTRA_ASFLAGS += \ 73 -target i686-linux-android \ 74 -nostdlibinc \ 75 -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin 76 CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS) 77 CLANG_CONFIG_EXTRA_LDFLAGS += \ 78 -target i686-linux-android \ 79 -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin 80 CLANG_CONFIG_UNKNOWN_CFLAGS += \ 81 -finline-limit=300 \ 82 -fno-inline-functions-called-once \ 83 -mfpmath=sse \ 84 -mbionic 85 endif 86 87 CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := external/clang/lib/include $(TARGET_OUT_HEADERS)/clang 88 89 # remove unknown flags to define CLANG_FLAGS 90 TARGET_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_GLOBAL_CFLAGS)) 91 HOST_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(HOST_GLOBAL_CFLAGS)) 92 93 TARGET_arm_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_arm_CFLAGS)) 94 TARGET_thumb_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_thumb_CFLAGS)) 95 96 # llvm does not yet support -march=armv5e nor -march=armv5te, fall back to armv5 or armv5t 97 $(call clang-flags-subst,-march=armv5te,-march=armv5t) 98 $(call clang-flags-subst,-march=armv5e,-march=armv5) 99 100 # clang does not support -Wno-psabi and -Wno-unused-but-set-variable 101 $(call clang-flags-subst,-Wno-psabi,) 102 $(call clang-flags-subst,-Wno-unused-but-set-variable,) 103 104 # clang does not support -mcpu=cortex-a15 yet - fall back to armv7-a for now 105 $(call clang-flags-subst,-mcpu=cortex-a15,-march=armv7-a) 106 107 ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address 108 ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit 109 ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload 110 ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan 111 112 # This allows us to use the superset of functionality that compiler-rt 113 # provides to Clang (for supporting features like -ftrapv). 114 COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras 115