Home | History | Annotate | Download | only in clang
      1 ## Clang configurations.
      2 
      3 LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin
      4 LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib64/clang/$(LLVM_RELEASE_VERSION)/lib/linux/
      5 
      6 CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
      7 CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX)
      8 LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
      9 LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
     10 
     11 CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
     12 LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX)
     13 
     14 # RenderScript-specific tools
     15 # These are tied to the version of LLVM directly in external/, so they might
     16 # trail the host prebuilts being used for the rest of the build process.
     17 RS_LLVM_PREBUILTS_VERSION := clang-2690385
     18 RS_LLVM_PREBUILTS_BASE := prebuilts/clang/host
     19 RS_LLVM_PREBUILTS_PATH := $(RS_LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(RS_LLVM_PREBUILTS_VERSION)/bin
     20 RS_CLANG := $(RS_LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
     21 RS_LLVM_AS := $(RS_LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
     22 RS_LLVM_LINK := $(RS_LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
     23 
     24 # Clang flags for all host or target rules
     25 CLANG_CONFIG_EXTRA_ASFLAGS :=
     26 CLANG_CONFIG_EXTRA_CFLAGS :=
     27 CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99
     28 CLANG_CONFIG_EXTRA_CPPFLAGS :=
     29 CLANG_CONFIG_EXTRA_LDFLAGS :=
     30 
     31 CLANG_CONFIG_EXTRA_CFLAGS += \
     32   -D__compiler_offsetof=__builtin_offsetof
     33 
     34 # Help catch common 32/64-bit errors.
     35 CLANG_CONFIG_EXTRA_CFLAGS += \
     36   -Werror=int-conversion
     37 
     38 # Disable overly aggressive warning for macros defined with a leading underscore
     39 # This used to happen in AndroidConfig.h, which was included everywhere.
     40 # TODO: can we remove this now?
     41 CLANG_CONFIG_EXTRA_CFLAGS += \
     42   -Wno-reserved-id-macro
     43 
     44 # Disable overly aggressive warning for format strings.
     45 # Bug: 20148343
     46 CLANG_CONFIG_EXTRA_CFLAGS += \
     47   -Wno-format-pedantic
     48 
     49 # Workaround for ccache with clang.
     50 # See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
     51 CLANG_CONFIG_EXTRA_CFLAGS += \
     52   -Wno-unused-command-line-argument
     53 
     54 # Disable -Winconsistent-missing-override until we can clean up the existing
     55 # codebase for it.
     56 CLANG_CONFIG_EXTRA_CPPFLAGS += \
     57   -Wno-inconsistent-missing-override
     58 
     59 # Force clang to always output color diagnostics.  Ninja will strip the ANSI
     60 # color codes if it is not running in a terminal.
     61 ifdef BUILDING_WITH_NINJA
     62 CLANG_CONFIG_EXTRA_CFLAGS += \
     63   -fcolor-diagnostics
     64 endif
     65 
     66 CLANG_CONFIG_UNKNOWN_CFLAGS := \
     67   -finline-functions \
     68   -finline-limit=64 \
     69   -fno-canonical-system-headers \
     70   -Wno-clobbered \
     71   -fno-devirtualize \
     72   -fno-tree-sra \
     73   -fprefetch-loop-arrays \
     74   -funswitch-loops \
     75   -Werror=unused-but-set-parameter \
     76   -Werror=unused-but-set-variable \
     77   -Wmaybe-uninitialized \
     78   -Wno-error=clobbered \
     79   -Wno-error=maybe-uninitialized \
     80   -Wno-error=unused-but-set-parameter \
     81   -Wno-error=unused-but-set-variable \
     82   -Wno-free-nonheap-object \
     83   -Wno-literal-suffix \
     84   -Wno-maybe-uninitialized \
     85   -Wno-old-style-declaration \
     86   -Wno-psabi \
     87   -Wno-unused-but-set-parameter \
     88   -Wno-unused-but-set-variable \
     89   -Wno-unused-local-typedefs \
     90   -Wunused-but-set-parameter \
     91   -Wunused-but-set-variable \
     92   -fdiagnostics-color \
     93   -fdebug-prefix-map=/proc/self/cwd=
     94 
     95 # Clang flags for all host rules
     96 CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
     97 CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
     98 CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
     99 CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
    100 
    101 # Clang flags for all host cross rules
    102 CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS :=
    103 CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS :=
    104 CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS :=
    105 CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS :=
    106 
    107 # Clang flags for all target rules
    108 CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
    109 CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
    110 CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
    111 CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
    112 
    113 CLANG_DEFAULT_UB_CHECKS := \
    114   bool \
    115   integer-divide-by-zero \
    116   return \
    117   returns-nonnull-attribute \
    118   shift-exponent \
    119   unreachable \
    120   vla-bound \
    121 
    122 # TODO(danalbert): The following checks currently have compiler performance
    123 # issues.
    124 # CLANG_DEFAULT_UB_CHECKS += alignment
    125 # CLANG_DEFAULT_UB_CHECKS += bounds
    126 # CLANG_DEFAULT_UB_CHECKS += enum
    127 # CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
    128 # CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
    129 # CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
    130 # CLANG_DEFAULT_UB_CHECKS += null
    131 # CLANG_DEFAULT_UB_CHECKS += shift-base
    132 # CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow
    133 
    134 # TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
    135 # https://llvm.org/PR19302
    136 # http://reviews.llvm.org/D6974
    137 # CLANG_DEFAULT_UB_CHECKS += object-size
    138 
    139 # HOST config
    140 clang_2nd_arch_prefix :=
    141 include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
    142 
    143 # HOST_2ND_ARCH config
    144 ifdef HOST_2ND_ARCH
    145 clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
    146 include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
    147 endif
    148 
    149 ifdef HOST_CROSS_ARCH
    150 clang_2nd_arch_prefix :=
    151 include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_ARCH).mk
    152 ifdef HOST_CROSS_2ND_ARCH
    153 clang_2nd_arch_prefix := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
    154 include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_2ND_ARCH).mk
    155 endif
    156 endif
    157 
    158 # TARGET config
    159 clang_2nd_arch_prefix :=
    160 include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
    161 
    162 # TARGET_2ND_ARCH config
    163 ifdef TARGET_2ND_ARCH
    164 clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
    165 include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
    166 endif
    167 
    168 ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
    169 ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
    170 
    171 ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES :=
    172 ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
    173 
    174 # This allows us to use the superset of functionality that compiler-rt
    175 # provides to Clang (for supporting features like -ftrapv).
    176 COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
    177 
    178 ifeq ($(HOST_PREFER_32_BIT),true)
    179 # We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
    180 FORCE_BUILD_LLVM_COMPONENTS := true
    181 endif
    182