Ying Wang | ba8b377 | 2014-03-10 18:23:08 -0700 | [diff] [blame] | 1 | ## Clang configurations. |
| 2 | |
| 3 | # WITHOUT_CLANG covers both HOST and TARGET |
| 4 | ifeq ($(WITHOUT_CLANG),true) |
| 5 | WITHOUT_TARGET_CLANG := true |
| 6 | WITHOUT_HOST_CLANG := true |
| 7 | endif |
| 8 | |
Tim Murray | 43d5e1b | 2014-04-03 16:06:59 -0700 | [diff] [blame] | 9 | LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/bin |
| 10 | LLVM_PREBUILTS_HEADER_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/lib/clang/3.5/include/ |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 11 | |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 12 | CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) |
| 13 | CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX) |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 14 | LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) |
| 15 | LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) |
Tim Murray | 75b58cc | 2014-04-30 13:54:32 -0700 | [diff] [blame] | 16 | |
Stephen Hines | b34b7ae | 2014-09-30 02:37:20 -0700 | [diff] [blame] | 17 | CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX) |
| 18 | LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX) |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 19 | |
Ying Wang | b169fb7 | 2014-07-29 14:08:33 -0700 | [diff] [blame] | 20 | # The C/C++ compiler can be wrapped by setting the CC/CXX_WRAPPER vars. |
| 21 | ifdef CC_WRAPPER |
| 22 | ifneq ($(CC_WRAPPER),$(firstword $(CLANG))) |
| 23 | CLANG := $(CC_WRAPPER) $(CLANG) |
| 24 | endif |
| 25 | endif |
| 26 | ifdef CXX_WRAPPER |
| 27 | ifneq ($(CXX_WRAPPER),$(firstword $(CLANG_CXX))) |
| 28 | CLANG_CXX := $(CXX_WRAPPER) $(CLANG_CXX) |
| 29 | endif |
| 30 | endif |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 31 | |
| 32 | # Clang flags for all host or target rules |
| 33 | CLANG_CONFIG_EXTRA_ASFLAGS := |
| 34 | CLANG_CONFIG_EXTRA_CFLAGS := |
| 35 | CLANG_CONFIG_EXTRA_CPPFLAGS := |
| 36 | CLANG_CONFIG_EXTRA_LDFLAGS := |
| 37 | |
Brian Carlstrom | 338d1e7 | 2014-06-17 14:36:05 -0700 | [diff] [blame] | 38 | CLANG_CONFIG_EXTRA_CFLAGS += \ |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 39 | -D__compiler_offsetof=__builtin_offsetof |
| 40 | |
Brian Carlstrom | 338d1e7 | 2014-06-17 14:36:05 -0700 | [diff] [blame] | 41 | # Help catch common 32/64-bit errors. |
| 42 | CLANG_CONFIG_EXTRA_CFLAGS += \ |
| 43 | -Werror=int-conversion |
| 44 | |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 45 | CLANG_CONFIG_UNKNOWN_CFLAGS := \ |
| 46 | -funswitch-loops \ |
Bernhard Rosenkraenzer | d6e1182 | 2014-05-12 16:05:14 +0200 | [diff] [blame] | 47 | -fno-tree-sra \ |
| 48 | -finline-limit=64 \ |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 49 | -Wno-psabi \ |
| 50 | -Wno-unused-but-set-variable \ |
Andrew Hsieh | 48f239c | 2014-05-09 14:13:13 +0800 | [diff] [blame] | 51 | -Wno-unused-but-set-parameter \ |
Bernhard Rosenkraenzer | d6e1182 | 2014-05-12 16:05:14 +0200 | [diff] [blame] | 52 | -Wmaybe-uninitialized \ |
| 53 | -Wno-maybe-uninitialized \ |
| 54 | -Wno-error=maybe-uninitialized \ |
Andrew Hsieh | 48f239c | 2014-05-09 14:13:13 +0800 | [diff] [blame] | 55 | -fno-canonical-system-headers |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 56 | |
| 57 | # Clang flags for all host rules |
Tim Murray | d318ba6 | 2014-04-21 14:00:31 -0700 | [diff] [blame] | 58 | CLANG_CONFIG_HOST_EXTRA_ASFLAGS := |
| 59 | CLANG_CONFIG_HOST_EXTRA_CFLAGS := |
| 60 | CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := |
| 61 | CLANG_CONFIG_HOST_EXTRA_LDFLAGS := |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 62 | |
| 63 | # Clang flags for all target rules |
| 64 | CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := |
| 65 | CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc |
| 66 | CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc |
| 67 | CLANG_CONFIG_TARGET_EXTRA_LDFLAGS := |
| 68 | |
| 69 | # HOST config |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 70 | clang_2nd_arch_prefix := |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 71 | include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 72 | |
| 73 | # HOST_2ND_ARCH config |
| 74 | ifdef HOST_2ND_ARCH |
| 75 | clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX) |
| 76 | include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk |
Tim Murray | 02cefc9 | 2014-03-20 13:48:35 -0700 | [diff] [blame] | 77 | endif |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 78 | |
| 79 | # TARGET config |
| 80 | clang_2nd_arch_prefix := |
| 81 | include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk |
| 82 | |
| 83 | # TARGET_2ND_ARCH config |
| 84 | ifdef TARGET_2ND_ARCH |
| 85 | clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) |
| 86 | include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk |
| 87 | endif |
| 88 | |
| 89 | |
| 90 | # Clang compiler-specific libc headers |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 91 | CLANG_CONFIG_EXTRA_HOST_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) |
| 92 | CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) $(TARGET_OUT_HEADERS)/clang |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 93 | |
| 94 | # Address sanitizer clang config |
Evgeniy Stepanov | 5d8029f | 2014-02-21 18:10:53 +0400 | [diff] [blame] | 95 | ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android |
| 96 | ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 97 | ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit |
Evgeniy Stepanov | 5d8029f | 2014-02-21 18:10:53 +0400 | [diff] [blame] | 98 | ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY) |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 99 | ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan |
| 100 | |
| 101 | # This allows us to use the superset of functionality that compiler-rt |
| 102 | # provides to Clang (for supporting features like -ftrapv). |
| 103 | COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras |
Ying Wang | a6ffb92 | 2014-11-06 14:11:33 -0800 | [diff] [blame^] | 104 | |
| 105 | ifeq ($(HOST_PREFER_32_BIT),true) |
| 106 | # We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source. |
| 107 | FORCE_BUILD_LLVM_COMPONENTS := true |
| 108 | endif |