2 # Copyright (C) 2006 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Configuration for Linux on x86 as a target.
18 # Included by combo/select.mk
20 # Provide a default variant.
21 ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
22 TARGET_ARCH_VARIANT := x86
25 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
26 TARGET_GCC_VERSION := 4.8
28 TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
31 # Include the arch-variant-specific configuration file.
32 # Its role is to define various ARCH_X86_HAVE_XXX feature macros,
33 # plus initial values for TARGET_GLOBAL_CFLAGS
35 TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
36 ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
37 $(error Unknown $(TARGET_ARCH) architecture version: $(TARGET_ARCH_VARIANT))
40 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
43 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
44 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
45 TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-$(TARGET_GCC_VERSION)
46 TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/x86_64-linux-android-
49 TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
50 TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
51 TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
52 TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
53 TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
54 TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
56 ifeq ($(TARGET_BUILD_VARIANT),user)
57 TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
59 TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ && \
60 $(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@
63 ifneq ($(wildcard $(TARGET_CC)),)
65 $(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a)
66 target_libgcov := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
67 -print-file-name=libgcov.a)
70 TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
72 libc_root := bionic/libc
73 libm_root := bionic/libm
74 libstdc++_root := bionic/libstdc++
75 libthread_db_root := bionic/libthread_db
77 # Define FDO (Feedback Directed Optimization) options.
82 ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
83 # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
84 # The profile will be generated on /data/local/tmp/profile on the device.
85 TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/profile -DANDROID_FDO
86 TARGET_FDO_LIB := $(target_libgcov)
88 # If BUILD_FDO_INSTRUMENT is turned off, then consider doing the FDO optimizations.
89 # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
90 ifeq ($(strip $(TARGET_FDO_PROFILE_PATH)),)
91 TARGET_FDO_PROFILE_PATH := fdo/profiles/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT)
93 ifeq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
94 $(warning Custom TARGET_FDO_PROFILE_PATH supplied, but directory does not exist. Turn off FDO.)
98 # If the FDO profile directory can't be found, then FDO is off.
99 ifneq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
100 TARGET_FDO_CFLAGS := -fprofile-use=$(TARGET_FDO_PROFILE_PATH) -DANDROID_FDO
101 TARGET_FDO_LIB := $(target_libgcov)
105 # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
106 # symlinks located in out/ to point to the appropriate kernel
107 # headers. see 'config/kernel_headers.make' for more details
109 ifneq ($(CUSTOM_KERNEL_HEADERS),)
110 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
111 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
113 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
114 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
115 KERNEL_HEADERS_AUX := $(libc_root)/kernel/common
117 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) $(KERNEL_HEADERS_AUX)
119 TARGET_GLOBAL_CFLAGS += \
123 -Werror=format-security \
124 -D_FORTIFY_SOURCE=2 \
125 -Wstrict-aliasing=2 \
127 -ffunction-sections \
130 -fno-inline-functions-called-once \
138 android_config_h := $(call select-android-config-h,target_linux-x86)
139 TARGET_ANDROID_CONFIG_CFLAGS := -include $(android_config_h) -I $(dir $(android_config_h))
140 TARGET_GLOBAL_CFLAGS += $(TARGET_ANDROID_CONFIG_CFLAGS)
142 TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
144 ifeq ($(ARCH_X86_HAVE_SSSE3),true) # yes, really SSSE3, not SSE3!
145 TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3
147 ifeq ($(ARCH_X86_HAVE_SSE4),true)
148 TARGET_GLOBAL_CFLAGS += -msse4
150 ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
151 TARGET_GLOBAL_CFLAGS += -msse4.1
153 ifeq ($(ARCH_X86_HAVE_SSE4_2),true)
154 TARGET_GLOBAL_CFLAGS += -msse4.2
156 ifeq ($(ARCH_X86_HAVE_AVX),true)
157 TARGET_GLOBAL_CFLAGS += -mavx
159 ifeq ($(ARCH_X86_HAVE_AES_NI),true)
160 TARGET_GLOBAL_CFLAGS += -maes
163 TARGET_GLOBAL_LDFLAGS += -m32
165 TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
166 TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
167 TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
168 TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
169 TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
171 TARGET_C_INCLUDES := \
172 $(libc_root)/arch-x86/include \
173 $(libc_root)/include \
174 $(libstdc++_root)/include \
176 $(libm_root)/include \
177 $(libm_root)/include/i387 \
178 $(libthread_db_root)/include
180 TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
181 TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
182 TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
184 TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
185 TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
187 TARGET_STRIP_MODULE:=true
189 TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
191 TARGET_CUSTOM_LD_COMMAND := true
192 define transform-o-to-shared-lib-inner
193 $(hide) $(PRIVATE_CXX) \
194 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
195 -nostdlib -Wl,-soname,$(notdir $@) \
197 $(TARGET_GLOBAL_CFLAGS) \
198 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
199 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
200 $(PRIVATE_ALL_OBJECTS) \
201 -Wl,--whole-archive \
202 $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
203 -Wl,--no-whole-archive \
204 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
205 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
206 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
207 $(PRIVATE_TARGET_LIBGCC) \
208 $(PRIVATE_TARGET_FDO_LIB) \
209 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
212 $(PRIVATE_TARGET_LIBGCC) \
213 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
216 define transform-o-to-executable-inner
217 $(hide) $(PRIVATE_CXX) \
218 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
219 -nostdlib -Bdynamic \
222 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
223 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
224 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
225 $(PRIVATE_ALL_OBJECTS) \
226 -Wl,--whole-archive \
227 $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
228 -Wl,--no-whole-archive \
229 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
230 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
231 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
232 $(PRIVATE_TARGET_LIBGCC) \
233 $(PRIVATE_TARGET_FDO_LIB) \
234 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
237 $(PRIVATE_TARGET_LIBGCC) \
238 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))
241 define transform-o-to-static-executable-inner
242 $(hide) $(PRIVATE_CXX) \
243 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
246 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
247 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_STATIC_O)) \
249 $(PRIVATE_ALL_OBJECTS) \
250 -Wl,--whole-archive \
251 $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
252 -Wl,--no-whole-archive \
254 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
255 $(PRIVATE_TARGET_FDO_LIB) \
256 $(PRIVATE_TARGET_LIBGCC) \
258 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))