blob: 966924e0f1c517d95a8f876d487700f7c775b9d9 [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)
yroussel13190052012-01-12 16:09:06 +01003LLVM_LINK := $(HOST_OUT_EXECUTABLES)/llvm-link$(HOST_EXECUTABLE_SUFFIX)
4
5define do-clang-flags-subst
6 TARGET_GLOBAL_CLANG_FLAGS := $(subst $(1),$(2),$(TARGET_GLOBAL_CLANG_FLAGS))
7 HOST_GLOBAL_CLANG_FLAGS := $(subst $(1),$(2),$(HOST_GLOBAL_CLANG_FLAGS))
8endef
9
10define clang-flags-subst
11 $(eval $(call do-clang-flags-subst,$(1),$(2)))
12endef
13
14
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040015CLANG_CONFIG_EXTRA_CFLAGS := \
16 -D__compiler_offsetof=__builtin_offsetof \
17 -Dnan=__builtin_nan \
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)
23 CLANG_CONFIG_EXTRA_CFLAGS += \
24 -target arm-linux-androideabi \
Evgeniy Stepanov55daae92012-03-26 14:15:47 +040025 -nostdlibinc \
Stephen Hines62304f12012-03-22 21:26:17 -070026 -B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin \
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040027 -mllvm -arm-enable-ehabi
28 CLANG_CONFIG_EXTRA_LDFLAGS += \
29 -target arm-linux-androideabi \
30 -B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin
31 CLANG_CONFIG_UNKNOWN_CFLAGS += \
32 -mthumb-interwork \
33 -fgcse-after-reload \
34 -frerun-cse-after-loop \
35 -frename-registers \
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +040036 -fno-builtin-sin \
37 -fno-strict-volatile-bitfields \
38 -fno-align-jumps \
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040039 -Wa,--noexecstack
40endif
41ifeq ($(TARGET_ARCH),x86)
42 CLANG_CONFIG_EXTRA_CFLAGS += \
Stephen Hines62304f12012-03-22 21:26:17 -070043 -target i686-android-linux \
Evgeniy Stepanov55daae92012-03-26 14:15:47 +040044 -nostdlibinc \
Stephen Hines62304f12012-03-22 21:26:17 -070045 -B$(TARGET_TOOLCHAIN_ROOT)/i686-android-linux/bin
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +040046 CLANG_CONFIG_EXTRA_LDFLAGS += \
47 -target i686-android-linux \
48 -B$(TARGET_TOOLCHAIN_ROOT)/i686-android-linux/bin
49 CLANG_CONFIG_UNKNOWN_CFLAGS += \
50 -finline-limit=300 \
51 -fno-inline-functions-called-once \
52 -mfpmath=sse \
53 -mbionic
54endif
55
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +040056CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := external/clang/lib/include $(TARGET_OUT_HEADERS)/clang
yroussel13190052012-01-12 16:09:06 +010057
58# remove unknown flags to define CLANG_FLAGS
59TARGET_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_GLOBAL_CFLAGS))
60HOST_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(HOST_GLOBAL_CFLAGS))
61
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +040062TARGET_arm_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_arm_CFLAGS))
63TARGET_thumb_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_thumb_CFLAGS))
64
yroussel13190052012-01-12 16:09:06 +010065# llvm does not yet support -march=armv5e nor -march=armv5te, fall back to armv5 or armv5t
66$(call clang-flags-subst,-march=armv5te,-march=armv5t)
67$(call clang-flags-subst,-march=armv5e,-march=armv5)
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +040068
69ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -faddress-sanitizer
70ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
71ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload
72ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan