Home | History | Annotate | Download | only in combo
      1 #
      2 # Copyright (C) 2010 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 MIPS.
     18 # Included by combo/select.mk
     19 
     20 # You can set TARGET_ARCH_VARIANT to use an arch version other
     21 # than mips32r2-fp. Each value should correspond to a file named
     22 # $(BUILD_COMBOS)/arch/<name>.mk which must contain
     23 # makefile variable definitions similar to the preprocessor
     24 # defines in build/core/combo/include/arch/<combo>/AndroidConfig.h. Their
     25 # purpose is to allow module Android.mk files to selectively compile
     26 # different versions of code based upon the funtionality and
     27 # instructions available in a given architecture version.
     28 #
     29 # The blocks also define specific arch_variant_cflags, which
     30 # include defines, and compiler settings for the given architecture
     31 # version.
     32 #
     33 ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
     34 TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := mips32r2-fp
     35 endif
     36 
     37 # Decouple NDK library selection with platform compiler version
     38 $(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.8
     39 
     40 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
     41 $(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9
     42 else
     43 $(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
     44 endif
     45 
     46 TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT).mk
     47 ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
     48 $(error Unknown MIPS architecture variant: $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
     49 endif
     50 
     51 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
     52 include $(BUILD_SYSTEM)/combo/fdo.mk
     53 
     54 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
     55 ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),)
     56 $(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mips64el-linux-android-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
     57 $(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/mips64el-linux-android-
     58 endif
     59 
     60 $(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
     61 $(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
     62 $(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
     63 $(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
     64 $(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
     65 $(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
     66 $(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
     67 
     68 $(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
     69 
     70 TARGET_mips_CFLAGS :=	-O2 \
     71 			-fomit-frame-pointer \
     72 			-fno-strict-aliasing    \
     73 			-funswitch-loops
     74 
     75 # Set FORCE_MIPS_DEBUGGING to "true" in your buildspec.mk
     76 # or in your environment to gdb debugging easier.
     77 # Don't forget to do a clean build.
     78 ifeq ($(FORCE_MIPS_DEBUGGING),true)
     79   TARGET_mips_CFLAGS += -fno-omit-frame-pointer
     80 endif
     81 
     82 android_config_h := $(call select-android-config-h,linux-mips)
     83 
     84 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
     85 			$(TARGET_mips_CFLAGS) \
     86 			-U__unix -U__unix__ -Umips \
     87 			-ffunction-sections \
     88 			-fdata-sections \
     89 			-funwind-tables \
     90 			-Wa,--noexecstack \
     91 			-Werror=format-security \
     92 			-D_FORTIFY_SOURCE=2 \
     93 			-no-canonical-prefixes \
     94 			-fno-canonical-system-headers \
     95 			$(arch_variant_cflags) \
     96 			-include $(android_config_h) \
     97 			-I $(dir $(android_config_h))
     98 
     99 ifneq ($(ARCH_MIPS_PAGE_SHIFT),)
    100 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -DPAGE_SHIFT=$(ARCH_MIPS_PAGE_SHIFT)
    101 endif
    102 
    103 $(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \
    104 			-Wl,-z,noexecstack \
    105 			-Wl,-z,relro \
    106 			-Wl,-z,now \
    107 			-Wl,--warn-shared-textrel \
    108 			-Wl,--fatal-warnings \
    109 			$(arch_variant_ldflags)
    110 
    111 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
    112 
    113 # More flags/options can be added here
    114 $(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
    115 			-DNDEBUG \
    116 			-g \
    117 			-Wstrict-aliasing=2 \
    118 			-fgcse-after-reload \
    119 			-frerun-cse-after-loop \
    120 			-frename-registers
    121 
    122 libc_root := bionic/libc
    123 libm_root := bionic/libm
    124 libstdc++_root := bionic/libstdc++
    125 
    126 
    127 ## on some hosts, the target cross-compiler is not available so do not run this command
    128 ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
    129 # We compile with the global cflags to ensure that
    130 # any flags which affect libgcc are correctly taken
    131 # into account.
    132 $(combo_2nd_arch_prefix)TARGET_LIBGCC := \
    133   $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc.a)
    134 $(combo_2nd_arch_prefix)TARGET_LIBATOMIC := \
    135   $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
    136 LIBGCC_EH := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc_eh.a)
    137 ifneq ($(LIBGCC_EH),libgcc_eh.a)
    138   $(combo_2nd_arch_prefix)TARGET_LIBGCC += $(LIBGCC_EH)
    139 endif
    140 endif
    141 
    142 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
    143 KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-mips # mips covers both mips and mips64.
    144 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
    145 
    146 $(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
    147 	$(libc_root)/arch-mips/include \
    148 	$(libc_root)/include \
    149 	$(libstdc++_root)/include \
    150 	$(KERNEL_HEADERS) \
    151 	$(libm_root)/include \
    152 	$(libm_root)/include/mips \
    153 
    154 $(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
    155 $(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
    156 $(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
    157 
    158 $(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
    159 $(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
    160 
    161 $(combo_2nd_arch_prefix)TARGET_STRIP_MODULE:=true
    162 
    163 $(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
    164 
    165 $(combo_2nd_arch_prefix)TARGET_CUSTOM_LD_COMMAND := true
    166 
    167 define $(combo_2nd_arch_prefix)transform-o-to-shared-lib-inner
    168 $(hide) $(PRIVATE_CXX) \
    169 	-nostdlib -Wl,-soname,$(notdir $@) \
    170 	-Wl,--gc-sections \
    171 	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl,-shared) \
    172 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
    173 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
    174 	$(PRIVATE_ALL_OBJECTS) \
    175 	-Wl,--whole-archive \
    176 	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
    177 	-Wl,--no-whole-archive \
    178 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
    179 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
    180 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
    181 	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
    182 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
    183 	-o $@ \
    184 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
    185 	$(PRIVATE_LDFLAGS) \
    186 	$(PRIVATE_TARGET_LIBATOMIC) \
    187 	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
    188 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \
    189 	$(PRIVATE_LDLIBS)
    190 endef
    191 
    192 define $(combo_2nd_arch_prefix)transform-o-to-executable-inner
    193 $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \
    194 	-Wl,-dynamic-linker,/system/bin/linker \
    195 	-Wl,--gc-sections \
    196 	-Wl,-z,nocopyreloc \
    197 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
    198 	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
    199 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
    200 	$(PRIVATE_ALL_OBJECTS) \
    201 	-Wl,--whole-archive \
    202 	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
    203 	-Wl,--no-whole-archive \
    204 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
    205 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
    206 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
    207 	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
    208 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
    209 	-o $@ \
    210 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
    211 	$(PRIVATE_LDFLAGS) \
    212 	$(PRIVATE_TARGET_LIBATOMIC) \
    213 	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
    214 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
    215 	$(PRIVATE_LDLIBS)
    216 endef
    217 
    218 define $(combo_2nd_arch_prefix)transform-o-to-static-executable-inner
    219 $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \
    220 	-Wl,--gc-sections \
    221 	-o $@ \
    222 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
    223 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_STATIC_O)) \
    224 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
    225 	$(PRIVATE_LDFLAGS) \
    226 	$(PRIVATE_ALL_OBJECTS) \
    227 	-Wl,--whole-archive \
    228 	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
    229 	-Wl,--no-whole-archive \
    230 	$(call normalize-target-libraries,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)))) \
    231 	-Wl,--start-group \
    232 	$(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
    233 	$(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
    234 	$(PRIVATE_TARGET_LIBATOMIC) \
    235 	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
    236 	-Wl,--end-group \
    237 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))
    238 endef
    239