提交 682ae821 编写于 作者: C Caoruihong

chore: enable make of mksh and toybox

Signed-off-by: NCaoruihong <crh.cao@huawei.com>
Change-Id: Ie152b0ad21af5dc8e8c31c71f236500e5726e1c4
上级 45a128a4
...@@ -378,7 +378,7 @@ group("liteos_a") { ...@@ -378,7 +378,7 @@ group("liteos_a") {
build_ext_component("make") { build_ext_component("make") {
exec_path = rebase_path(".", root_build_dir) exec_path = rebase_path(".", root_build_dir)
outdir = rebase_path(get_path_info(".", "out_dir")) outdir = rebase_path("$target_out_dir/${target_name}_out")
sysroot_path = rebase_path(ohos_current_sysroot) sysroot_path = rebase_path(ohos_current_sysroot)
arch_cflags = string_join(" ", target_arch_cflags) arch_cflags = string_join(" ", target_arch_cflags)
command = "./build.sh \"$board_name\" \"$ohos_build_compiler\" \"$root_build_dir\" \"$ohos_build_type\" \"$tee_enable\"" command = "./build.sh \"$board_name\" \"$ohos_build_compiler\" \"$root_build_dir\" \"$ohos_build_type\" \"$tee_enable\""
......
...@@ -180,8 +180,8 @@ else ...@@ -180,8 +180,8 @@ else
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libgcc_s.so.1) $(OUT)/musl $(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libgcc_s.so.1) $(OUT)/musl
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl $(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl
endif endif
$(HIDE)$(STRIP) $(OUT)/musl/*
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR) $(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR)
$(HIDE)shopt -s nullglob && $(STRIP) $(ROOTFS_DIR)/bin/* $(ROOTFS_DIR)/lib/*
ifneq ($(VERSION),) ifneq ($(VERSION),)
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR) $(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)
endif endif
......
...@@ -30,16 +30,24 @@ ...@@ -30,16 +30,24 @@
include $(LITEOSTOPDIR)/config.mk include $(LITEOSTOPDIR)/config.mk
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LLVM_SYSROOT := --sysroot=$(SYSROOT_PATH) $(ARCH_CFLAGS) LLVM_SYSROOT := --sysroot=$(SYSROOT_PATH)
endif endif
# common flags config # common flags config
BASE_OPTS := -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-common -fno-strict-aliasing -D_GNU_SOURCE \ BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LLVM_EXTRA_OPTS) $(LLVM_SYSROOT) $(LITEOS_GCOV_OPTS) BASE_OPTS += -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-common -fno-strict-aliasing
BASE_OPTS += -fstack-protector-strong -Wall -Werror -flto
BASE_OPTS += $(LITEOS_CORE_COPTS) $(LLVM_EXTRA_OPTS) $(LLVM_SYSROOT) $(LITEOS_GCOV_OPTS)
CFLAGS := -std=c99 -fPIE -fno-exceptions $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE) ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
CXXFLAGS := -std=c++11 -fPIE -fexceptions -fpermissive -frtti $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE) OPTMIZE_OPTS = -Oz
LDFLAGS := -pie -s -Wl,-z,relro,-z,now $(BASE_OPTS) $(LLVM_EXTRA_LD_OPTS) else
OPTMIZE_OPTS = -O2
endif
CFLAGS := -std=c99 -fPIE -fno-exceptions $(BASE_OPTS) $(OPTMIZE_OPTS)
CXXFLAGS := -std=c++11 -fPIE -fexceptions -fpermissive -frtti $(BASE_OPTS) $(OPTMIZE_OPTS)
LDFLAGS := -pie -Wl,-z,relro,-z,now -O2 $(BASE_OPTS) $(LLVM_EXTRA_LD_OPTS)
# alias variable config # alias variable config
HIDE := @ HIDE := @
...@@ -55,8 +63,8 @@ APP_SUBDIRS := ...@@ -55,8 +63,8 @@ APP_SUBDIRS :=
ifeq ($(LOSCFG_SHELL), y) ifeq ($(LOSCFG_SHELL), y)
APP_SUBDIRS += shell APP_SUBDIRS += shell
#APP_SUBDIRS += mksh APP_SUBDIRS += mksh
#APP_SUBDIRS += toybox APP_SUBDIRS += toybox
endif endif
ifeq ($(LOSCFG_USER_INIT_DEBUG), y) ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
......
...@@ -32,22 +32,8 @@ import("//kernel/liteos_a/liteos.gni") ...@@ -32,22 +32,8 @@ import("//kernel/liteos_a/liteos.gni")
executable("init") { executable("init") {
sources = [ "src/init.c" ] sources = [ "src/init.c" ]
cflags = [ "-fPIE" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [
"-Wno-shift-op-parentheses",
"-Wno-bitwise-op-parentheses",
"-Wnonnull",
]
}
ldflags = [
"-pie",
"-s",
]
if (defined(LOSCFG_QUICK_START)) { if (defined(LOSCFG_QUICK_START)) {
ldflags += [ "--static" ] ldflags = [ "--static" ]
defines = [ "LOSCFG_QUICK_START" ]
} }
} }
...@@ -48,7 +48,6 @@ build_ext_component("build_mksh") { ...@@ -48,7 +48,6 @@ build_ext_component("build_mksh") {
"-flto", "-flto",
"-fdata-sections", "-fdata-sections",
"-ffunction-sections", "-ffunction-sections",
"-Oz",
"-fstack-protector-strong", "-fstack-protector-strong",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
"-DMKSH_DISABLE_TTY_WARNING", "-DMKSH_DISABLE_TTY_WARNING",
...@@ -62,6 +61,11 @@ build_ext_component("build_mksh") { ...@@ -62,6 +61,11 @@ build_ext_component("build_mksh") {
"-DMKSH_NO_INITCOMS", "-DMKSH_NO_INITCOMS",
"-DADAPT_FOR_LITEOS_A", "-DADAPT_FOR_LITEOS_A",
] ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-Oz" ]
} else {
cflags += [ "-O2" ]
}
cflags = string_join(" ", cflags) cflags = string_join(" ", cflags)
extra_flags = string_join(" ", target_arch_cflags) extra_flags = string_join(" ", target_arch_cflags)
......
...@@ -29,50 +29,28 @@ ...@@ -29,50 +29,28 @@
include $(APPSTOPDIR)/config.mk include $(APPSTOPDIR)/config.mk
MKSH := mksh BUILD_DIR := $(OUT)/mksh_build
BUILD_LOG := $(BUILD_DIR)/build.log
MKSH_DIR := $(shell pwd)/ CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
CFLAGS += -Wno-error
LDFLAGS += -Wl,--gc-sections
APPS_OUT := $(OUT)/bin all:
ETC_OUT := $(OUT)/etc
BUILD_DIR := $(MKSH_DIR)/build
BUILD_LOG := $(MKSH_DIR)/build.log
TARGET_OS := OpenHarmony
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -fstack-protector-strong -D_FORTIFY_SOURCE=2
LOCAL_CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
LOCAL_CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LOCAL_CFLAGS += -Oz --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
else
LOCAL_CFLAGS += -O2
endif
all:$(MKSH)
$(MKSH):
ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),) ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),)
$(HIDE)echo "not clean, rebuilding now" $(HIDE)echo "not clean, rebuilding now"
$(HIDE)chmod +x $(BUILD_DIR)/Rebuild.sh $(HIDE)cd $(BUILD_DIR) && sh ./Rebuild.sh > $(BUILD_LOG) 2>&1
$(HIDE)cd $(BUILD_DIR) && ./Rebuild.sh > $(BUILD_LOG) 2>&1
else else
$(HIDE)mkdir -p $(BUILD_DIR) $(HIDE)mkdir -p $(BUILD_DIR)
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(MKSH)/. $(BUILD_DIR) $(HIDE)$(CP) $(LITEOSTHIRDPARTY)/mksh/. $(BUILD_DIR)
$(HIDE)chmod +x $(BUILD_DIR)/Build.sh $(HIDE)cd $(BUILD_DIR) && CC="$(CC)" TARGET_OS=OpenHarmony CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" sh ./Build.sh -r > $(BUILD_LOG) 2>&1
$(HIDE)cd $(BUILD_DIR) && CC=$(CC) TARGET_OS=$(TARGET_OS) CFLAGS="$(LOCAL_CFLAGS)" LDFLAGS="$(LOCAL_LDFLAGS)" ./Build.sh -r > $(BUILD_LOG) 2>&1
endif endif
$(HIDE)$(CP) -rf $(BUILD_DIR)/$(MKSH) . $(HIDE)mkdir -p $(OUT)/bin/ $(OUT)/etc/
$(HIDE)$(STRIP) $(MKSH) $(HIDE)$(STRIP) $(BUILD_DIR)/mksh -o $(OUT)/bin/mksh
$(HIDE)mkdir -p $(APPS_OUT) $(HIDE)$(CP) $(BUILD_DIR)/.mkshrc $(OUT)/etc/
$(HIDE)$(CP) $(MKSH) $(APPS_OUT)
$(HIDE)mkdir -p $(ETC_OUT)
$(HIDE)$(CP) -rf $(BUILD_DIR)/.mkshrc $(ETC_OUT)/
$(HIDE)$(RM) $(BUILD_DIR) $(BUILD_LOG)
clean: clean:
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG) $(HIDE)$(RM) $(BUILD_DIR)
.PHONY: all $(MKSH) clean .PHONY: all clean
...@@ -41,18 +41,4 @@ executable("shell") { ...@@ -41,18 +41,4 @@ executable("shell") {
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ] deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
include_dirs = [ "include" ] include_dirs = [ "include" ]
cflags = [ "-fPIE" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [
"-Wno-shift-op-parentheses",
"-Wno-bitwise-op-parentheses",
]
}
ldflags = [
"-pie",
"-s",
]
} }
...@@ -38,18 +38,4 @@ executable("tftp") { ...@@ -38,18 +38,4 @@ executable("tftp") {
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ] deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
include_dirs = [ "include" ] include_dirs = [ "include" ]
cflags = [ "-fPIE" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [
"-Wno-shift-op-parentheses",
"-Wno-bitwise-op-parentheses",
]
}
ldflags = [
"-pie",
"-s",
]
} }
...@@ -29,40 +29,25 @@ ...@@ -29,40 +29,25 @@
include $(APPSTOPDIR)/config.mk include $(APPSTOPDIR)/config.mk
TOYBOX:= toybox BUILD_DIR := $(OUT)/toybox_build
BUILD_LOG := $(BUILD_DIR)/build.log
TOYBOX_DIR := $(shell pwd) CFLAGS += -Wno-error
APPS_OUT := $(OUT)/bin all:
BUILD_DIR := $(TOYBOX_DIR)/build
BUILD_LOG := $(TOYBOX_DIR)/build.log
OUTNAME := $(TOYBOX)
CFLAGS := -D_FORTIFY_SOURCE=2 -fstack-protector-strong
LDFLAGS :=
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
CFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
LDFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
endif
$(TOYBOX):
ifneq ($(wildcard $(BUILD_DIR)),) ifneq ($(wildcard $(BUILD_DIR)),)
$(HIDE)echo "not clean, rebuilding now"; $(HIDE)echo "not clean, rebuilding now"
else else
$(HIDE)mkdir $(BUILD_DIR) $(HIDE)mkdir -p $(BUILD_DIR)
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR) $(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/. $(BUILD_DIR)
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR) $(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/porting/liteos_a/. $(BUILD_DIR)
$(HIDE)$(CP) liteos_a_custom.config $(BUILD_DIR)/../
endif endif
$(HIDE)unset KCONFIG_CONFIG CROSS_COMPILE && \
$(HIDE)CFLAGS="$(CFLAGS)" CC="$(CC)" OUTNAME="$(OUTNAME)" \ env CC="$(CC)" OUTNAME="$(OUT)/bin/toybox" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1 make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
$(HIDE)$(CP) $(BUILD_DIR)/$(TOYBOX) .
$(HIDE)mkdir -p $(APPS_OUT)
$(HIDE)$(CP) $(TOYBOX) $(APPS_OUT)
$(HIDE)$(RM) $(BUILD_DIR) $(BUILD_LOG)
clean: clean:
$(HIDE)$(RM) $(TOYBOX) $(BUILD_DIR) $(BUILD_LOG) $(HIDE)$(RM) $(BUILD_DIR)
.PHONY: all $(TOYBOX) clean .PHONY: all clean
...@@ -595,12 +595,9 @@ LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos.ld ...@@ -595,12 +595,9 @@ LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos.ld
endif endif
##compiler## ##compiler##
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
_CC = $(CC) $(LLVM_EXTRA_OPTS) $(LLVM_EXTRA_LD_OPTS) $(LITEOS_CORE_COPTS)
LITEOS_BASELIB += $(shell $(_CC) "-print-file-name=libunwind.a") --no-dependent-libraries
else
_CC = $(CC) $(LITEOS_CORE_COPTS) _CC = $(CC) $(LITEOS_CORE_COPTS)
LITEOS_BASELIB += $(shell $(_CC) "-print-file-name=libgcc_eh.a") ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
_CC += $(LLVM_EXTRA_OPTS) $(LLVM_EXTRA_LD_OPTS)
endif endif
LITEOS_BASELIB += $(shell $(_CC) "-print-libgcc-file-name") LITEOS_BASELIB += $(shell $(_CC) "-print-libgcc-file-name")
LITEOS_LIB_INCLUDE += -isystem $(shell $(_CC) "-print-file-name=include") LITEOS_LIB_INCLUDE += -isystem $(shell $(_CC) "-print-file-name=include")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册