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 | |
| 17 | CLANG_TBLGEN := $(HOST_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX) |
| 18 | TBLGEN := $(HOST_OUT_EXECUTABLES)/tblgen$(BUILD_EXECUTABLE_SUFFIX) |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 19 | |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 20 | |
| 21 | # Clang flags for all host or target rules |
| 22 | CLANG_CONFIG_EXTRA_ASFLAGS := |
| 23 | CLANG_CONFIG_EXTRA_CFLAGS := |
| 24 | CLANG_CONFIG_EXTRA_CPPFLAGS := |
| 25 | CLANG_CONFIG_EXTRA_LDFLAGS := |
| 26 | |
| 27 | CLANG_CONFIG_EXTRA_CFLAGS := \ |
| 28 | -D__compiler_offsetof=__builtin_offsetof |
| 29 | |
| 30 | CLANG_CONFIG_UNKNOWN_CFLAGS := \ |
| 31 | -funswitch-loops \ |
Bernhard Rosenkraenzer | d6e1182 | 2014-05-12 16:05:14 +0200 | [diff] [blame^] | 32 | -fno-tree-sra \ |
| 33 | -finline-limit=64 \ |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 34 | -Wno-psabi \ |
| 35 | -Wno-unused-but-set-variable \ |
Andrew Hsieh | 48f239c | 2014-05-09 14:13:13 +0800 | [diff] [blame] | 36 | -Wno-unused-but-set-parameter \ |
Bernhard Rosenkraenzer | d6e1182 | 2014-05-12 16:05:14 +0200 | [diff] [blame^] | 37 | -Wmaybe-uninitialized \ |
| 38 | -Wno-maybe-uninitialized \ |
| 39 | -Wno-error=maybe-uninitialized \ |
Andrew Hsieh | 48f239c | 2014-05-09 14:13:13 +0800 | [diff] [blame] | 40 | -fno-canonical-system-headers |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 41 | |
| 42 | # Clang flags for all host rules |
Tim Murray | d318ba6 | 2014-04-21 14:00:31 -0700 | [diff] [blame] | 43 | CLANG_CONFIG_HOST_EXTRA_ASFLAGS := |
| 44 | CLANG_CONFIG_HOST_EXTRA_CFLAGS := |
| 45 | CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := |
| 46 | CLANG_CONFIG_HOST_EXTRA_LDFLAGS := |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 47 | |
| 48 | # Clang flags for all target rules |
| 49 | CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := |
| 50 | CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc |
| 51 | CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc |
| 52 | CLANG_CONFIG_TARGET_EXTRA_LDFLAGS := |
| 53 | |
| 54 | # HOST config |
Tim Murray | 02cefc9 | 2014-03-20 13:48:35 -0700 | [diff] [blame] | 55 | ifneq ($(strip $(BUILD_HOST_64bit)),) |
| 56 | include $(BUILD_SYSTEM)/clang/HOST_x86_64.mk |
| 57 | else |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 58 | include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk |
Tim Murray | 02cefc9 | 2014-03-20 13:48:35 -0700 | [diff] [blame] | 59 | endif |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 60 | |
| 61 | # TARGET config |
| 62 | clang_2nd_arch_prefix := |
| 63 | include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk |
| 64 | |
| 65 | # TARGET_2ND_ARCH config |
| 66 | ifdef TARGET_2ND_ARCH |
| 67 | clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) |
| 68 | include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk |
| 69 | endif |
| 70 | |
| 71 | |
| 72 | # Clang compiler-specific libc headers |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 73 | CLANG_CONFIG_EXTRA_HOST_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) |
| 74 | 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] | 75 | |
| 76 | # Address sanitizer clang config |
| 77 | ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address |
| 78 | ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit |
| 79 | ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload |
| 80 | ADDRESS_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). |
| 84 | COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras |