Android.common_build.mk revision 1e13374baf7dfaf442ffbf9809c37c131d681eaf
1afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
2afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# Copyright (C) 2011 The Android Open Source Project
3afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
4afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# Licensed under the Apache License, Version 2.0 (the "License");
5afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# you may not use this file except in compliance with the License.
6afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# You may obtain a copy of the License at
7afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
8afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#      http://www.apache.org/licenses/LICENSE-2.0
9afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
10afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# Unless required by applicable law or agreed to in writing, software
11afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# distributed under the License is distributed on an "AS IS" BASIS,
12afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# See the License for the specific language governing permissions and
14afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# limitations under the License.
15afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
16afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
173774335b08076117d6950cd472cdd59a167470b5Igor Murashkinifndef ART_ANDROID_COMMON_BUILD_MK
183774335b08076117d6950cd472cdd59a167470b5Igor MurashkinART_ANDROID_COMMON_BUILD_MK = true
19afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
20afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersinclude art/build/Android.common.mk
213774335b08076117d6950cd472cdd59a167470b5Igor Murashkininclude art/build/Android.common_utils.mk
22afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
23afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# These can be overridden via the environment or by editing to
24afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# enable/disable certain build configuration.
25afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
26afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# For example, to disable everything but the host debug build you use:
27afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
28afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# (export ART_BUILD_TARGET_NDEBUG=false && export ART_BUILD_TARGET_DEBUG=false && export ART_BUILD_HOST_NDEBUG=false && ...)
29afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
30afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# Beware that tests may use the non-debug build for performance, notable 055-enum-performance
31afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
32afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_BUILD_TARGET_NDEBUG ?= true
33afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_BUILD_TARGET_DEBUG ?= true
34afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_BUILD_HOST_NDEBUG ?= true
35afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_BUILD_HOST_DEBUG ?= true
36dc5616146966369550f66e2a8866e142763bbefeCalin JuravleART_BUILD_HOST_STATIC ?= true
37afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
384895ea4eb55a06003cc08cda55a6dca1c42a1794Calin Juravle# Asan does not support static linkage
394895ea4eb55a06003cc08cda55a6dca1c42a1794Calin Juravleifdef SANITIZE_HOST
404895ea4eb55a06003cc08cda55a6dca1c42a1794Calin Juravle  ART_BUILD_HOST_STATIC := false
414895ea4eb55a06003cc08cda55a6dca1c42a1794Calin Juravleendif
424895ea4eb55a06003cc08cda55a6dca1c42a1794Calin Juravle
430e26f464d94eeb8cc09d881c46adfe35640c8d9aCalin Juravleifneq ($(HOST_OS),linux)
444895ea4eb55a06003cc08cda55a6dca1c42a1794Calin Juravle  ART_BUILD_HOST_STATIC := false
454895ea4eb55a06003cc08cda55a6dca1c42a1794Calin Juravleendif
464895ea4eb55a06003cc08cda55a6dca1c42a1794Calin Juravle
47afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(ART_BUILD_TARGET_NDEBUG),false)
48afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers$(info Disabling ART_BUILD_TARGET_NDEBUG)
49afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
50afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(ART_BUILD_TARGET_DEBUG),false)
51afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers$(info Disabling ART_BUILD_TARGET_DEBUG)
52afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
53afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(ART_BUILD_HOST_NDEBUG),false)
54afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers$(info Disabling ART_BUILD_HOST_NDEBUG)
55afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
56afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(ART_BUILD_HOST_DEBUG),false)
57afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers$(info Disabling ART_BUILD_HOST_DEBUG)
58afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
5965e069df6f864102b062fc04de8877f8230034a8Calin Juravleifeq ($(ART_BUILD_HOST_STATIC),true)
6065e069df6f864102b062fc04de8877f8230034a8Calin Juravle$(info Enabling ART_BUILD_HOST_STATIC)
6165e069df6f864102b062fc04de8877f8230034a8Calin Juravleendif
62afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
63afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
64e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier# Used to enable JIT
65e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier#
66e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu ChartierART_JIT := false
67e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartierifneq ($(wildcard art/JIT_ART),)
68e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier$(info Enabling ART_JIT because of existence of art/JIT_ART)
69e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu ChartierART_JIT := true
70e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartierendif
71e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartierifeq ($(WITH_ART_JIT), true)
72e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu ChartierART_JIT := true
73e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartierendif
74e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier
75e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier#
76afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
77afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers#
783e781622a67e6d83e76e1bf765e9d84b3c718dc9Hiroshi YamauchiART_DEFAULT_GC_TYPE ?= CMS
793e781622a67e6d83e76e1bf765e9d84b3c718dc9Hiroshi Yamauchiart_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(ART_DEFAULT_GC_TYPE)
80afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
81ee0ebc81ba294710f90f0c8c934db1debae437aaAndreas GampeART_HOST_CFLAGS :=
82ee0ebc81ba294710f90f0c8c934db1debae437aaAndreas GampeART_TARGET_CFLAGS :=
83ee0ebc81ba294710f90f0c8c934db1debae437aaAndreas Gampe
8412bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland LevillainART_HOST_ASFLAGS :=
8512bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland LevillainART_TARGET_ASFLAGS :=
8612bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland Levillain
87afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# Clang build support.
88afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
89afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# Host.
90afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_HOST_CLANG := false
91afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifneq ($(WITHOUT_HOST_CLANG),true)
92afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  # By default, host builds use clang for better warnings.
93afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_HOST_CLANG := true
94afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
95afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
96ea521dccd5dea59bcdfda7cc61cdd413152a8890Sebastien Hertz# Clang on the target. Target builds use GCC by default.
9788c05693f090bc2562a530a4696082229de98840Bernhard Rosenkraenzerifneq ($(USE_CLANG_PLATFORM_BUILD),)
9888c05693f090bc2562a530a4696082229de98840Bernhard RosenkraenzerART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
9988c05693f090bc2562a530a4696082229de98840Bernhard Rosenkraenzerelse
100d642a91052cd28735bf38cc4a79421ec24d1ee72Ian RogersART_TARGET_CLANG := false
10188c05693f090bc2562a530a4696082229de98840Bernhard Rosenkraenzerendif
102afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_TARGET_CLANG_arm :=
103ea521dccd5dea59bcdfda7cc61cdd413152a8890Sebastien HertzART_TARGET_CLANG_arm64 :=
10491ddd0d2db1f04368591d74505d8ea4c77c56030Duane SandART_TARGET_CLANG_mips :=
10591ddd0d2db1f04368591d74505d8ea4c77c56030Duane SandART_TARGET_CLANG_mips64 :=
106afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_TARGET_CLANG_x86 :=
107afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_TARGET_CLANG_x86_64 :=
108afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
109afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersdefine set-target-local-clang-vars
110afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers    LOCAL_CLANG := $(ART_TARGET_CLANG)
111afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers    $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
112afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers      ifneq ($$(ART_TARGET_CLANG_$(arch)),)
113afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers        LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
114afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers      endif)
115afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendef
116afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
1176f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_CLANG_CFLAGS :=
1186f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_CLANG_CFLAGS_arm :=
1196f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_CLANG_CFLAGS_arm64 :=
1206f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_CLANG_CFLAGS_mips :=
1211a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeART_TARGET_CLANG_CFLAGS_mips64 :=
1226f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_CLANG_CFLAGS_x86 :=
1236f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_CLANG_CFLAGS_x86_64 :=
1246f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers
1256f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# These are necessary for Clang ARM64 ART builds. TODO: remove.
1266f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_CLANG_CFLAGS_arm64  += \
127685fbe422ce8103933f709b29c97bbe32647c75eAndreas Gampe  -DNVALGRIND
1286f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers
1296f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# Warn about thread safety violations with clang.
1306c7cdc5eb809a72e5d0457d0220f9ad8458fe831Dan Albertart_clang_cflags := -Wthread-safety
1316f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers
1326f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# Warn if switch fallthroughs aren't annotated.
1336f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_clang_cflags += -Wimplicit-fallthrough
1346f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers
1356f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# Enable float equality warnings.
1366f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_clang_cflags += -Wfloat-equal
1376f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers
138277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# Enable warning of converting ints to void*.
139277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampeart_clang_cflags += -Wint-to-void-pointer-cast
140277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe
141ca71458862be8505330b7fd5649a062f31d143dcAndreas Gampe# Enable warning of wrong unused annotations.
142ca71458862be8505330b7fd5649a062f31d143dcAndreas Gampeart_clang_cflags += -Wused-but-marked-unused
143ca71458862be8505330b7fd5649a062f31d143dcAndreas Gampe
144758a801b66c134361a7b43f7e83f85d1fb800c4cAndreas Gampe# Enable warning for deprecated language features.
145758a801b66c134361a7b43f7e83f85d1fb800c4cAndreas Gampeart_clang_cflags += -Wdeprecated
146758a801b66c134361a7b43f7e83f85d1fb800c4cAndreas Gampe
147662226652394d0388b0f6a3c9f79a317de273c8fAndreas Gampe# Enable warning for unreachable break & return.
148662226652394d0388b0f6a3c9f79a317de273c8fAndreas Gampeart_clang_cflags += -Wunreachable-code-break -Wunreachable-code-return
149662226652394d0388b0f6a3c9f79a317de273c8fAndreas Gampe
150662226652394d0388b0f6a3c9f79a317de273c8fAndreas Gampe# Enable missing-noreturn only on non-Mac. As lots of things are not implemented for Apple, it's
151662226652394d0388b0f6a3c9f79a317de273c8fAndreas Gampe# a pain.
152662226652394d0388b0f6a3c9f79a317de273c8fAndreas Gampeifneq ($(HOST_OS),darwin)
153662226652394d0388b0f6a3c9f79a317de273c8fAndreas Gampe  art_clang_cflags += -Wmissing-noreturn
154662226652394d0388b0f6a3c9f79a317de273c8fAndreas Gampeendif
15565b798ea10dd716c1bb3dda029f9bf255435af72Andreas Gampe
156ca71458862be8505330b7fd5649a062f31d143dcAndreas Gampe
157277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# GCC-only warnings.
158277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampeart_gcc_cflags := -Wunused-but-set-parameter
159277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# Suggest const: too many false positives, but good for a trial run.
160277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe#                  -Wsuggest-attribute=const
161277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
162277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe#                  -Wuseless-cast
163277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
164277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# that are still stuck pre-C++11.
165277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe#                  -Wzero-as-null-pointer-constant \
166277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# Suggest final: Have to move to a more recent GCC.
167277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe#                  -Wsuggest-final-types
168277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe
169bced67d061049b607ce02a9813ef9dd0c87f8081Andreas GampeART_TARGET_CLANG_CFLAGS := $(art_clang_cflags)
1706f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersifeq ($(ART_HOST_CLANG),true)
1714ad5cd3e7d519484559ef778d96fb3f0be8919faIan Rogers  # Bug: 15446488. We don't omit the frame pointer to work around
1724ad5cd3e7d519484559ef778d96fb3f0be8919faIan Rogers  # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
1734ad5cd3e7d519484559ef778d96fb3f0be8919faIan Rogers  ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
174277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampeelse
175277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe  ART_HOST_CFLAGS += $(art_gcc_cflags)
1766f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersendif
177bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampeifneq ($(ART_TARGET_CLANG),true)
178277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe  ART_TARGET_CFLAGS += $(art_gcc_cflags)
179bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampeelse
180bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampe  # TODO: if we ever want to support GCC/Clang mix for multi-target products, this needs to be
181bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampe  #       split up.
182bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampe  ifeq ($(ART_TARGET_CLANG_$(TARGET_ARCH)),false)
183bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampe    ART_TARGET_CFLAGS += $(art_gcc_cflags)
184bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampe  endif
1856f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersendif
1866f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers
187277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# Clear local variables now their use has ended.
1886f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_clang_cflags :=
189277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampeart_gcc_cflags :=
1906f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers
191afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_CPP_EXTENSION := .cc
192afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
193afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_C_INCLUDES := \
194afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  external/gtest/include \
195848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao  external/icu/icu4c/source/common \
1966130f739d8f35e01037ba5c3ec5e5a1057900479Dmitriy Ivanov  external/valgrind/include \
1976130f739d8f35e01037ba5c3ec5e5a1057900479Dmitriy Ivanov  external/valgrind \
198afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  external/vixl/src \
199afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  external/zlib \
200afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
2016f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# Base set of cflags used by all things ART.
202afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersart_cflags := \
203afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  -fno-rtti \
204afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  -std=gnu++11 \
205afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  -ggdb3 \
206afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  -Wall \
207afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  -Werror \
208afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  -Wextra \
209afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  -Wstrict-aliasing \
21029b3841ad8c1c18ee7ddd2d8cab85806b3d62eaaAndreas Gampe  -fstrict-aliasing \
21107140838a3ee44a6056cacdc78f2930e019107daIan Rogers  -Wunreachable-code \
212277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe  -Wredundant-decls \
213277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe  -Wshadow \
2147c3952f423b8213083d60596a5f0bf4237ca3f7bAndreas Gampe  -Wunused \
2156f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers  -fvisibility=protected \
2166f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers  $(art_default_gc_type_cflags)
217afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
21812bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland Levillain# Base set of asflags used by all things ART.
21912bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland Levillainart_asflags :=
22012bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland Levillain
221277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe# Missing declarations: too many at the moment, as we use "extern" quite a bit.
222277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe#  -Wmissing-declarations \
223277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe
224277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe
225cd195fe131842ad9ca7909203d479d325feaf9ddMathieu Chartier
226cd195fe131842ad9ca7909203d479d325feaf9ddMathieu Chartierifdef ART_IMT_SIZE
227cd195fe131842ad9ca7909203d479d325feaf9ddMathieu Chartier  art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
228cd195fe131842ad9ca7909203d479d325feaf9ddMathieu Chartierelse
229cd195fe131842ad9ca7909203d479d325feaf9ddMathieu Chartier  # Default is 64
230cd195fe131842ad9ca7909203d479d325feaf9ddMathieu Chartier  art_cflags += -DIMT_SIZE=64
231cd195fe131842ad9ca7909203d479d325feaf9ddMathieu Chartierendif
232cd195fe131842ad9ca7909203d479d325feaf9ddMathieu Chartier
2339bb492a33c97e72d0c43a4ee968e34cc32534981Nicolas Geoffrayifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
2349bb492a33c97e72d0c43a4ee968e34cc32534981Nicolas Geoffray  art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
2359bb492a33c97e72d0c43a4ee968e34cc32534981Nicolas Geoffrayendif
2369bb492a33c97e72d0c43a4ee968e34cc32534981Nicolas Geoffray
237b0d22f178c0a8d1ee7d3692f282bb46c53cc2036Hiroshi Yamauchiifeq ($(ART_HEAP_POISONING),true)
238b0d22f178c0a8d1ee7d3692f282bb46c53cc2036Hiroshi Yamauchi  art_cflags += -DART_HEAP_POISONING=1
23912bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland Levillain  art_asflags += -DART_HEAP_POISONING=1
240b0d22f178c0a8d1ee7d3692f282bb46c53cc2036Hiroshi Yamauchiendif
241b0d22f178c0a8d1ee7d3692f282bb46c53cc2036Hiroshi Yamauchi
242c23f0d88bee65433a94f84c7cabe50be863905a5Hiroshi Yamauchiifeq ($(ART_USE_READ_BARRIER),true)
243c23f0d88bee65433a94f84c7cabe50be863905a5Hiroshi Yamauchi  art_cflags += -DART_USE_READ_BARRIER=1
24412bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland Levillain  art_asflags += -DART_USE_READ_BARRIER=1
245c23f0d88bee65433a94f84c7cabe50be863905a5Hiroshi Yamauchiendif
246c23f0d88bee65433a94f84c7cabe50be863905a5Hiroshi Yamauchi
24779bd2bfa8f1602067fd381834206ed6b7e73a9beHiroshi Yamauchiifeq ($(ART_USE_TLAB),true)
24879bd2bfa8f1602067fd381834206ed6b7e73a9beHiroshi Yamauchi  art_cflags += -DART_USE_TLAB=1
24979bd2bfa8f1602067fd381834206ed6b7e73a9beHiroshi Yamauchiendif
25079bd2bfa8f1602067fd381834206ed6b7e73a9beHiroshi Yamauchi
2516f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# Cflags for non-debug ART and ART tools.
252afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersart_non_debug_cflags := \
253afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  -O3
254afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
2556f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# Cflags for debug ART and ART tools.
2566f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_debug_cflags := \
25740e7f0e25fe8c0d50e1ade5c28730bb07fe399ceNicolas Geoffray  -O2 \
2586f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers  -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
25932f5b4d2c8c9b52e9522941c159577b21752d0faSerban Constantinescu  -DVIXL_DEBUG \
26050fe6daa14e4f1f43ccacce9f03003570ea8c09fIan Rogers  -UNDEBUG
26167a4338c5cc91ad3a8a3b99f06e1cf03b232d156Stephen Hines
2626f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_host_non_debug_cflags := $(art_non_debug_cflags)
2636f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_target_non_debug_cflags := $(art_non_debug_cflags)
26467a4338c5cc91ad3a8a3b99f06e1cf03b232d156Stephen Hines
265afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(HOST_OS),linux)
26667a4338c5cc91ad3a8a3b99f06e1cf03b232d156Stephen Hines  # Larger frame-size for host clang builds today
26731fb26054349db03b3f1627fe975ed099ade69ddDan Albert  ifneq ($(ART_COVERAGE),true)
26831fb26054349db03b3f1627fe975ed099ade69ddDan Albert    ifneq ($(NATIVE_COVERAGE),true)
2691e13374baf7dfaf442ffbf9809c37c131d681eafEvgenii Stepanov      art_host_non_debug_cflags += -Wframe-larger-than=2700
2701e13374baf7dfaf442ffbf9809c37c131d681eafEvgenii Stepanov      ifdef SANITIZE_TARGET
2711e13374baf7dfaf442ffbf9809c37c131d681eafEvgenii Stepanov        art_target_non_debug_cflags += -Wframe-larger-than=5450
2721e13374baf7dfaf442ffbf9809c37c131d681eafEvgenii Stepanov      else
273e1b6e974ad2e5695bc166cb363050208d77ded45Evgenii Stepanov        art_target_non_debug_cflags += -Wframe-larger-than=1728
274e1b6e974ad2e5695bc166cb363050208d77ded45Evgenii Stepanov      endif
27531fb26054349db03b3f1627fe975ed099ade69ddDan Albert    endif
27698b8bcf433e7bd8f1a447f7bf8d6cf80ec505c5eDan Albert  endif
277afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
278afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
279a28ff0f8a4df47a53041a69e611b841d8d38b3a1Ying Wangifndef LIBART_IMG_HOST_BASE_ADDRESS
280a28ff0f8a4df47a53041a69e611b841d8d38b3a1Ying Wang  $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
281a28ff0f8a4df47a53041a69e611b841d8d38b3a1Ying Wangendif
282a28ff0f8a4df47a53041a69e611b841d8d38b3a1Ying WangART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
283a28ff0f8a4df47a53041a69e611b841d8d38b3a1Ying WangART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
28412bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland LevillainART_HOST_ASFLAGS += $(art_asflags)
285afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
286a28ff0f8a4df47a53041a69e611b841d8d38b3a1Ying Wangifndef LIBART_IMG_TARGET_BASE_ADDRESS
287a28ff0f8a4df47a53041a69e611b841d8d38b3a1Ying Wang  $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
288afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
289a28ff0f8a4df47a53041a69e611b841d8d38b3a1Ying WangART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
29012bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland LevillainART_TARGET_ASFLAGS += $(art_asflags)
291a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light
2926f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
2936f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
2946f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
2956f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
2966f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers
297a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
298a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
299a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightendif
300a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
301a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
302a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightendif
303a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex LightART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
304a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex LightART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
305a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light
306a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
307a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
308a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightendif
309a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
310a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
311a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightendif
312a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex LightART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
313a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex LightART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
314a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light
315afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
316afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
317afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
3186f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# Clear locals now they've served their purpose.
3196f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_cflags :=
32012bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland Levillainart_asflags :=
3216f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_debug_cflags :=
3226f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_non_debug_cflags :=
3236f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_host_non_debug_cflags :=
3246f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_target_non_debug_cflags :=
3256f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_default_gc_type :=
3266f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersart_default_gc_type_cflags :=
327afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
3286f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_HOST_LDLIBS :=
3296f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogersifneq ($(ART_HOST_CLANG),true)
3306f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers  # GCC lacks libc++ assumed atomic operations, grab via libatomic.
3316f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers  ART_HOST_LDLIBS += -latomic
332afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
333afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
3346f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian RogersART_TARGET_LDFLAGS :=
335afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
336afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers# $(1): ndebug_or_debug
337afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersdefine set-target-local-cflags-vars
338afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
339afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
34012bd7210bb2f5738e33dfa3f2f1cba2e0aab4955Roland Levillain  LOCAL_ASFLAGS += $(ART_TARGET_ASFLAGS)
341997660dec8b10bba56276f35a9ee8d7ce9d62fc2Dehao Chen  LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
342afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  art_target_cflags_ndebug_or_debug := $(1)
343afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
344afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers    LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
345afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  else
346afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers    LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
347afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  endif
348afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
349bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampe  LOCAL_CLANG_CFLAGS := $(ART_TARGET_CLANG_CFLAGS)
350afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  $(foreach arch,$(ART_SUPPORTED_ARCH),
351bced67d061049b607ce02a9813ef9dd0c87f8081Andreas Gampe    LOCAL_CLANG_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch)))
352afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
353afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  # Clear locally used variables.
354afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  art_target_cflags_ndebug_or_debug :=
355afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendef
356afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
3576f3dbbadf4ce66982eb3d400e0a74cb73eb034f3Ian Rogers# Support for disabling certain builds.
358afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_BUILD_TARGET := false
359afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_BUILD_HOST := false
360afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_BUILD_NDEBUG := false
361afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian RogersART_BUILD_DEBUG := false
362afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(ART_BUILD_TARGET_NDEBUG),true)
363afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_BUILD_TARGET := true
364afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_BUILD_NDEBUG := true
365afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
366afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(ART_BUILD_TARGET_DEBUG),true)
367afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_BUILD_TARGET := true
368afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_BUILD_DEBUG := true
369afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
370afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(ART_BUILD_HOST_NDEBUG),true)
371afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_BUILD_HOST := true
372afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_BUILD_NDEBUG := true
373afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
374afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersifeq ($(ART_BUILD_HOST_DEBUG),true)
375afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_BUILD_HOST := true
376afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers  ART_BUILD_DEBUG := true
377afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogersendif
378afd9acc30bdd11cdd12d8209eb994cb371c65e33Ian Rogers
3793774335b08076117d6950cd472cdd59a167470b5Igor Murashkinendif # ART_ANDROID_COMMON_BUILD_MK
380