Home | History | Annotate | Download | only in arm-linux-androideabi-clang3.6
      1 # Copyright (C) 2014 The Android Open Source Project
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #      http://www.apache.org/licenses/LICENSE-2.0
      8 #
      9 # Unless required by applicable law or agreed to in writing, software
     10 # distributed under the License is distributed on an "AS IS" BASIS,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 #
     15 
     16 # this file is used to prepare the NDK to build with the arm clang toolchain any
     17 # number of source files
     18 #
     19 # its purpose is to define (or re-define) templates used to build
     20 # various sources into target object files, libraries or executables.
     21 #
     22 # Note that this file may end up being parsed several times in future
     23 # revisions of the NDK.
     24 #
     25 
     26 #
     27 # Override the toolchain prefix
     28 #
     29 
     30 LLVM_TOOLCHAIN_PREBUILT_ROOT := $(call get-toolchain-root,llvm)
     31 LLVM_TOOLCHAIN_PREFIX := $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/
     32 
     33 TOOLCHAIN_NAME := arm-linux-androideabi
     34 BINUTILS_ROOT := $(call get-binutils-root,$(NDK_ROOT),$(TOOLCHAIN_NAME))
     35 TOOLCHAIN_ROOT := $(call get-toolchain-root,$(TOOLCHAIN_NAME)-4.9)
     36 TOOLCHAIN_PREFIX := $(TOOLCHAIN_ROOT)/bin/$(TOOLCHAIN_NAME)-
     37 
     38 TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT)
     39 TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT)
     40 
     41 #
     42 # CFLAGS and LDFLAGS
     43 #
     44 
     45 TARGET_CFLAGS := \
     46     -gcc-toolchain $(call host-path,$(TOOLCHAIN_ROOT)) \
     47     -fpic \
     48     -ffunction-sections \
     49     -funwind-tables \
     50     -fstack-protector-strong \
     51     -Wno-invalid-command-line-argument \
     52     -Wno-unused-command-line-argument \
     53     -no-canonical-prefixes
     54 
     55 # Disable integrated-as for better compatibility
     56 TARGET_CFLAGS += \
     57     -fno-integrated-as
     58 
     59 TARGET_LDFLAGS += \
     60     -gcc-toolchain $(call host-path,$(TOOLCHAIN_ROOT)) \
     61     -no-canonical-prefixes
     62 
     63 ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),)
     64     LLVM_TRIPLE := armv7-none-linux-androideabi
     65 
     66     TARGET_CFLAGS += -target $(LLVM_TRIPLE) \
     67                      -march=armv7-a \
     68                      -mfloat-abi=softfp \
     69                      -mfpu=vfpv3-d16
     70 
     71     TARGET_LDFLAGS += -target $(LLVM_TRIPLE) \
     72                       -Wl,--fix-cortex-a8
     73 
     74     GCCLIB_SUBDIR := armv7-a
     75 else
     76 ifneq ($(filter %armeabi-v7a-hard,$(TARGET_ARCH_ABI)),)
     77     LLVM_TRIPLE := armv7-none-linux-androideabi
     78 
     79     TARGET_CFLAGS += -target $(LLVM_TRIPLE) \
     80                      -march=armv7-a \
     81                      -mfpu=vfpv3-d16 \
     82                      -mhard-float \
     83                      -D_NDK_MATH_NO_SOFTFP=1
     84 
     85     TARGET_LDFLAGS += -target $(LLVM_TRIPLE) \
     86                       -Wl,--fix-cortex-a8 \
     87                       -Wl,--no-warn-mismatch \
     88                       -lm_hard
     89 
     90     GCCLIB_SUBDIR := armv7-a
     91 else
     92     LLVM_TRIPLE := armv5te-none-linux-androideabi
     93 
     94     TARGET_CFLAGS += -target $(LLVM_TRIPLE) \
     95                      -march=armv5te \
     96                      -mtune=xscale \
     97                      -msoft-float
     98 
     99     TARGET_LDFLAGS += -target $(LLVM_TRIPLE)
    100 
    101     GCCLIB_SUBDIR :=
    102 endif
    103 endif
    104 
    105 GCCLIB_ROOT := $(call get-gcclibs-path,$(NDK_ROOT),$(TOOLCHAIN_NAME))
    106 
    107 TARGET_CFLAGS.neon := -mfpu=neon
    108 
    109 TARGET_arm_release_CFLAGS :=  -O2 \
    110                               -g \
    111                               -DNDEBUG \
    112                               -fomit-frame-pointer \
    113                               -fstrict-aliasing
    114 
    115 TARGET_thumb_release_CFLAGS := -mthumb \
    116                                -Os \
    117                                -g \
    118                                -DNDEBUG \
    119                                -fomit-frame-pointer \
    120                                -fno-strict-aliasing
    121 
    122 # When building for debug, compile everything as arm.
    123 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
    124                            -O0 \
    125                            -UNDEBUG \
    126                            -fno-omit-frame-pointer \
    127                            -fno-strict-aliasing
    128 
    129 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
    130                              -O0 \
    131                              -UNDEBUG \
    132                              -marm \
    133                              -fno-omit-frame-pointer
    134 
    135 # This function will be called to determine the target CFLAGS used to build
    136 # a C or Assembler source file, based on its tags.
    137 #
    138 TARGET-process-src-files-tags = \
    139 $(eval __arm_sources := $(call get-src-files-with-tag,arm)) \
    140 $(eval __thumb_sources := $(call get-src-files-without-tag,arm)) \
    141 $(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
    142 $(eval __release_sources := $(call get-src-files-without-tag,debug)) \
    143 $(call set-src-files-target-cflags, \
    144     $(call set_intersection,$(__arm_sources),$(__debug_sources)), \
    145     $(TARGET_arm_debug_CFLAGS)) \
    146 $(call set-src-files-target-cflags,\
    147     $(call set_intersection,$(__arm_sources),$(__release_sources)),\
    148     $(TARGET_arm_release_CFLAGS)) \
    149 $(call set-src-files-target-cflags,\
    150     $(call set_intersection,$(__arm_sources),$(__debug_sources)),\
    151     $(TARGET_arm_debug_CFLAGS)) \
    152 $(call set-src-files-target-cflags,\
    153     $(call set_intersection,$(__thumb_sources),$(__release_sources)),\
    154     $(TARGET_thumb_release_CFLAGS)) \
    155 $(call set-src-files-target-cflags,\
    156     $(call set_intersection,$(__thumb_sources),$(__debug_sources)),\
    157     $(TARGET_thumb_debug_CFLAGS)) \
    158 $(call add-src-files-target-cflags,\
    159     $(call get-src-files-with-tag,neon),\
    160     $(TARGET_CFLAGS.neon)) \
    161 $(call set-src-files-text,$(__arm_sources),arm) \
    162 $(call set-src-files-text,$(__thumb_sources),thumb)
    163