TARGET_linux-x86.mk revision b47c863ec7d7b0d6806d7ea85887c662893a2c70
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_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX) 55 56ifeq ($(TARGET_BUILD_VARIANT),user) 57$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@ 58else 59$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@ && \ 60 $(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@ 61endif 62 63ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),) 64$(combo_2nd_arch_prefix)TARGET_LIBGCC := \ 65 $(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcc.a) 66target_libgcov := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \ 67 -print-file-name=libgcov.a) 68endif 69 70$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined 71 72libc_root := bionic/libc 73libm_root := bionic/libm 74libstdc++_root := bionic/libstdc++ 75 76# Define FDO (Feedback Directed Optimization) options. 77 78$(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS:= 79$(combo_2nd_arch_prefix)TARGET_FDO_LIB:= 80 81ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),) 82 # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation. 83 # The profile will be generated on /data/local/tmp/profile on the device. 84 $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/profile -DANDROID_FDO 85 $(combo_2nd_arch_prefix)TARGET_FDO_LIB := $(target_libgcov) 86else 87 # If BUILD_FDO_INSTRUMENT is turned off, then consider doing the FDO optimizations. 88 # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build. 89 ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),) 90 $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := fdo/profiles/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT) 91 else 92 ifeq ($(strip $(wildcard $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH))),) 93 $(warning Custom $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH supplied, but directory does not exist. Turn off FDO.) 94 endif 95 endif 96 97 # If the FDO profile directory can't be found, then FDO is off. 98 ifneq ($(strip $(wildcard $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH))),) 99 $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) -DANDROID_FDO 100 $(combo_2nd_arch_prefix)TARGET_FDO_LIB := $(target_libgcov) 101 endif 102endif 103 104KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi 105KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64. 106KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) 107 108android_config_h := $(call select-android-config-h,target_linux-x86) 109 110$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \ 111 -O2 \ 112 -Ulinux \ 113 -Wa,--noexecstack \ 114 -Werror=format-security \ 115 -D_FORTIFY_SOURCE=2 \ 116 -Wstrict-aliasing=2 \ 117 -fPIC -fPIE \ 118 -ffunction-sections \ 119 -finline-functions \ 120 -finline-limit=300 \ 121 -fno-inline-functions-called-once \ 122 -fno-short-enums \ 123 -fstrict-aliasing \ 124 -funswitch-loops \ 125 -funwind-tables \ 126 -fstack-protector \ 127 -m32 \ 128 -msse2 \ 129 -include $(android_config_h) \ 130 -I $(dir $(android_config_h)) 131 132$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags) 133 134ifeq ($(ARCH_X86_HAVE_SSSE3),true) # yes, really SSSE3, not SSE3! 135 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3 136endif 137ifeq ($(ARCH_X86_HAVE_SSE4),true) 138 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4 139endif 140ifeq ($(ARCH_X86_HAVE_SSE4_1),true) 141 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.1 142endif 143ifeq ($(ARCH_X86_HAVE_SSE4_2),true) 144 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.2 145endif 146ifeq ($(ARCH_X86_HAVE_AVX),true) 147 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mavx 148endif 149ifeq ($(ARCH_X86_HAVE_AES_NI),true) 150 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -maes 151endif 152 153$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -m32 154 155$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack 156$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now 157$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel 158$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings 159$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections 160 161$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \ 162 $(libc_root)/arch-x86/include \ 163 $(libc_root)/include \ 164 $(libstdc++_root)/include \ 165 $(KERNEL_HEADERS) \ 166 $(libm_root)/include \ 167 $(libm_root)/include/i387 \ 168 169$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o 170$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o 171$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o 172 173$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o 174$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o 175 176$(combo_2nd_arch_prefix)TARGET_STRIP_MODULE:=true 177 178$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm 179 180$(combo_2nd_arch_prefix)TARGET_CUSTOM_LD_COMMAND := true 181define $(combo_2nd_arch_prefix)transform-o-to-shared-lib-inner 182$(hide) $(PRIVATE_CXX) \ 183 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ 184 -nostdlib -Wl,-soname,$(notdir $@) \ 185 -shared -Bsymbolic \ 186 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ 187 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \ 188 $(PRIVATE_ALL_OBJECTS) \ 189 -Wl,--whole-archive \ 190 $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 191 -Wl,--no-whole-archive \ 192 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 193 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 194 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 195 $(PRIVATE_TARGET_LIBGCC) \ 196 $(PRIVATE_TARGET_FDO_LIB) \ 197 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 198 -o $@ \ 199 $(PRIVATE_LDFLAGS) \ 200 $(PRIVATE_TARGET_LIBGCC) \ 201 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) 202endef 203 204define $(combo_2nd_arch_prefix)transform-o-to-executable-inner 205$(hide) $(PRIVATE_CXX) \ 206 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ 207 -nostdlib -Bdynamic \ 208 -Wl,-z,nocopyreloc \ 209 -fPIE -pie \ 210 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ 211 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ 212 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \ 213 $(PRIVATE_ALL_OBJECTS) \ 214 -Wl,--whole-archive \ 215 $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 216 -Wl,--no-whole-archive \ 217 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 218 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 219 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 220 $(PRIVATE_TARGET_LIBGCC) \ 221 $(PRIVATE_TARGET_FDO_LIB) \ 222 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 223 -o $@ \ 224 $(PRIVATE_LDFLAGS) \ 225 $(PRIVATE_TARGET_LIBGCC) \ 226 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) 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 $(PRIVATE_TARGET_LIBGCC) \ 245 -Wl,--end-group \ 246 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) 247endef 248