blob: ce6cedaaf83b10c5db54ae75fe504e023c58dec4 [file] [log] [blame]
Ying Wangba8b3772014-03-10 18:23:08 -07001## Clang configurations.
2
3# WITHOUT_CLANG covers both HOST and TARGET
4ifeq ($(WITHOUT_CLANG),true)
5WITHOUT_TARGET_CLANG := true
6WITHOUT_HOST_CLANG := true
7endif
8
Tim Murray43d5e1b2014-04-03 16:06:59 -07009LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/bin
10LLVM_PREBUILTS_HEADER_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/lib/clang/3.5/include/
Ying Wang1f982832014-02-06 18:08:44 -080011
Stephen Hines7bc754b2014-02-19 09:03:00 -080012CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
13CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines7bc754b2014-02-19 09:03:00 -080014LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
15LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
Tim Murray75b58cc2014-04-30 13:54:32 -070016
17CLANG_TBLGEN := $(HOST_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
18TBLGEN := $(HOST_OUT_EXECUTABLES)/tblgen$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines7bc754b2014-02-19 09:03:00 -080019
Ying Wang1f982832014-02-06 18:08:44 -080020
21# Clang flags for all host or target rules
22CLANG_CONFIG_EXTRA_ASFLAGS :=
23CLANG_CONFIG_EXTRA_CFLAGS :=
24CLANG_CONFIG_EXTRA_CPPFLAGS :=
25CLANG_CONFIG_EXTRA_LDFLAGS :=
26
27CLANG_CONFIG_EXTRA_CFLAGS := \
28 -D__compiler_offsetof=__builtin_offsetof
29
30CLANG_CONFIG_UNKNOWN_CFLAGS := \
31 -funswitch-loops \
Bernhard Rosenkraenzerd6e11822014-05-12 16:05:14 +020032 -fno-tree-sra \
33 -finline-limit=64 \
Ying Wang1f982832014-02-06 18:08:44 -080034 -Wno-psabi \
35 -Wno-unused-but-set-variable \
Andrew Hsieh48f239c2014-05-09 14:13:13 +080036 -Wno-unused-but-set-parameter \
Bernhard Rosenkraenzerd6e11822014-05-12 16:05:14 +020037 -Wmaybe-uninitialized \
38 -Wno-maybe-uninitialized \
39 -Wno-error=maybe-uninitialized \
Andrew Hsieh48f239c2014-05-09 14:13:13 +080040 -fno-canonical-system-headers
Ying Wang1f982832014-02-06 18:08:44 -080041
42# Clang flags for all host rules
Tim Murrayd318ba62014-04-21 14:00:31 -070043CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
44CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
45CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
46CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
Ying Wang1f982832014-02-06 18:08:44 -080047
48# Clang flags for all target rules
49CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
50CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
51CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
52CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
53
54# HOST config
Tim Murray02cefc92014-03-20 13:48:35 -070055ifneq ($(strip $(BUILD_HOST_64bit)),)
56include $(BUILD_SYSTEM)/clang/HOST_x86_64.mk
57else
Ying Wang1f982832014-02-06 18:08:44 -080058include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
Tim Murray02cefc92014-03-20 13:48:35 -070059endif
Ying Wang1f982832014-02-06 18:08:44 -080060
61# TARGET config
62clang_2nd_arch_prefix :=
63include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
64
65# TARGET_2ND_ARCH config
66ifdef TARGET_2ND_ARCH
67clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
68include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
69endif
70
71
72# Clang compiler-specific libc headers
Stephen Hines7bc754b2014-02-19 09:03:00 -080073CLANG_CONFIG_EXTRA_HOST_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH)
74CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) $(TARGET_OUT_HEADERS)/clang
Ying Wang1f982832014-02-06 18:08:44 -080075
76# Address sanitizer clang config
77ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address
78ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
79ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload
80ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
81
82# This allows us to use the superset of functionality that compiler-rt
83# provides to Clang (for supporting features like -ftrapv).
84COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras