• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 x86_64 llvm toolchain
17# 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
30LLVM_TOOLCHAIN_PREBUILT_ROOT := $(call get-toolchain-root,llvm)
31LLVM_TOOLCHAIN_PREFIX := $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/
32
33TOOLCHAIN_NAME := x86_64-linux-android
34BINUTILS_ROOT := $(call get-binutils-root,$(NDK_ROOT),$(TOOLCHAIN_NAME))
35TOOLCHAIN_ROOT := $(call get-toolchain-root,x86_64-4.9)
36TOOLCHAIN_PREFIX := $(TOOLCHAIN_ROOT)/bin/$(TOOLCHAIN_NAME)-
37
38TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT)
39TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT)
40
41LLVM_TRIPLE := x86_64-none-linux-android
42
43TARGET_CFLAGS := \
44    -gcc-toolchain $(call host-path,$(TOOLCHAIN_ROOT)) \
45    -target $(LLVM_TRIPLE) \
46    -ffunction-sections \
47    -funwind-tables \
48    -fstack-protector-strong \
49    -fPIC \
50    -Wno-invalid-command-line-argument \
51    -Wno-unused-command-line-argument \
52    -no-canonical-prefixes
53
54TARGET_LDFLAGS += \
55    -gcc-toolchain $(call host-path,$(TOOLCHAIN_ROOT)) \
56    -target $(LLVM_TRIPLE) \
57    -no-canonical-prefixes
58
59TARGET_x86_64_release_CFLAGS := -O2 \
60                             -g \
61                             -DNDEBUG \
62                             -fomit-frame-pointer \
63                             -fstrict-aliasing
64
65TARGET_x86_64_debug_CFLAGS := $(TARGET_x86_64_release_CFLAGS) \
66                           -O0 \
67                           -UNDEBUG \
68                           -fno-omit-frame-pointer \
69                           -fno-strict-aliasing
70
71# This function will be called to determine the target CFLAGS used to build
72# a C or Assembler source file, based on its tags.
73#
74TARGET-process-src-files-tags = \
75$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
76$(eval __release_sources := $(call get-src-files-without-tag,debug)) \
77$(call set-src-files-target-cflags, $(__debug_sources), $(TARGET_x86_64_debug_CFLAGS)) \
78$(call set-src-files-target-cflags, $(__release_sources),$(TARGET_x86_64_release_CFLAGS)) \
79
80# The ABI-specific sub-directory that the SDK tools recognize for
81# this toolchain's generated binaries
82TARGET_ABI_SUBDIR := x86_64
83