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 | |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 9 | ifeq (true,$(FORCE_BUILD_LLVM_COMPONENTS)) |
| 10 | LLVM_PREBUILTS_PATH := $(BUILD_OUT_EXECUTABLES) |
| 11 | LLVM_PREBUILTS_HEADER_PATH := external/clang/lib/include |
| 12 | else |
| 13 | LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.4/bin |
| 14 | LLVM_PREBUILTS_HEADER_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.4/lib/clang/3.4/include/ |
| 15 | endif |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 16 | |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 17 | CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) |
| 18 | CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX) |
| 19 | CLANG_TBLGEN := $(LLVM_PREBUILTS_PATH)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX) |
| 20 | LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) |
| 21 | LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) |
| 22 | TBLGEN := $(LLVM_PREBUILTS_PATH)/tblgen$(BUILD_EXECUTABLE_SUFFIX) |
| 23 | |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 24 | |
| 25 | # Clang flags for all host or target rules |
| 26 | CLANG_CONFIG_EXTRA_ASFLAGS := |
| 27 | CLANG_CONFIG_EXTRA_CFLAGS := |
| 28 | CLANG_CONFIG_EXTRA_CPPFLAGS := |
| 29 | CLANG_CONFIG_EXTRA_LDFLAGS := |
| 30 | |
| 31 | CLANG_CONFIG_EXTRA_CFLAGS := \ |
| 32 | -D__compiler_offsetof=__builtin_offsetof |
| 33 | |
| 34 | CLANG_CONFIG_UNKNOWN_CFLAGS := \ |
| 35 | -funswitch-loops \ |
| 36 | -Wno-psabi \ |
| 37 | -Wno-unused-but-set-variable \ |
| 38 | -Wno-unused-but-set-parameter |
| 39 | |
| 40 | # Clang flags for all host rules |
Tim Murray | 02cefc9 | 2014-03-20 13:48:35 -0700 | [diff] [blame^] | 41 | CLANG_CONFIG_HOST_EXTRA_ASFLAGS := --gcc-toolchain=$(HOST_TOOLCHAIN_FOR_CLANG) |
| 42 | CLANG_CONFIG_HOST_EXTRA_CFLAGS := --gcc-toolchain=$(HOST_TOOLCHAIN_FOR_CLANG) |
| 43 | CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := --gcc-toolchain=$(HOST_TOOLCHAIN_FOR_CLANG) |
| 44 | CLANG_CONFIG_HOST_EXTRA_LDFLAGS := --gcc-toolchain=$(HOST_TOOLCHAIN_FOR_CLANG) |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 45 | |
| 46 | # Clang flags for all target rules |
| 47 | CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := |
| 48 | CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc |
| 49 | CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc |
| 50 | CLANG_CONFIG_TARGET_EXTRA_LDFLAGS := |
| 51 | |
| 52 | # HOST config |
Tim Murray | 02cefc9 | 2014-03-20 13:48:35 -0700 | [diff] [blame^] | 53 | ifneq ($(strip $(BUILD_HOST_64bit)),) |
| 54 | include $(BUILD_SYSTEM)/clang/HOST_x86_64.mk |
| 55 | else |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 56 | include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk |
Tim Murray | 02cefc9 | 2014-03-20 13:48:35 -0700 | [diff] [blame^] | 57 | endif |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 58 | |
| 59 | # TARGET config |
| 60 | clang_2nd_arch_prefix := |
| 61 | include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk |
| 62 | |
| 63 | # TARGET_2ND_ARCH config |
| 64 | ifdef TARGET_2ND_ARCH |
| 65 | clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) |
| 66 | include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk |
| 67 | endif |
| 68 | |
| 69 | |
| 70 | # Clang compiler-specific libc headers |
Stephen Hines | 7bc754b | 2014-02-19 09:03:00 -0800 | [diff] [blame] | 71 | CLANG_CONFIG_EXTRA_HOST_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) |
| 72 | 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] | 73 | |
| 74 | # Address sanitizer clang config |
| 75 | ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address |
| 76 | ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit |
| 77 | ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload |
| 78 | ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan |
| 79 | |
| 80 | # This allows us to use the superset of functionality that compiler-rt |
| 81 | # provides to Clang (for supporting features like -ftrapv). |
| 82 | COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras |