OSDN Git Service

am 366ac666: am 2b3b1409: am 6873be9e: am 5d2265cb: am ed5ea12b: am f09c7628: am...
[android-x86/build.git] / core / llvm_config.mk
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 endif
69 ifeq ($(TARGET_ARCH),x86)
70   RS_TRIPLE := i686-unknown-linux
71   CLANG_CONFIG_EXTRA_ASFLAGS += \
72     -target i686-linux-android \
73     -nostdlibinc \
74     -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin
75   CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS)
76   CLANG_CONFIG_EXTRA_LDFLAGS += \
77     -target i686-linux-android \
78     -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin
79   CLANG_CONFIG_UNKNOWN_CFLAGS += \
80     -finline-limit=300 \
81     -fno-inline-functions-called-once \
82     -mfpmath=sse \
83     -mbionic
84 endif
85
86 CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := external/clang/lib/include $(TARGET_OUT_HEADERS)/clang
87
88 # remove unknown flags to define CLANG_FLAGS
89 TARGET_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_GLOBAL_CFLAGS))
90 HOST_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(HOST_GLOBAL_CFLAGS))
91
92 TARGET_arm_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_arm_CFLAGS))
93 TARGET_thumb_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_thumb_CFLAGS))
94
95 # 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)
98
99 # 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
103 # 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
106 ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address
107 ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
108 ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload
109 ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
110
111 # This allows us to use the superset of functionality that compiler-rt
112 # provides to Clang (for supporting features like -ftrapv).
113 COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras