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