chore: optimize build scripts and add lto config entry
Signed-off-by: Caoruihong <crh.cao@huawei.com> Change-Id: Ibf8df58696b7f1ccb3b5b21154c3b94dda1e8ad2
This commit is contained in:
parent
c26ca519f7
commit
055295b6d1
26
BUILD.gn
26
BUILD.gn
|
@ -88,6 +88,10 @@ exec_script("//build/lite/run_shell_cmd.py",
|
|||
|
||||
import("liteos.gni")
|
||||
|
||||
assert(ARCH != "", "ARCH not set!")
|
||||
assert(ARCH == arch, "ARCH not match! details: $ARCH != $arch")
|
||||
assert(tee_enable == defined(LOSCFG_TEE_ENABLE), "TEE switch not match!")
|
||||
|
||||
generate_notice_file("kernel_notice_file") {
|
||||
module_name = "kernel"
|
||||
module_source_dir_list = [
|
||||
|
@ -200,7 +204,13 @@ config("optimize_config") {
|
|||
} else {
|
||||
optimization_cflag = "-Os"
|
||||
}
|
||||
cflags += [ "-flto" ]
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_LTO)) {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-flto=thin" ]
|
||||
} else {
|
||||
cflags += [ "-flto" ]
|
||||
}
|
||||
}
|
||||
cflags += [ optimization_cflag ]
|
||||
asmflags = cflags
|
||||
|
@ -223,11 +233,6 @@ config("warn_config") {
|
|||
"-Winvalid-pch",
|
||||
"-Wno-address-of-packed-member",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_QUICK_START)) {
|
||||
cflags -= [ "-Werror" ]
|
||||
}
|
||||
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
|
@ -279,7 +284,7 @@ config("los_config") {
|
|||
|
||||
executable("liteos") {
|
||||
configs = [] # clear default configs
|
||||
configs += [ ":los_config" ]
|
||||
configs += [ ":arch_config" ]
|
||||
configs += [ ":public" ]
|
||||
|
||||
ldflags = [
|
||||
|
@ -304,18 +309,17 @@ executable("liteos") {
|
|||
inputs += [ "$root_out_dir/board.ld" ]
|
||||
|
||||
output_dir = target_out_dir
|
||||
output_name = liteos_name
|
||||
|
||||
deps = [
|
||||
"platform:board.ld",
|
||||
"platform:copy_board.ld",
|
||||
":modules",
|
||||
]
|
||||
}
|
||||
|
||||
copy("copy_liteos") {
|
||||
deps = [ ":liteos" ]
|
||||
sources = [ "$target_out_dir/unstripped/bin/$liteos_name" ]
|
||||
outputs = [ "$root_out_dir/{{source_file_part}}" ]
|
||||
sources = [ "$target_out_dir/unstripped/bin/liteos" ]
|
||||
outputs = [ "$root_out_dir/$liteos_name" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_kernel_image") {
|
||||
|
|
8
Kconfig
8
Kconfig
|
@ -74,6 +74,14 @@ config COMPILE_OPTIMIZE_SIZE
|
|||
help
|
||||
Answer Y to add optimization options for small code size.
|
||||
The final binary size will be smaller.
|
||||
But the compile time may be a bit longer.
|
||||
|
||||
config COMPILE_LTO
|
||||
bool "Enable link time optimization (LTO)" if COMPILE_OPTIMIZE_SIZE
|
||||
default y
|
||||
help
|
||||
Answer Y to add lto options for more smaller code size.
|
||||
The final binary size will be smaller.
|
||||
But the compile time may be much longer.
|
||||
|
||||
endmenu
|
||||
|
|
2
Makefile
2
Makefile
|
@ -27,7 +27,7 @@
|
|||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
LITEOSTOPDIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
|
||||
LITEOSTOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
export LITEOSTOPDIR
|
||||
|
||||
APPS = apps
|
||||
|
|
|
@ -40,5 +40,4 @@ kernel_module(module_name) {
|
|||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
|
|
|
@ -4,10 +4,4 @@ MODULE_NAME := $(notdir $(shell pwd))
|
|||
|
||||
LOCAL_SRCS := $(wildcard *.c)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/common \
|
||||
-I $(LITEOSTOPDIR)/kernel/common/patchfs \
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
include $(MODULE)
|
||||
|
|
|
@ -40,9 +40,6 @@ if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
|||
ARCH = "aarch64"
|
||||
}
|
||||
|
||||
assert(ARCH != "", "ARCH not set!")
|
||||
assert(ARCH == arch, "ARCH not match! details: $ARCH != $arch")
|
||||
|
||||
template("kernel_module") {
|
||||
current_dir_name = get_path_info(rebase_path("."), "file")
|
||||
if (target_name != current_dir_name) {
|
||||
|
|
|
@ -66,23 +66,16 @@ config("public") {
|
|||
include_dirs = [ "." ]
|
||||
}
|
||||
|
||||
source_set("board") {
|
||||
kernel_module("board.ld") {
|
||||
sources = [ "board.ld.S" ]
|
||||
|
||||
configs = []
|
||||
configs += [
|
||||
"$LITEOSTOPDIR:los_config",
|
||||
"$LITEOSTOPDIR:public",
|
||||
]
|
||||
|
||||
asmflags = [
|
||||
"-P",
|
||||
"-E",
|
||||
]
|
||||
}
|
||||
|
||||
copy("board.ld") {
|
||||
deps = [ ":board" ]
|
||||
sources = [ "$target_out_dir/board.board.ld.o" ]
|
||||
copy("copy_board.ld") {
|
||||
deps = [ ":board.ld" ]
|
||||
sources = [ "$target_out_dir/board.ld.board.ld.o" ]
|
||||
outputs = [ "$root_out_dir/board.ld" ]
|
||||
}
|
||||
|
|
|
@ -44,22 +44,6 @@ ifneq ($(LOSCFG_BASE_CORE_HILOG), y)
|
|||
LOCAL_SRCS := $(filter-out los_hilog.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_KERNEL_TICKLESS), y)
|
||||
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/kernel/extended/include
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_KERNEL_TRACE), y)
|
||||
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/kernel/extended/include
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_KERNEL_CPUP), y)
|
||||
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/kernel/extended/include
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_KERNEL_VDSO), y)
|
||||
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/kernel/extended/vdso/include
|
||||
endif
|
||||
|
||||
ALL_ASSRCS := $(wildcard *.S)
|
||||
ASSRCS := $(filter-out board.ld.S,$(ALL_ASSRCS))
|
||||
|
||||
|
@ -68,9 +52,8 @@ LOCAL_SRCS += $(ASSRCS)
|
|||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
BOARD_LD = $(OUT)/lib/board.ld
|
||||
$(BOARD_LD): board.ld.S $(LITEOS_MENUCONFIG_H)
|
||||
$(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) -I. \
|
||||
-imacros $(LITEOS_MENUCONFIG_H) -P -E $< -o $@
|
||||
$(BOARD_LD): board.ld.S
|
||||
$(HIDE)$(CC) $(LITEOS_CFLAGS) -P -E $< -o $@
|
||||
|
||||
.PHONY: rm_board_ld
|
||||
rm_board_ld:
|
||||
|
|
|
@ -27,31 +27,13 @@
|
|||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
############################# SRCs #################################
|
||||
HWI_SRC :=
|
||||
MMU_SRC :=
|
||||
NET_SRC :=
|
||||
TIMER_SRC :=
|
||||
HRTIMER_SRC :=
|
||||
USB_SRC :=
|
||||
|
||||
############################# HI3516DV300 Options#################################
|
||||
|
||||
########################## HI3518EV300 Options##############################
|
||||
|
||||
########################## Qemu ARM Virt Options##############################
|
||||
|
||||
LITEOS_BASELIB += -lbsp -lbsp_config
|
||||
|
||||
PLATFORM_BSP_BASE := $(LITEOSTOPDIR)/platform
|
||||
|
||||
PLATFORM_INCLUDE := -I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \
|
||||
-I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH)/include \
|
||||
-I $(PLATFORM_BSP_BASE)/../kernel/common/rootfs \
|
||||
-I $(PLATFORM_BSP_BASE) \
|
||||
-I $(PLATFORM_BSP_BASE)/../../../drivers/liteos/platform/pm \
|
||||
-I $(PLATFORM_BSP_BASE)/hw/include \
|
||||
-I $(PLATFORM_BSP_BASE)/include
|
||||
-I $(PLATFORM_BSP_BASE)
|
||||
|
||||
LIB_SUBDIRS += $(PLATFORM_BSP_BASE) $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH)
|
||||
LITEOS_PLATFORM_INCLUDE += $(PLATFORM_INCLUDE)
|
||||
|
|
|
@ -30,16 +30,6 @@
|
|||
-include $(LITEOS_CONFIG_FILE)
|
||||
|
||||
HIDE := @
|
||||
CC :=
|
||||
AS :=
|
||||
AR :=
|
||||
LD :=
|
||||
GPP :=
|
||||
OBJCOPY :=
|
||||
OBJDUMP :=
|
||||
SIZE :=
|
||||
NM :=
|
||||
MKDIR = mkdir
|
||||
OBJ_MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi
|
||||
RM = -rm -rf
|
||||
ifeq ($(OS),)
|
||||
|
@ -121,12 +111,6 @@ MODULE = $(LITEOSTOPDIR)/tools/build/mk/module.mk
|
|||
LITEOS_CMACRO += -D__LITEOS__ -DSECUREC_IN_KERNEL=0
|
||||
AS_OBJS_LIBC_FLAGS = -D__ASSEMBLY__
|
||||
|
||||
ifeq ($(LOSCFG_QUICK_START), y)
|
||||
WARNING_AS_ERROR := -Wall
|
||||
else
|
||||
WARNING_AS_ERROR := -Wall -Werror
|
||||
endif
|
||||
|
||||
####################################### CPU Option Begin #########################################
|
||||
include $(LITEOSTOPDIR)/arch/cpu.mk
|
||||
####################################### CPU Option End #########################################
|
||||
|
@ -137,6 +121,7 @@ include $(LITEOSTOPDIR)/platform/bsp.mk
|
|||
ifeq ($(LOSCFG_PLATFORM_ROOTFS), y)
|
||||
LITEOS_BASELIB += -lrootfs
|
||||
LIB_SUBDIRS += $(LITEOSTOPDIR)/kernel/common/rootfs
|
||||
LITEOS_PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/kernel/common/rootfs
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_PLATFORM_PATCHFS), y)
|
||||
|
@ -440,9 +425,16 @@ ifeq ($(LOSCFG_COMPILE_OPTIMIZE), y)
|
|||
endif
|
||||
ifeq ($(LOSCFG_COMPILE_OPTIMIZE_SIZE), y)
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LITEOS_COPTS_OPTIMIZE = -Oz -flto
|
||||
LITEOS_COPTS_OPTIMIZE = -Oz
|
||||
else
|
||||
LITEOS_COPTS_OPTIMIZE = -Os -flto
|
||||
LITEOS_COPTS_OPTIMIZE = -Os
|
||||
endif
|
||||
endif
|
||||
ifeq ($(LOSCFG_COMPILE_LTO), y)
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LITEOS_COPTS_OPTIMIZE += -flto=thin
|
||||
else
|
||||
LITEOS_COPTS_OPTIMIZE += -flto
|
||||
endif
|
||||
endif
|
||||
LITEOS_COPTS_DEBUG += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE)
|
||||
|
@ -556,7 +548,7 @@ LITEOS_SECURITY_INCLUDE := $(LITEOS_SECURITY_CAP_INC) $(LITEOS_SECURITY_VID_I
|
|||
LOSCFG_TOOLS_DEBUG_INCLUDE := $(LITEOS_SHELL_INCLUDE) $(LITEOS_UART_INCLUDE) \
|
||||
$(LITEOS_TELNET_INCLUDE)
|
||||
|
||||
LITEOS_COMMON_OPTS := -fno-pic -fno-builtin -nostdinc -nostdlib $(WARNING_AS_ERROR) -fms-extensions -fno-omit-frame-pointer -Wno-address-of-packed-member -Winvalid-pch
|
||||
LITEOS_COMMON_OPTS := -fno-pic -fno-builtin -nostdinc -nostdlib -Wall -Werror -fms-extensions -fno-omit-frame-pointer -Wno-address-of-packed-member -Winvalid-pch
|
||||
|
||||
LITEOS_CXXOPTS_BASE += $(LITEOS_COMMON_OPTS) -std=c++11 -nostdinc++ -fexceptions -fpermissive -fno-use-cxa-atexit -frtti
|
||||
|
||||
|
|
Loading…
Reference in New Issue