1# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. 2# 3# Redistribution and use in source and binary forms, with or without modification, 4# are permitted provided that the following conditions are met: 5# 6# 1. Redistributions of source code must retain the above copyright notice, this list of 7# conditions and the following disclaimer. 8# 9# 2. Redistributions in binary form must reproduce the above copyright notice, this list 10# of conditions and the following disclaimer in the documentation and/or other materials 11# provided with the distribution. 12# 13# 3. Neither the name of the copyright holder nor the names of its contributors may be used 14# to endorse or promote products derived from this software without specific prior written 15# permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 21# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29import("//build/lite/config/component/lite_component.gni") 30import("liteos.gni") 31 32LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h") 33 34liteos_name = "OHOS_Image" 35liteos_kernel_only = false 36 37# 38# arch_config 39# 40liteos_arch_config_cflags = [] 41if (defined(LOSCFG_ARCH_ARM)) { 42 mcpu = LOSCFG_ARCH_CPU 43 if (defined(LOSCFG_ARCH_ARM_AARCH64) && defined(LOSCFG_ARCH_FPU_DISABLE)) { 44 mcpu += "+nofp" 45 } 46 liteos_arch_config_cflags += [ "-mcpu=$mcpu" ] 47 if (defined(LOSCFG_ARCH_ARM_AARCH32) && defined(LOSCFG_ARCH_FPU)) { 48 liteos_arch_config_cflags += [ "-mfpu=$LOSCFG_ARCH_FPU" ] 49 } 50} 51 52arch_config_cflags = liteos_arch_config_cflags 53arch_config_asmflags = [] 54arch_config_ldflags = liteos_arch_config_cflags 55 56if (defined(LOSCFG_ARCH_ARM_AARCH32) && !defined(LOSCFG_COMPILER_CLANG_LLVM)) { 57 arch_config_cflags += [ "-mthumb-interwork" ] 58} 59if (defined(LOSCFG_THUMB)) { 60 arch_config_cflags += [ "-mthumb" ] 61 if (defined(LOSCFG_COMPILER_CLANG_LLVM)) { 62 arch_config_cflags += [ "-mimplicit-it=thumb" ] 63 } else { 64 arch_config_cflags += [ "-Wa,-mimplicit-it=thumb" ] 65 } 66} 67arch_config_asmflags += arch_config_cflags 68 69# 70# stdinc_config 71# 72stdinc_config_cflags = [] 73stdinc_config_asmflags = [] 74 75if (defined(LOSCFG_LIBC_MUSL)) { 76 stdinc_config_cflags += [ "-nostdinc" ] 77} 78stdinc_config_asmflags += stdinc_config_cflags 79 80# 81# ssp_config 82# 83ssp_config_cflags = [] 84ssp_config_asmflags = [] 85 86if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) { 87 ssp_config_cflags += [ "-fstack-protector-all" ] 88} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) { 89 ssp_config_cflags += [ "-fstack-protector-strong" ] 90} else if (defined(LOSCFG_CC_STACKPROTECTOR)) { 91 ssp_config_cflags += [ 92 "-fstack-protector", 93 "--param", 94 "ssp-buffer-size=4", 95 ] 96} else { 97 ssp_config_cflags += [ "-fno-stack-protector" ] 98} 99ssp_config_asmflags += ssp_config_cflags 100 101# 102# optimize_config 103# 104optimize_config_cflags = [] 105optimize_config_asmflags = [] 106 107if (defined(LOSCFG_COMPILE_LTO)) { 108 if (defined(LOSCFG_COMPILER_CLANG_LLVM)) { 109 optimize_config_cflags += [ "-flto=thin" ] 110 } else { 111 #optimize_config_cflags += [ "-flto" ] 112 } 113} 114if (defined(LOSCFG_COMPILE_DEBUG)) { 115 optimize_config_cflags += [ 116 "-g", 117 "-gdwarf-2", 118 ] 119 optimize_config_cflags += [ "-O0" ] 120} 121if (defined(LOSCFG_COMPILE_OPTIMIZE)) { 122 optimize_config_cflags += [ "-O2" ] 123} 124if (defined(LOSCFG_COMPILE_OPTIMIZE_SIZE)) { 125 if (defined(LOSCFG_COMPILER_CLANG_LLVM)) { 126 optimize_config_cflags += [ "-Oz" ] 127 } else { 128 optimize_config_cflags += [ "-Os" ] 129 } 130} 131optimize_config_asmflags += optimize_config_cflags 132 133# 134# kconfig_config 135# 136kconfig_config_cflags = [] 137kconfig_config_asmflags = [] 138 139kconfig_config_cflags += [ 140 "-imacros", 141 "$LITEOS_MENUCONFIG_H", 142] 143kconfig_config_asmflags += kconfig_config_cflags 144 145# 146# warn_config 147# 148warn_config_cflags = [] 149warn_config_asmflags = [] 150 151warn_config_cflags += [ 152 "-Wall", 153 "-Werror", 154 "-Wpointer-arith", 155 "-Wstrict-prototypes", 156 "-Winvalid-pch", 157 "-Wno-address-of-packed-member", 158] 159warn_config_asmflags += warn_config_cflags 160 161# 162# dialect_config 163# 164dialect_config_cflags = [] 165dialect_config_ccflags = [] 166dialect_config_asmflags = [] 167 168dialect_config_cflags += [ "-std=c99" ] 169dialect_config_ccflags += [ "-std=c++11" ] 170 171# 172# misc_config 173# 174misc_config_cflags = [] 175misc_config_asmflags = [] 176 177misc_config_cflags += [ 178 "-fno-pic", 179 "-fno-builtin", 180 "-fms-extensions", 181 "-fno-strict-aliasing", 182 "-fno-common", 183 "-fsigned-char", 184 "-ffunction-sections", 185 "-fdata-sections", 186 "-fno-exceptions", 187 "-fno-omit-frame-pointer", 188] 189if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) { 190 misc_config_cflags += [ "-fno-aggressive-loop-optimizations" ] 191} 192misc_config_asmflags += misc_config_cflags 193misc_config_asmflags += [ "-DCLZ=CLZ" ] 194 195# ldflags for generating executable bin files 196executable_config_ldflags = [ 197 "-static", 198 "-Wl,--gc-sections", 199 "-Wl,-Map=$liteos_name.map", 200] 201 202# Commands to generate kernel_image 203toochain_config_objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix" 204toochain_config_objdump = "${compile_prefix}objdump$toolchain_cmd_suffix" 205 206toochain_config_command = 207 "$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin" 208toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'" 209toochain_config_command += 210 " && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'" 211