Andrew Hsieh | 6db7305 | 2014-10-15 16:58:47 +0800 | [diff] [blame] | 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 arm64 clang-3.5 |
| 17 | # toolchain any 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_VERSION := 3.5 |
| 31 | LLVM_NAME := llvm-$(LLVM_VERSION) |
| 32 | LLVM_TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(LLVM_NAME) |
| 33 | LLVM_TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(LLVM_TOOLCHAIN_ROOT)) |
| 34 | LLVM_TOOLCHAIN_PREFIX := $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/ |
| 35 | |
| 36 | TOOLCHAIN_VERSION := 4.9 |
| 37 | TOOLCHAIN_NAME := aarch64-linux-android-$(TOOLCHAIN_VERSION) |
| 38 | TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME) |
| 39 | TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(TOOLCHAIN_ROOT)) |
| 40 | TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/aarch64-linux-android- |
| 41 | |
| 42 | TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT) |
| 43 | TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT) |
| 44 | |
| 45 | LLVM_TRIPLE := aarch64-none-linux-android |
| 46 | |
| 47 | TARGET_CFLAGS := \ |
| 48 | -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \ |
| 49 | -target $(LLVM_TRIPLE) \ |
| 50 | -ffunction-sections \ |
| 51 | -funwind-tables \ |
Daniel Micay | 45e3de0 | 2015-03-20 02:54:46 -0400 | [diff] [blame] | 52 | -fstack-protector-strong \ |
Andrew Hsieh | 6db7305 | 2014-10-15 16:58:47 +0800 | [diff] [blame] | 53 | -fpic \ |
| 54 | -Wno-invalid-command-line-argument \ |
| 55 | -Wno-unused-command-line-argument \ |
| 56 | -no-canonical-prefixes |
| 57 | |
| 58 | TARGET_C_INCLUDES := \ |
| 59 | $(SYSROOT_INC)/usr/include |
| 60 | |
| 61 | TARGET_LDFLAGS += \ |
| 62 | -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \ |
| 63 | -target $(LLVM_TRIPLE) \ |
| 64 | -no-canonical-prefixes |
| 65 | |
| 66 | TARGET_arm64_release_CFLAGS := -O2 \ |
| 67 | -g \ |
| 68 | -DNDEBUG \ |
| 69 | -fomit-frame-pointer \ |
| 70 | -fstrict-aliasing |
| 71 | |
| 72 | TARGET_arm64_debug_CFLAGS := $(TARGET_arm64_release_CFLAGS) \ |
| 73 | -O0 \ |
| 74 | -UNDEBUG \ |
| 75 | -fno-omit-frame-pointer \ |
| 76 | -fno-strict-aliasing |
| 77 | |
| 78 | # This function will be called to determine the target CFLAGS used to build |
| 79 | # a C or Assembler source file, based on its tags. |
| 80 | # |
| 81 | TARGET-process-src-files-tags = \ |
| 82 | $(eval __debug_sources := $(call get-src-files-with-tag,debug)) \ |
| 83 | $(eval __release_sources := $(call get-src-files-without-tag,debug)) \ |
| 84 | $(call set-src-files-target-cflags, $(__debug_sources), $(TARGET_arm64_debug_CFLAGS)) \ |
| 85 | $(call set-src-files-target-cflags, $(__release_sources),$(TARGET_arm64_release_CFLAGS)) \ |