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) |
yroussel | 1319005 | 2012-01-12 16:09:06 +0100 | [diff] [blame] | 3 | LLVM_LINK := $(HOST_OUT_EXECUTABLES)/llvm-link$(HOST_EXECUTABLE_SUFFIX) |
| 4 | |
| 5 | define 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)) |
| 8 | endef |
| 9 | |
| 10 | define clang-flags-subst |
| 11 | $(eval $(call do-clang-flags-subst,$(1),$(2))) |
| 12 | endef |
| 13 | |
| 14 | |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 15 | CLANG_CONFIG_EXTRA_CFLAGS := \ |
| 16 | -D__compiler_offsetof=__builtin_offsetof \ |
| 17 | -Dnan=__builtin_nan \ |
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) |
| 23 | CLANG_CONFIG_EXTRA_CFLAGS += \ |
| 24 | -target arm-linux-androideabi \ |
Evgeniy Stepanov | 55daae9 | 2012-03-26 14:15:47 +0400 | [diff] [blame] | 25 | -nostdlibinc \ |
Stephen Hines | 62304f1 | 2012-03-22 21:26:17 -0700 | [diff] [blame] | 26 | -B$(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi/bin \ |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 27 | -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 Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame^] | 36 | -fno-builtin-sin \ |
| 37 | -fno-strict-volatile-bitfields \ |
| 38 | -fno-align-jumps \ |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 39 | -Wa,--noexecstack |
| 40 | endif |
| 41 | ifeq ($(TARGET_ARCH),x86) |
| 42 | CLANG_CONFIG_EXTRA_CFLAGS += \ |
Stephen Hines | 62304f1 | 2012-03-22 21:26:17 -0700 | [diff] [blame] | 43 | -target i686-android-linux \ |
Evgeniy Stepanov | 55daae9 | 2012-03-26 14:15:47 +0400 | [diff] [blame] | 44 | -nostdlibinc \ |
Stephen Hines | 62304f1 | 2012-03-22 21:26:17 -0700 | [diff] [blame] | 45 | -B$(TARGET_TOOLCHAIN_ROOT)/i686-android-linux/bin |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 46 | 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 |
| 54 | endif |
| 55 | |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame^] | 56 | 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] | 57 | |
| 58 | # remove unknown flags to define CLANG_FLAGS |
| 59 | TARGET_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_GLOBAL_CFLAGS)) |
| 60 | HOST_GLOBAL_CLANG_FLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(HOST_GLOBAL_CFLAGS)) |
| 61 | |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame^] | 62 | TARGET_arm_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_arm_CFLAGS)) |
| 63 | TARGET_thumb_CLANG_CFLAGS += $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(TARGET_thumb_CFLAGS)) |
| 64 | |
yroussel | 1319005 | 2012-01-12 16:09:06 +0100 | [diff] [blame] | 65 | # 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 Stepanov | 6cc9c06 | 2012-03-30 12:15:12 +0400 | [diff] [blame] | 68 | |
| 69 | ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -faddress-sanitizer |
| 70 | ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit |
| 71 | ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload |
| 72 | ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan |