blob: 5f0f1d23f10484210c914cb78140dc82a3c923d0 [file] [log] [blame]
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -08001#
2# Copyright (C) 2006 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070017# Configuration for Linux on ARM.
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080018# Included by combo/select.mk
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070019
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020020# You can set TARGET_ARCH_VARIANT to use an arch version other
21# than ARMv5TE. Each value should correspond to a file named
22# $(BUILD_COMBOS)/arch/<name>.mk which must contain
Elliott Hughes43146112015-08-28 10:31:28 -070023# makefile variable definitions. Their
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020024# purpose is to allow module Android.mk files to selectively compile
25# different versions of code based upon the funtionality and
Ben Lesliee03f0232008-10-30 10:41:09 -050026# instructions available in a given architecture version.
27#
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020028# The blocks also define specific arch_variant_cflags, which
Ben Lesliee03f0232008-10-30 10:41:09 -050029# include defines, and compiler settings for the given architecture
30# version.
31#
Ying Wange1d44c32013-12-27 11:09:36 -080032ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
33TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv5te
Ben Lesliee03f0232008-10-30 10:41:09 -050034endif
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020035
Ben Cheng4de6fa42014-04-10 22:46:26 -070036# Decouple NDK library selection with platform compiler version
Rong Xubf8346e2014-12-03 16:27:20 -080037$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.9
Ben Cheng4de6fa42014-04-10 22:46:26 -070038
Ben Chengec4caba2012-12-12 16:22:54 -080039ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
Rong Xubf8346e2014-12-03 16:27:20 -080040$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9
Ben Chengec4caba2012-12-12 16:22:54 -080041else
Ying Wange1d44c32013-12-27 11:09:36 -080042$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
Ben Cheng054ffd22012-12-11 14:01:10 -080043endif
44
Ying Wange1d44c32013-12-27 11:09:36 -080045TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT).mk
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020046ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
Ying Wange1d44c32013-12-27 11:09:36 -080047$(error Unknown ARM architecture version: $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
Andy McFadden8f51a2a2009-05-28 12:47:23 -070048endif
Ben Lesliee03f0232008-10-30 10:41:09 -050049
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020050include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
Dehao Chen25671e12014-07-23 14:28:58 -070051include $(BUILD_SYSTEM)/combo/fdo.mk
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020052
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070053# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
Ying Wange1d44c32013-12-27 11:09:36 -080054ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),)
55$(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
56$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi-
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070057endif
58
Dan Albert216ecac2015-05-04 12:44:44 -070059$(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc
60$(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++
61$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar
62$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy
63$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld
64$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf
65$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070066
Ying Wange1d44c32013-12-27 11:09:36 -080067$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070068
Ying Wange1d44c32013-12-27 11:09:36 -080069$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O2 \
Dave Bort95282482009-04-23 18:44:55 -070070 -fomit-frame-pointer \
71 -fstrict-aliasing \
Jing Yua83b7692010-12-21 16:33:48 -080072 -funswitch-loops
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070073
Elliott Hughes03d2aa42013-02-14 12:04:48 -080074# Modules can choose to compile some source as thumb.
Ying Wange1d44c32013-12-27 11:09:36 -080075$(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \
Dave Bort95282482009-04-23 18:44:55 -070076 -Os \
77 -fomit-frame-pointer \
Jing Yua83b7692010-12-21 16:33:48 -080078 -fno-strict-aliasing
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070079
Dave Bort95282482009-04-23 18:44:55 -070080# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
81# or in your environment to force a full arm build, even for
82# files that are normally built as thumb; this can make
83# gdb debugging easier. Don't forget to do a clean build.
84#
85# NOTE: if you try to build a -O0 build with thumb, several
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070086# of the libraries (libpv, libwebcore, libkjs) need to be built
87# with -mlong-calls. When built at -O0, those libraries are
88# too big for a thumb "BL <label>" to go from one end to the other.
Dave Bort95282482009-04-23 18:44:55 -070089ifeq ($(FORCE_ARM_DEBUGGING),true)
Ying Wange1d44c32013-12-27 11:09:36 -080090 $(combo_2nd_arch_prefix)TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
91 $(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
Dave Bort95282482009-04-23 18:44:55 -070092endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070093
Ying Wange1d44c32013-12-27 11:09:36 -080094$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
Dan Albert4803ce22014-08-06 12:36:46 -070095 -msoft-float \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070096 -ffunction-sections \
Doug Kwanbaff0892010-06-29 11:14:42 -070097 -fdata-sections \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070098 -funwind-tables \
99 -fstack-protector \
Nick Kralevich2915cc32010-05-05 11:09:52 -0700100 -Wa,--noexecstack \
Nick Kralevichd868cad2010-05-14 09:34:59 -0700101 -Werror=format-security \
Nick Kralevich316f7202013-04-25 16:49:10 -0700102 -D_FORTIFY_SOURCE=2 \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -0800103 -fno-short-enums \
Andrew Hsieh48f239c2014-05-09 14:13:13 +0800104 -no-canonical-prefixes \
105 -fno-canonical-system-headers \
Ying Wangf4723fa2013-08-15 11:01:10 -0700106 $(arch_variant_cflags) \
Ben Lesliee03f0232008-10-30 10:41:09 -0500107
Ben Cheng1cea0752013-08-28 11:00:54 -0700108# The "-Wunused-but-set-variable" option often breaks projects that enable
109# "-Wall -Werror" due to a commom idiom "ALOGV(mesg)" where ALOGV is turned
110# into no-op in some builds while mesg is defined earlier. So we explicitly
111# disable "-Wunused-but-set-variable" here.
Rong Xubf8346e2014-12-03 16:27:20 -0800112ifneq ($(filter 4.6 4.6.% 4.7 4.7.% 4.8 4.9, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),)
Ying Wange1d44c32013-12-27 11:09:36 -0800113$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -fno-builtin-sin \
Ben Cheng1cea0752013-08-28 11:00:54 -0700114 -fno-strict-volatile-bitfields
Doug Kwanbe3689e2011-07-14 16:34:26 -0700115endif
116
David 'Digit' Turner3e467782010-06-16 16:04:55 -0700117# This is to avoid the dreaded warning compiler message:
118# note: the mangling of 'va_list' has changed in GCC 4.4
119#
120# The fact that the mangling changed does not affect the NDK ABI
121# very fortunately (since none of the exposed APIs used va_list
122# in their exported C++ functions). Also, GCC 4.5 has already
123# removed the warning from the compiler.
124#
Ying Wange1d44c32013-12-27 11:09:36 -0800125$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -Wno-psabi
David 'Digit' Turner3e467782010-06-16 16:04:55 -0700126
Ying Wange1d44c32013-12-27 11:09:36 -0800127$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \
Nick Kralevich2915cc32010-05-05 11:09:52 -0700128 -Wl,-z,noexecstack \
Nick Kralevich233d4602012-04-26 09:09:24 -0700129 -Wl,-z,relro \
130 -Wl,-z,now \
Dehao Chen734de7a2015-01-14 11:21:22 -0800131 -Wl,--build-id=md5 \
Nick Kralevichb2382102012-08-10 12:51:26 -0700132 -Wl,--warn-shared-textrel \
Nick Kralevich077007e2012-10-18 14:21:26 -0700133 -Wl,--fatal-warnings \
Doug Kwanbaff0892010-06-29 11:14:42 -0700134 -Wl,--icf=safe \
Dmitriy Ivanov179685c2014-11-13 14:51:10 -0800135 -Wl,--hash-style=gnu \
Erik Gillingc12c5182009-07-17 15:57:10 -0700136 $(arch_variant_ldflags)
137
Ying Wange1d44c32013-12-27 11:09:36 -0800138$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mthumb-interwork
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700139
Ying Wange1d44c32013-12-27 11:09:36 -0800140$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700141
Ben Chengefd24892010-10-21 15:15:09 -0700142# More flags/options can be added here
Ying Wange1d44c32013-12-27 11:09:36 -0800143$(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
Mike Reed8dd26ee2009-10-30 08:32:28 -0400144 -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800145 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700146 -Wstrict-aliasing=2 \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700147 -fgcse-after-reload \
148 -frerun-cse-after-loop \
149 -frename-registers
150
151libc_root := bionic/libc
152libm_root := bionic/libm
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700153
Ben Lesliee03f0232008-10-30 10:41:09 -0500154
155## on some hosts, the target cross-compiler is not available so do not run this command
Ying Wange1d44c32013-12-27 11:09:36 -0800156ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200157# We compile with the global cflags to ensure that
Ben Lesliee03f0232008-10-30 10:41:09 -0500158# any flags which affect libgcc are correctly taken
159# into account.
Ying Wange1d44c32013-12-27 11:09:36 -0800160$(combo_2nd_arch_prefix)TARGET_LIBGCC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
161 $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
Andrew Hsieh4c952d72014-05-29 02:47:27 -0700162$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
163 $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
Dan Albert7655a972014-09-24 09:42:39 -0700164$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
165 $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcov.a)
Ben Lesliee03f0232008-10-30 10:41:09 -0500166endif
167
Elliott Hughesdddb5662014-01-10 16:35:08 -0800168KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
Christopher Ferris6a2f2852015-09-16 11:09:04 -0700169KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
Colin Cross3814cbf2014-01-21 16:54:00 -0800170KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_$(combo_2nd_arch_prefix)ARCH)
Christopher Ferris9824ce42013-12-16 13:58:39 -0800171KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700172
Ying Wange1d44c32013-12-27 11:09:36 -0800173$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700174 $(libc_root)/arch-arm/include \
175 $(libc_root)/include \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700176 $(KERNEL_HEADERS) \
177 $(libm_root)/include \
Dima Zavin6d98f5f2010-08-05 17:46:47 -0700178 $(libm_root)/include/arm \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700179
Ying Wange1d44c32013-12-27 11:09:36 -0800180$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
181$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
182$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700183
Ying Wange1d44c32013-12-27 11:09:36 -0800184$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
185$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
David 'Digit' Turner438f5f72010-06-18 15:05:01 -0700186
Dmitriy Ivanov4c2d1a62015-04-20 16:59:05 -0700187$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
Dimitry Ivanov1eca10f2015-04-23 04:22:33 +0000188
Dan Alberte088c0d2014-11-13 10:15:46 -0800189$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker