yroussel | 1319005 | 2012-01-12 16:09:06 +0100 | [diff] [blame] | 1 | CLANG := $(HOST_OUT_EXECUTABLES)/clang$(HOST_EXECUTABLE_SUFFIX) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 2 | CLANG_CXX := $(HOST_OUT_EXECUTABLES)/clang++$(HOST_EXECUTABLE_SUFFIX) |
Stephen Hines | 7e48e40 | 2012-05-08 18:43:48 -0700 | [diff] [blame] | 3 | LLVM_AS := $(HOST_OUT_EXECUTABLES)/llvm-as$(HOST_EXECUTABLE_SUFFIX) |
yroussel | 1319005 | 2012-01-12 16:09:06 +0100 | [diff] [blame] | 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 | |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 16 | CLANG_CONFIG_EXTRA_CFLAGS := \ |
| 17 | -D__compiler_offsetof=__builtin_offsetof \ |
yroussel | 1319005 | 2012-01-12 16:09:06 +0100 | [diff] [blame] | 18 | |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 19 | CLANG_CONFIG_UNKNOWN_CFLAGS := \ |
| 20 | -funswitch-loops |
| 21 | |
| 22 | ifeq ($(TARGET_ARCH),arm) |
Stephen Hines | 408733b | 2013-03-12 17:10:19 -0700 | [diff] [blame] | 23 | RS_TRIPLE := armv7-none-linux-gnueabi |
Evgeniy Stepanov | e1d27e2 | 2012-08-21 15:45:56 +0400 | [diff] [blame] | 24 | CLANG_CONFIG_EXTRA_ASFLAGS += \ |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 25 | -target arm-linux-androideabi \ |
Evgeniy Stepanov | 55daae9 | 2012-03-26 14:15:47 +0400 | [diff] [blame] | 26 | -nostdlibinc \ |
Evgeniy Stepanov | e1d27e2 | 2012-08-21 15:45:56 +0400 | [diff] [blame] | 27 | -B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin |
| 28 | CLANG_CONFIG_EXTRA_CFLAGS += \ |
| 29 | $(CLANG_CONFIG_EXTRA_ASFLAGS) \ |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 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 \ |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame] | 39 | -fno-builtin-sin \ |
| 40 | -fno-strict-volatile-bitfields \ |
| 41 | -fno-align-jumps \ |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 42 | -Wa,--noexecstack |
| 43 | endif |
Keun young Park | 6e86a57 | 2012-08-15 17:53:29 -0700 | [diff] [blame] | 44 | ifeq ($(TARGET_ARCH),mips) |
Stephen Hines | 9f66959 | 2013-03-08 09:02:52 -0800 | [diff] [blame] | 45 | RS_TRIPLE := mipsel-unknown-linux |
Evgeniy Stepanov | e1d27e2 | 2012-08-21 15:45:56 +0400 | [diff] [blame] | 46 | CLANG_CONFIG_EXTRA_ASFLAGS += \ |
Keun young Park | 02a2f84 | 2012-08-21 10:20:18 -0700 | [diff] [blame] | 47 | -target mipsel-linux-androideabi \ |
Keun young Park | 6e86a57 | 2012-08-15 17:53:29 -0700 | [diff] [blame] | 48 | -nostdlibinc \ |
| 49 | -B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin |
Evgeniy Stepanov | e1d27e2 | 2012-08-21 15:45:56 +0400 | [diff] [blame] | 50 | CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS) |
Keun young Park | 6e86a57 | 2012-08-15 17:53:29 -0700 | [diff] [blame] | 51 | CLANG_CONFIG_EXTRA_LDFLAGS += \ |
Keun young Park | 02a2f84 | 2012-08-21 10:20:18 -0700 | [diff] [blame] | 52 | -target mipsel-linux-androideabi \ |
Keun young Park | 6e86a57 | 2012-08-15 17:53:29 -0700 | [diff] [blame] | 53 | -B$(TARGET_TOOLCHAIN_ROOT)/mipsel-linux-android/bin |
| 54 | CLANG_CONFIG_UNKNOWN_CFLAGS += \ |
| 55 | -EL \ |
Keun young Park | f6e6bf7 | 2012-10-05 13:26:19 -0700 | [diff] [blame] | 56 | -mips32 \ |
Keun young Park | 6e86a57 | 2012-08-15 17:53:29 -0700 | [diff] [blame] | 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 \ |
Keun young Park | f6e6bf7 | 2012-10-05 13:26:19 -0700 | [diff] [blame] | 64 | -mtune=mips32r2 \ |
| 65 | -march=mips32 \ |
Raghu Gandham | 695fee3 | 2013-02-07 16:07:01 -0800 | [diff] [blame] | 66 | -mtune=mips32 \ |
| 67 | -msynci |
Keun young Park | 6e86a57 | 2012-08-15 17:53:29 -0700 | [diff] [blame] | 68 | endif |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 69 | ifeq ($(TARGET_ARCH),x86) |
Tim Murray | 1a6f09a | 2013-03-05 11:07:15 -0800 | [diff] [blame] | 70 | RS_TRIPLE := i686-unknown-linux |
Evgeniy Stepanov | e1d27e2 | 2012-08-21 15:45:56 +0400 | [diff] [blame] | 71 | CLANG_CONFIG_EXTRA_ASFLAGS += \ |
Jean-Baptiste Queru | feec98b | 2012-05-16 13:18:39 -0700 | [diff] [blame] | 72 | -target i686-linux-android \ |
Evgeniy Stepanov | 55daae9 | 2012-03-26 14:15:47 +0400 | [diff] [blame] | 73 | -nostdlibinc \ |
Jean-Baptiste Queru | feec98b | 2012-05-16 13:18:39 -0700 | [diff] [blame] | 74 | -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin |
Evgeniy Stepanov | e1d27e2 | 2012-08-21 15:45:56 +0400 | [diff] [blame] | 75 | CLANG_CONFIG_EXTRA_CFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 76 | CLANG_CONFIG_EXTRA_LDFLAGS += \ |
Jean-Baptiste Queru | feec98b | 2012-05-16 13:18:39 -0700 | [diff] [blame] | 77 | -target i686-linux-android \ |
| 78 | -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 79 | CLANG_CONFIG_UNKNOWN_CFLAGS += \ |
| 80 | -finline-limit=300 \ |
| 81 | -fno-inline-functions-called-once \ |
| 82 | -mfpmath=sse \ |
| 83 | -mbionic |
| 84 | endif |
| 85 | |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame] | 86 | CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := external/clang/lib/include $(TARGET_OUT_HEADERS)/clang |
yroussel | 1319005 | 2012-01-12 16:09:06 +0100 | [diff] [blame] | 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 | |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame] | 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 | |
yroussel | 1319005 | 2012-01-12 16:09:06 +0100 | [diff] [blame] | 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) |
Evgeniy Stepanov | 6cc9c06 | 2012-03-30 12:15:12 +0400 | [diff] [blame] | 98 | |
Shih-wei Liao | c814bce | 2012-08-03 05:17:23 -0700 | [diff] [blame] | 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 | |
Ben Cheng | 533aa27 | 2013-01-14 13:45:45 -0800 | [diff] [blame] | 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 | |
Shih-wei Liao | 357a51c | 2013-01-27 01:44:37 -0800 | [diff] [blame] | 106 | ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address |
Evgeniy Stepanov | 6cc9c06 | 2012-03-30 12:15:12 +0400 | [diff] [blame] | 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 |
Stephen Hines | c72f396 | 2012-06-11 14:53:34 -0700 | [diff] [blame] | 110 | |
| 111 | # This allows us to use the superset of functionality that compiler-rt |
| 112 | # provides to Clang (for supporting features like -ftrapv). |
Shih-wei Liao | c8dfc16 | 2013-01-27 01:45:59 -0800 | [diff] [blame] | 113 | COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras |