TARGET_linux-x86.mk revision ce1c596e1507295f3037e9fa7bf163fb2ab95a11
1# 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 17# Configuration for Linux on x86 as a target. 18# Included by combo/select.mk 19 20# Provide a default variant. 21ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),) 22TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := x86 23endif 24 25ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),) 26$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.8 27else 28$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP) 29endif 30 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 34# 35TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT).mk 36ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),) 37$(error Unknown $(TARGET_$(combo_2nd_arch_prefix)ARCH) architecture version: $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)) 38endif 39 40include $(TARGET_ARCH_SPECIFIC_MAKEFILE) 41 42 43# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else 44ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),) 45$(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION) 46$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/x86_64-linux-android- 47endif 48 49$(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) 50$(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) 51$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) 52$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX) 53$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX) 54$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX) 55$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX) 56 57ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),) 58$(combo_2nd_arch_prefix)TARGET_LIBGCC := \ 59 $(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcc.a) 60target_libgcov := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \ 61 -print-file-name=libgcov.a) 62endif 63 64$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined 65 66libc_root := bionic/libc 67libm_root := bionic/libm 68libstdc++_root := bionic/libstdc++ 69 70# Define FDO (Feedback Directed Optimization) options. 71 72$(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS:= 73$(combo_2nd_arch_prefix)TARGET_FDO_LIB:= 74 75ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),) 76 # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation. 77 # The profile will be generated on /data/local/tmp/profile on the device. 78 $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/profile -DANDROID_FDO 79 $(combo_2nd_arch_prefix)TARGET_FDO_LIB := $(target_libgcov) 80else 81 # If BUILD_FDO_INSTRUMENT is turned off, then consider doing the FDO optimizations. 82 # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build. 83 ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),) 84 $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := fdo/profiles/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT) 85 else 86 ifeq ($(strip $(wildcard $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH))),) 87 $(warning Custom $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH supplied, but directory does not exist. Turn off FDO.) 88 endif 89 endif 90 91 # If the FDO profile directory can't be found, then FDO is off. 92 ifneq ($(strip $(wildcard $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH))),) 93 $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) -DANDROID_FDO 94 $(combo_2nd_arch_prefix)TARGET_FDO_LIB := $(target_libgcov) 95 endif 96endif 97 98KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi 99KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64. 100KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) 101 102android_config_h := $(call select-android-config-h,target_linux-x86) 103 104$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \ 105 -O2 \ 106 -Ulinux \ 107 -Wa,--noexecstack \ 108 -Werror=format-security \ 109 -D_FORTIFY_SOURCE=2 \ 110 -Wstrict-aliasing=2 \ 111 -fPIC -fPIE \ 112 -ffunction-sections \ 113 -finline-functions \ 114 -finline-limit=300 \ 115 -fno-inline-functions-called-once \ 116 -fno-short-enums \ 117 -fstrict-aliasing \ 118 -funswitch-loops \ 119 -funwind-tables \ 120 -fstack-protector \ 121 -m32 \ 122 -msse2 \ 123 -include $(android_config_h) \ 124 -I $(dir $(android_config_h)) 125 126$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags) 127 128ifeq ($(ARCH_X86_HAVE_SSSE3),true) # yes, really SSSE3, not SSE3! 129 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3 130endif 131ifeq ($(ARCH_X86_HAVE_SSE4),true) 132 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4 133endif 134ifeq ($(ARCH_X86_HAVE_SSE4_1),true) 135 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.1 136endif 137ifeq ($(ARCH_X86_HAVE_SSE4_2),true) 138 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.2 139endif 140ifeq ($(ARCH_X86_HAVE_AVX),true) 141 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mavx 142endif 143ifeq ($(ARCH_X86_HAVE_AES_NI),true) 144 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -maes 145endif 146 147$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -m32 148 149$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack 150$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now 151$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel 152$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings 153$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections 154 155$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \ 156 $(libc_root)/arch-x86/include \ 157 $(libc_root)/include \ 158 $(libstdc++_root)/include \ 159 $(KERNEL_HEADERS) \ 160 $(libm_root)/include \ 161 $(libm_root)/include/i387 \ 162 163$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o 164$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o 165$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o 166 167$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o 168$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o 169 170$(combo_2nd_arch_prefix)TARGET_STRIP_MODULE:=true 171 172$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm 173 174$(combo_2nd_arch_prefix)TARGET_CUSTOM_LD_COMMAND := true 175define $(combo_2nd_arch_prefix)transform-o-to-shared-lib-inner 176$(hide) $(PRIVATE_CXX) \ 177 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ 178 -nostdlib -Wl,-soname,$(notdir $@) \ 179 -shared -Bsymbolic \ 180 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ 181 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \ 182 $(PRIVATE_ALL_OBJECTS) \ 183 -Wl,--whole-archive \ 184 $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 185 -Wl,--no-whole-archive \ 186 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 187 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 188 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 189 $(PRIVATE_TARGET_LIBGCC) \ 190 $(PRIVATE_TARGET_FDO_LIB) \ 191 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 192 -o $@ \ 193 $(PRIVATE_LDFLAGS) \ 194 $(PRIVATE_TARGET_LIBGCC) \ 195 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) 196endef 197 198define $(combo_2nd_arch_prefix)transform-o-to-executable-inner 199$(hide) $(PRIVATE_CXX) \ 200 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ 201 -nostdlib -Bdynamic \ 202 -Wl,-z,nocopyreloc \ 203 -fPIE -pie \ 204 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ 205 -Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \ 206 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \ 207 $(PRIVATE_ALL_OBJECTS) \ 208 -Wl,--whole-archive \ 209 $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 210 -Wl,--no-whole-archive \ 211 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 212 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 213 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 214 $(PRIVATE_TARGET_LIBGCC) \ 215 $(PRIVATE_TARGET_FDO_LIB) \ 216 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 217 -o $@ \ 218 $(PRIVATE_LDFLAGS) \ 219 $(PRIVATE_TARGET_LIBGCC) \ 220 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) 221endef 222 223define $(combo_2nd_arch_prefix)transform-o-to-static-executable-inner 224$(hide) $(PRIVATE_CXX) \ 225 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ 226 -nostdlib -Bstatic \ 227 -o $@ \ 228 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ 229 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_STATIC_O)) \ 230 $(PRIVATE_LDFLAGS) \ 231 $(PRIVATE_ALL_OBJECTS) \ 232 -Wl,--whole-archive \ 233 $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 234 -Wl,--no-whole-archive \ 235 -Wl,--start-group \ 236 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 237 $(PRIVATE_TARGET_FDO_LIB) \ 238 $(PRIVATE_TARGET_LIBGCC) \ 239 -Wl,--end-group \ 240 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) 241endef 242