提交 055295b6 编写于 作者: C Caoruihong

chore: optimize build scripts and add lto config entry

Signed-off-by: NCaoruihong <crh.cao@huawei.com>
Change-Id: Ibf8df58696b7f1ccb3b5b21154c3b94dda1e8ad2
上级 c26ca519
...@@ -88,6 +88,10 @@ exec_script("//build/lite/run_shell_cmd.py", ...@@ -88,6 +88,10 @@ exec_script("//build/lite/run_shell_cmd.py",
import("liteos.gni") 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") { generate_notice_file("kernel_notice_file") {
module_name = "kernel" module_name = "kernel"
module_source_dir_list = [ module_source_dir_list = [
...@@ -200,7 +204,13 @@ config("optimize_config") { ...@@ -200,7 +204,13 @@ config("optimize_config") {
} else { } else {
optimization_cflag = "-Os" 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 ] cflags += [ optimization_cflag ]
asmflags = cflags asmflags = cflags
...@@ -223,11 +233,6 @@ config("warn_config") { ...@@ -223,11 +233,6 @@ config("warn_config") {
"-Winvalid-pch", "-Winvalid-pch",
"-Wno-address-of-packed-member", "-Wno-address-of-packed-member",
] ]
if (defined(LOSCFG_QUICK_START)) {
cflags -= [ "-Werror" ]
}
asmflags = cflags asmflags = cflags
} }
...@@ -279,7 +284,7 @@ config("los_config") { ...@@ -279,7 +284,7 @@ config("los_config") {
executable("liteos") { executable("liteos") {
configs = [] # clear default configs configs = [] # clear default configs
configs += [ ":los_config" ] configs += [ ":arch_config" ]
configs += [ ":public" ] configs += [ ":public" ]
ldflags = [ ldflags = [
...@@ -304,18 +309,17 @@ executable("liteos") { ...@@ -304,18 +309,17 @@ executable("liteos") {
inputs += [ "$root_out_dir/board.ld" ] inputs += [ "$root_out_dir/board.ld" ]
output_dir = target_out_dir output_dir = target_out_dir
output_name = liteos_name
deps = [ deps = [
"platform:board.ld", "platform:copy_board.ld",
":modules", ":modules",
] ]
} }
copy("copy_liteos") { copy("copy_liteos") {
deps = [ ":liteos" ] deps = [ ":liteos" ]
sources = [ "$target_out_dir/unstripped/bin/$liteos_name" ] sources = [ "$target_out_dir/unstripped/bin/liteos" ]
outputs = [ "$root_out_dir/{{source_file_part}}" ] outputs = [ "$root_out_dir/$liteos_name" ]
} }
build_ext_component("build_kernel_image") { build_ext_component("build_kernel_image") {
......
...@@ -74,6 +74,14 @@ config COMPILE_OPTIMIZE_SIZE ...@@ -74,6 +74,14 @@ config COMPILE_OPTIMIZE_SIZE
help help
Answer Y to add optimization options for small code size. Answer Y to add optimization options for small code size.
The final binary size will be smaller. 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. But the compile time may be much longer.
endmenu endmenu
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
LITEOSTOPDIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))) LITEOSTOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
export LITEOSTOPDIR export LITEOSTOPDIR
APPS = apps APPS = apps
......
...@@ -40,5 +40,4 @@ kernel_module(module_name) { ...@@ -40,5 +40,4 @@ kernel_module(module_name) {
} }
config("public") { config("public") {
include_dirs = [ "." ]
} }
...@@ -4,10 +4,4 @@ MODULE_NAME := $(notdir $(shell pwd)) ...@@ -4,10 +4,4 @@ MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard *.c) LOCAL_SRCS := $(wildcard *.c)
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/common \
-I $(LITEOSTOPDIR)/kernel/common/patchfs \
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE) include $(MODULE)
...@@ -40,9 +40,6 @@ if (defined(LOSCFG_ARCH_ARM_AARCH32)) { ...@@ -40,9 +40,6 @@ if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
ARCH = "aarch64" ARCH = "aarch64"
} }
assert(ARCH != "", "ARCH not set!")
assert(ARCH == arch, "ARCH not match! details: $ARCH != $arch")
template("kernel_module") { template("kernel_module") {
current_dir_name = get_path_info(rebase_path("."), "file") current_dir_name = get_path_info(rebase_path("."), "file")
if (target_name != current_dir_name) { if (target_name != current_dir_name) {
......
...@@ -66,23 +66,16 @@ config("public") { ...@@ -66,23 +66,16 @@ config("public") {
include_dirs = [ "." ] include_dirs = [ "." ]
} }
source_set("board") { kernel_module("board.ld") {
sources = [ "board.ld.S" ] sources = [ "board.ld.S" ]
configs = []
configs += [
"$LITEOSTOPDIR:los_config",
"$LITEOSTOPDIR:public",
]
asmflags = [ asmflags = [
"-P", "-P",
"-E", "-E",
] ]
} }
copy("board.ld") { copy("copy_board.ld") {
deps = [ ":board" ] deps = [ ":board.ld" ]
sources = [ "$target_out_dir/board.board.ld.o" ] sources = [ "$target_out_dir/board.ld.board.ld.o" ]
outputs = [ "$root_out_dir/board.ld" ] outputs = [ "$root_out_dir/board.ld" ]
} }
...@@ -44,22 +44,6 @@ ifneq ($(LOSCFG_BASE_CORE_HILOG), y) ...@@ -44,22 +44,6 @@ ifneq ($(LOSCFG_BASE_CORE_HILOG), y)
LOCAL_SRCS := $(filter-out los_hilog.c, $(LOCAL_SRCS)) LOCAL_SRCS := $(filter-out los_hilog.c, $(LOCAL_SRCS))
endif 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) ALL_ASSRCS := $(wildcard *.S)
ASSRCS := $(filter-out board.ld.S,$(ALL_ASSRCS)) ASSRCS := $(filter-out board.ld.S,$(ALL_ASSRCS))
...@@ -68,9 +52,8 @@ LOCAL_SRCS += $(ASSRCS) ...@@ -68,9 +52,8 @@ LOCAL_SRCS += $(ASSRCS)
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS) LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
BOARD_LD = $(OUT)/lib/board.ld BOARD_LD = $(OUT)/lib/board.ld
$(BOARD_LD): board.ld.S $(LITEOS_MENUCONFIG_H) $(BOARD_LD): board.ld.S
$(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) -I. \ $(HIDE)$(CC) $(LITEOS_CFLAGS) -P -E $< -o $@
-imacros $(LITEOS_MENUCONFIG_H) -P -E $< -o $@
.PHONY: rm_board_ld .PHONY: rm_board_ld
rm_board_ld: rm_board_ld:
......
...@@ -27,31 +27,13 @@ ...@@ -27,31 +27,13 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # 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 LITEOS_BASELIB += -lbsp -lbsp_config
PLATFORM_BSP_BASE := $(LITEOSTOPDIR)/platform PLATFORM_BSP_BASE := $(LITEOSTOPDIR)/platform
PLATFORM_INCLUDE := -I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \ PLATFORM_INCLUDE := -I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \
-I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH)/include \ -I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH)/include \
-I $(PLATFORM_BSP_BASE)/../kernel/common/rootfs \ -I $(PLATFORM_BSP_BASE)
-I $(PLATFORM_BSP_BASE) \
-I $(PLATFORM_BSP_BASE)/../../../drivers/liteos/platform/pm \
-I $(PLATFORM_BSP_BASE)/hw/include \
-I $(PLATFORM_BSP_BASE)/include
LIB_SUBDIRS += $(PLATFORM_BSP_BASE) $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) LIB_SUBDIRS += $(PLATFORM_BSP_BASE) $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH)
LITEOS_PLATFORM_INCLUDE += $(PLATFORM_INCLUDE) LITEOS_PLATFORM_INCLUDE += $(PLATFORM_INCLUDE)
...@@ -30,16 +30,6 @@ ...@@ -30,16 +30,6 @@
-include $(LITEOS_CONFIG_FILE) -include $(LITEOS_CONFIG_FILE)
HIDE := @ HIDE := @
CC :=
AS :=
AR :=
LD :=
GPP :=
OBJCOPY :=
OBJDUMP :=
SIZE :=
NM :=
MKDIR = mkdir
OBJ_MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi OBJ_MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi
RM = -rm -rf RM = -rm -rf
ifeq ($(OS),) ifeq ($(OS),)
...@@ -121,12 +111,6 @@ MODULE = $(LITEOSTOPDIR)/tools/build/mk/module.mk ...@@ -121,12 +111,6 @@ MODULE = $(LITEOSTOPDIR)/tools/build/mk/module.mk
LITEOS_CMACRO += -D__LITEOS__ -DSECUREC_IN_KERNEL=0 LITEOS_CMACRO += -D__LITEOS__ -DSECUREC_IN_KERNEL=0
AS_OBJS_LIBC_FLAGS = -D__ASSEMBLY__ 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 ######################################### ####################################### CPU Option Begin #########################################
include $(LITEOSTOPDIR)/arch/cpu.mk include $(LITEOSTOPDIR)/arch/cpu.mk
####################################### CPU Option End ######################################### ####################################### CPU Option End #########################################
...@@ -137,6 +121,7 @@ include $(LITEOSTOPDIR)/platform/bsp.mk ...@@ -137,6 +121,7 @@ include $(LITEOSTOPDIR)/platform/bsp.mk
ifeq ($(LOSCFG_PLATFORM_ROOTFS), y) ifeq ($(LOSCFG_PLATFORM_ROOTFS), y)
LITEOS_BASELIB += -lrootfs LITEOS_BASELIB += -lrootfs
LIB_SUBDIRS += $(LITEOSTOPDIR)/kernel/common/rootfs LIB_SUBDIRS += $(LITEOSTOPDIR)/kernel/common/rootfs
LITEOS_PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/kernel/common/rootfs
endif endif
ifeq ($(LOSCFG_PLATFORM_PATCHFS), y) ifeq ($(LOSCFG_PLATFORM_PATCHFS), y)
...@@ -440,9 +425,16 @@ ifeq ($(LOSCFG_COMPILE_OPTIMIZE), y) ...@@ -440,9 +425,16 @@ ifeq ($(LOSCFG_COMPILE_OPTIMIZE), y)
endif endif
ifeq ($(LOSCFG_COMPILE_OPTIMIZE_SIZE), y) ifeq ($(LOSCFG_COMPILE_OPTIMIZE_SIZE), y)
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LITEOS_COPTS_OPTIMIZE = -Oz -flto LITEOS_COPTS_OPTIMIZE = -Oz
else
LITEOS_COPTS_OPTIMIZE = -Os
endif
endif
ifeq ($(LOSCFG_COMPILE_LTO), y)
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LITEOS_COPTS_OPTIMIZE += -flto=thin
else else
LITEOS_COPTS_OPTIMIZE = -Os -flto LITEOS_COPTS_OPTIMIZE += -flto
endif endif
endif endif
LITEOS_COPTS_DEBUG += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE) LITEOS_COPTS_DEBUG += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE)
...@@ -556,7 +548,7 @@ LITEOS_SECURITY_INCLUDE := $(LITEOS_SECURITY_CAP_INC) $(LITEOS_SECURITY_VID_I ...@@ -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) \ LOSCFG_TOOLS_DEBUG_INCLUDE := $(LITEOS_SHELL_INCLUDE) $(LITEOS_UART_INCLUDE) \
$(LITEOS_TELNET_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 LITEOS_CXXOPTS_BASE += $(LITEOS_COMMON_OPTS) -std=c++11 -nostdinc++ -fexceptions -fpermissive -fno-use-cxa-atexit -frtti
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册