Home | History | Annotate | Download | only in combo
      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.
     21 ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
     22 TARGET_ARCH_VARIANT := x86_64
     23 endif
     24 
     25 # Decouple NDK library selection with platform compiler version
     26 TARGET_NDK_GCC_VERSION := 4.9
     27 
     28 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
     29 TARGET_GCC_VERSION := 4.9
     30 else
     31 TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
     32 endif
     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 #
     38 TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
     39 ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
     40 $(error Unknown $(TARGET_ARCH) architecture version: $(TARGET_ARCH_VARIANT))
     41 endif
     42 
     43 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
     44 include $(BUILD_SYSTEM)/combo/fdo.mk
     45 
     46 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
     47 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
     48 TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-$(TARGET_GCC_VERSION)
     49 TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/x86_64-linux-android-
     50 endif
     51 
     52 TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc
     53 TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++
     54 TARGET_AR := $(TARGET_TOOLS_PREFIX)ar
     55 TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy
     56 TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
     57 TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
     58 TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
     59 TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
     60 
     61 define $(combo_var_prefix)transform-shared-lib-to-toc
     62 $(call _gen_toc_command_for_elf,$(1),$(2))
     63 endef
     64 
     65 ifneq ($(wildcard $(TARGET_CC)),)
     66 TARGET_LIBGCC := \
     67 	$(shell $(TARGET_CC) -m64 -print-file-name=libgcc.a)
     68 TARGET_LIBATOMIC := \
     69 	$(shell $(TARGET_CC) -m64 -print-file-name=libatomic.a)
     70 TARGET_LIBGCOV := \
     71 	$(shell $(TARGET_CC) -m64 -print-file-name=libgcov.a)
     72 endif
     73 
     74 TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
     75 
     76 libc_root := bionic/libc
     77 libm_root := bionic/libm
     78 
     79 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
     80 KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
     81 KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
     82 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
     83 
     84 TARGET_GLOBAL_CFLAGS += \
     85 			-O2 \
     86 			-Wa,--noexecstack \
     87 			-Werror=format-security \
     88 			-D_FORTIFY_SOURCE=2 \
     89 			-Wstrict-aliasing=2 \
     90 			-ffunction-sections \
     91 			-finline-functions \
     92 			-finline-limit=300 \
     93 			-fno-short-enums \
     94 			-fstrict-aliasing \
     95 			-funswitch-loops \
     96 			-funwind-tables \
     97 			-fstack-protector-strong \
     98 			-m64 \
     99 			-no-canonical-prefixes \
    100 			-fno-canonical-system-headers
    101 
    102 # Help catch common 32/64-bit errors.
    103 TARGET_GLOBAL_CFLAGS += \
    104     -Werror=pointer-to-int-cast \
    105     -Werror=int-to-pointer-cast \
    106     -Werror=implicit-function-declaration \
    107 
    108 TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
    109 
    110 ifeq ($(ARCH_X86_HAVE_SSSE3),true)   # yes, really SSSE3, not SSE3!
    111     TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3
    112 endif
    113 ifeq ($(ARCH_X86_HAVE_SSE4),true)
    114     TARGET_GLOBAL_CFLAGS += -msse4
    115 endif
    116 ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
    117     TARGET_GLOBAL_CFLAGS += -msse4.1
    118 endif
    119 ifeq ($(ARCH_X86_HAVE_SSE4_2),true)
    120     TARGET_GLOBAL_CFLAGS += -msse4.2
    121 endif
    122 ifeq ($(ARCH_X86_HAVE_POPCNT),true)
    123     TARGET_GLOBAL_CFLAGS += -mpopcnt
    124 endif
    125 ifeq ($(ARCH_X86_HAVE_AVX),true)
    126     TARGET_GLOBAL_CFLAGS += -mavx
    127 endif
    128 ifeq ($(ARCH_X86_HAVE_AES_NI),true)
    129     TARGET_GLOBAL_CFLAGS += -maes
    130 endif
    131 
    132 TARGET_GLOBAL_LDFLAGS += -m64
    133 
    134 TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
    135 TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
    136 TARGET_GLOBAL_LDFLAGS += -Wl,--build-id=md5
    137 TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
    138 TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
    139 TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
    140 TARGET_GLOBAL_LDFLAGS += -Wl,--hash-style=gnu
    141 TARGET_GLOBAL_LDFLAGS += -Wl,--no-undefined-version
    142 
    143 TARGET_C_INCLUDES := \
    144 	$(libc_root)/arch-x86_64/include \
    145 	$(libc_root)/include \
    146 	$(KERNEL_HEADERS) \
    147 	$(libm_root)/include \
    148 	$(libm_root)/include/amd64 \
    149 
    150 TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
    151 TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
    152 TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
    153 
    154 TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
    155 TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
    156 
    157 TARGET_LINKER := /system/bin/linker64
    158 
    159 TARGET_GLOBAL_YASM_FLAGS := -f elf64 -m amd64
    160