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