blob: c4b4af4ee4cb9e0fd4cb5b120531f6da4f5a2ce7 [file] [log] [blame]
yroussel13190052012-01-12 16:09:06 +01001CLANG := $(HOST_OUT_EXECUTABLES)/clang$(HOST_EXECUTABLE_SUFFIX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04002CLANG_CXX := $(HOST_OUT_EXECUTABLES)/clang++$(HOST_EXECUTABLE_SUFFIX)
Stephen Hines7e48e402012-05-08 18:43:48 -07003LLVM_AS := $(HOST_OUT_EXECUTABLES)/llvm-as$(HOST_EXECUTABLE_SUFFIX)
yroussel13190052012-01-12 16:09:06 +01004LLVM_LINK := $(HOST_OUT_EXECUTABLES)/llvm-link$(HOST_EXECUTABLE_SUFFIX)
5
6define 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))
9endef
10
11define clang-flags-subst
12 $(eval $(call do-clang-flags-subst,$(1),$(2)))
13endef
14
15
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040016CLANG_CONFIG_EXTRA_CFLAGS := \
17 -D__compiler_offsetof=__builtin_offsetof \
yroussel13190052012-01-12 16:09:06 +010018
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040019CLANG_CONFIG_UNKNOWN_CFLAGS := \
20 -funswitch-loops
21
22ifeq ($(TARGET_ARCH),arm)
Stephen Hines408733b2013-03-12 17:10:19 -070023 RS_TRIPLE := armv7-none-linux-gnueabi
Evgeniy Stepanove1d27e22012-08-21 15:45:56 +040024 CLANG_CONFIG_EXTRA_ASFLAGS += \
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040025 -target arm-linux-androideabi \
Evgeniy Stepanov55daae92012-03-26 14:15:47 +040026 -nostdlibinc \
Evgeniy Stepanove1d27e22012-08-21 15:45:56 +040027 -B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin
28 CLANG_CONFIG_EXTRA_CFLAGS += \
29 $(CLANG_CONFIG_EXTRA_ASFLAGS) \
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040030 -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 \
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +040039 -fno-builtin-sin \
40 -fno-strict-volatile-bitfields \
41 -fno-align-jumps \
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040042 -Wa,--noexecstack
43endif
Keun young Park6e86a572012-08-15 17:53:29 -070044ifeq ($(TARGET_ARCH),mips)
Stephen Hines9f669592013-03-08 09:02:52 -080045 RS_TRIPLE := mipsel-unknown-linux
Evgeniy Stepanove1d27e22012-08-21 15:45:56 +040046 CLANG_CONFIG_EXTRA_ASFLAGS += \
Keun young Park02a2f842012-08-21 10:20:18 -070047 -target mipsel-linux-androideabi \
Keun young Park6e86a572012-08-15 17:53:29 -070048 -nostdlibinc \
49 -B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin
Evgeniy Stepanove1d27e22012-08-21 15:45:56 +040050 CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
Keun young Park6e86a572012-08-15 17:53:29 -070051 CLANG_CONFIG_EXTRA_LDFLAGS += \
Keun young Park02a2f842012-08-21 10:20:18 -070052 -target mipsel-linux-androideabi \
Keun young Park6e86a572012-08-15 17:53:29 -070053 -B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin
54 CLANG_CONFIG_UNKNOWN_CFLAGS += \
55 -EL \
Keun young Parkf6e6bf72012-10-05 13:26:19 -070056 -mips32 \
Keun young Park6e86a572012-08-15 17:53:29 -070057 -mips32r2 \
58 -mhard-float \
59 -fno-strict-volatile-bitfields \
60 -fgcse-after-reload \
61 -frerun-cse-after-loop \
62 -frename-registers \
63 -march=mips32r2 \
Keun young Parkf6e6bf72012-10-05 13:26:19 -070064 -mtune=mips32r2 \
65 -march=mips32 \
Raghu Gandham695fee32013-02-07 16:07:01 -080066 -mtune=mips32 \
67 -msynci
Keun young Park6e86a572012-08-15 17:53:29 -070068endif
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040069ifeq ($(TARGET_ARCH),x86)
Tim Murray1a6f09a2013-03-05 11:07:15 -080070 RS_TRIPLE := i686-unknown-linux
Evgeniy Stepanove1d27e22012-08-21 15:45:56 +040071 CLANG_CONFIG_EXTRA_ASFLAGS += \
Jean-Baptiste Querufeec98b2012-05-16 13:18:39 -070072 -target i686-linux-android \
Evgeniy Stepanov55daae92012-03-26 14:15:47 +040073 -nostdlibinc \
Jean-Baptiste Querufeec98b2012-05-16 13:18:39 -070074 -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin
Evgeniy Stepanove1d27e22012-08-21 15:45:56 +040075 CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040076 CLANG_CONFIG_EXTRA_LDFLAGS += \
Jean-Baptiste Querufeec98b2012-05-16 13:18:39 -070077 -target i686-linux-android \
78 -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040079 CLANG_CONFIG_UNKNOWN_CFLAGS += \
80 -finline-limit=300 \
81 -fno-inline-functions-called-once \
82 -mfpmath=sse \
83 -mbionic
84endif
85
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +040086CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := external/clang/lib/include $(TARGET_OUT_HEADERS)/clang
yroussel13190052012-01-12 16:09:06 +010087
88# remove unknown flags to define CLANG_FLAGS
89TARGET_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_GLOBAL_CFLAGS))
90HOST_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(HOST_GLOBAL_CFLAGS))
91
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +040092TARGET_arm_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_arm_CFLAGS))
93TARGET_thumb_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_thumb_CFLAGS))
94
yroussel13190052012-01-12 16:09:06 +010095# llvm does not yet support -march=armv5e nor -march=armv5te, fall back to armv5 or armv5t
96$(call clang-flags-subst,-march=armv5te,-march=armv5t)
97$(call clang-flags-subst,-march=armv5e,-march=armv5)
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +040098
Shih-wei Liaoc814bce2012-08-03 05:17:23 -070099# clang does not support -Wno-psabi and -Wno-unused-but-set-variable
100$(call clang-flags-subst,-Wno-psabi,)
101$(call clang-flags-subst,-Wno-unused-but-set-variable,)
102
Ben Cheng533aa272013-01-14 13:45:45 -0800103# clang does not support -mcpu=cortex-a15 yet - fall back to armv7-a for now
104$(call clang-flags-subst,-mcpu=cortex-a15,-march=armv7-a)
105
Shih-wei Liao357a51c2013-01-27 01:44:37 -0800106ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400107ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
108ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload
109ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
Stephen Hinesc72f3962012-06-11 14:53:34 -0700110
111# This allows us to use the superset of functionality that compiler-rt
112# provides to Clang (for supporting features like -ftrapv).
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800113COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras