TARGET_linux-x86.mk revision 90036610ddfe0455553a1b46bb8adbeafde0cac1
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.9
27
28ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
29$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9
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)
44include $(BUILD_SYSTEM)/combo/fdo.mk
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)
63$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := \
64	$(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libatomic.a)
65$(combo_2nd_arch_prefix)TARGET_LIBGCOV := \
66	$(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcov.a)
67endif
68
69$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
70
71libc_root := bionic/libc
72libm_root := bionic/libm
73
74KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
75KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
76KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
77
78android_config_h := $(call select-android-config-h,target_linux-x86)
79
80$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
81			-O2 \
82			-Wa,--noexecstack \
83			-Werror=format-security \
84			-D_FORTIFY_SOURCE=2 \
85			-Wstrict-aliasing=2 \
86			-ffunction-sections \
87			-finline-functions \
88			-finline-limit=300 \
89			-fno-short-enums \
90			-fstrict-aliasing \
91			-funswitch-loops \
92			-funwind-tables \
93			-fstack-protector \
94			-m32 \
95			-no-canonical-prefixes \
96			-fno-canonical-system-headers \
97			-include $(android_config_h) \
98			-I $(dir $(android_config_h))
99
100# Work around gcc 4.9 devirtualization bug, https://b.corp.google.com/19872411.
101$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
102			-fno-devirtualize \
103
104$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
105
106ifeq ($(ARCH_X86_HAVE_SSSE3),true)   # yes, really SSSE3, not SSE3!
107    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3
108endif
109ifeq ($(ARCH_X86_HAVE_SSE4),true)
110    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4
111endif
112ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
113    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.1
114endif
115ifeq ($(ARCH_X86_HAVE_SSE4_2),true)
116    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.2
117endif
118ifeq ($(ARCH_X86_HAVE_AVX),true)
119    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mavx
120endif
121ifeq ($(ARCH_X86_HAVE_AES_NI),true)
122    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -maes
123endif
124
125$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -m32
126
127$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
128$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
129$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--build-id=md5
130$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
131$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
132$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
133$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--hash-style=gnu
134
135$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
136	$(libc_root)/arch-x86/include \
137	$(libc_root)/include \
138	$(KERNEL_HEADERS) \
139	$(libm_root)/include \
140	$(libm_root)/include/i387 \
141
142$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
143$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
144$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
145
146$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
147$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
148
149$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
150
151$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libm
152
153$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
154
155$(combo_2nd_arch_prefix)TARGET_GLOBAL_YASM_FLAGS := -f elf32 -m x86
156