TARGET_linux-x86_64.mk revision 0ba68bafa3b465110d10da1a57a1843ff91b2f3a
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_64 as a target.
18# Included by combo/select.mk
19
20# Provide a default variant.
21ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
22TARGET_ARCH_VARIANT := x86_64
23endif
24
25# Decouple NDK library selection with platform compiler version
26TARGET_NDK_GCC_VERSION := 4.9
27
28ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
29TARGET_GCC_VERSION := 4.9
30else
31TARGET_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_ARCH)/$(TARGET_ARCH_VARIANT).mk
39ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
40$(error Unknown $(TARGET_ARCH) architecture version: $(TARGET_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 $(TARGET_TOOLS_PREFIX)),)
48TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-$(TARGET_GCC_VERSION)
49TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/x86_64-linux-android-
50endif
51
52TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
53TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
54TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
55TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
56TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
57TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
58TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
59
60ifneq ($(wildcard $(TARGET_CC)),)
61TARGET_LIBGCC := \
62	$(shell $(TARGET_CC) -m64 -print-file-name=libgcc.a)
63TARGET_LIBATOMIC := \
64	$(shell $(TARGET_CC) -m64 -print-file-name=libatomic.a)
65TARGET_LIBGCOV := \
66	$(shell $(TARGET_CC) -m64 -print-file-name=libgcov.a)
67endif
68
69TARGET_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
78TARGET_GLOBAL_CFLAGS += \
79			-O2 \
80			-Wa,--noexecstack \
81			-Werror=format-security \
82			-D_FORTIFY_SOURCE=2 \
83			-Wstrict-aliasing=2 \
84			-ffunction-sections \
85			-finline-functions \
86			-finline-limit=300 \
87			-fno-short-enums \
88			-fstrict-aliasing \
89			-funswitch-loops \
90			-funwind-tables \
91			-fstack-protector \
92			-m64 \
93			-no-canonical-prefixes \
94			-fno-canonical-system-headers
95
96# Work around gcc 4.9 devirtualization bug, https://b.corp.google.com/19872411.
97TARGET_GLOBAL_CFLAGS += \
98			-fno-devirtualize \
99
100# Help catch common 32/64-bit errors.
101TARGET_GLOBAL_CFLAGS += \
102    -Werror=pointer-to-int-cast \
103    -Werror=int-to-pointer-cast \
104    -Werror=implicit-function-declaration \
105
106android_config_h := $(call select-android-config-h,target_linux-x86)
107TARGET_ANDROID_CONFIG_CFLAGS := -include $(android_config_h) -I $(dir $(android_config_h))
108TARGET_GLOBAL_CFLAGS += $(TARGET_ANDROID_CONFIG_CFLAGS)
109
110TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
111
112ifeq ($(ARCH_X86_HAVE_SSSE3),true)   # yes, really SSSE3, not SSE3!
113    TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3
114endif
115ifeq ($(ARCH_X86_HAVE_SSE4),true)
116    TARGET_GLOBAL_CFLAGS += -msse4
117endif
118ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
119    TARGET_GLOBAL_CFLAGS += -msse4.1
120endif
121ifeq ($(ARCH_X86_HAVE_SSE4_2),true)
122    TARGET_GLOBAL_CFLAGS += -msse4.2
123endif
124ifeq ($(ARCH_X86_HAVE_POPCNT),true)
125    TARGET_GLOBAL_CFLAGS += -mpopcnt
126endif
127ifeq ($(ARCH_X86_HAVE_AVX),true)
128    TARGET_GLOBAL_CFLAGS += -mavx
129endif
130ifeq ($(ARCH_X86_HAVE_AES_NI),true)
131    TARGET_GLOBAL_CFLAGS += -maes
132endif
133
134TARGET_GLOBAL_LDFLAGS += -m64
135
136TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
137TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
138TARGET_GLOBAL_LDFLAGS += -Wl,--build-id=md5
139TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
140TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
141TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
142TARGET_GLOBAL_LDFLAGS += -Wl,--hash-style=gnu
143
144TARGET_C_INCLUDES := \
145	$(libc_root)/arch-x86_64/include \
146	$(libc_root)/include \
147	$(KERNEL_HEADERS) \
148	$(libm_root)/include \
149	$(libm_root)/include/amd64 \
150
151TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
152TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
153TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
154
155TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
156TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
157
158TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libm
159
160TARGET_LINKER := /system/bin/linker64
161
162TARGET_GLOBAL_YASM_FLAGS := -f elf64 -m amd64
163