提交 77dcef4b 编写于 作者: G Guangyao Ma

fix: clang相关编译选项隔离

liteos_a在apps/mksh和apps/toybox编译中,clang相关编译选项未进行隔离。之后支持
其他类似gcc编译时,可能存在编译问题。
其中 --target=$(LLVM_TARGET) $(LLVM_SYSROOT) 是clang编译特有的编译选项,需要被
隔离。

close #I444AV
Signed-off-by: NGuangyao Ma <guangyao.ma@outlook.com>
Change-Id: Ib11453aa0b3ee6bcdf3104d13d166c65f2202527
上级 72734a33
......@@ -39,11 +39,16 @@ BUILD_DIR := $(MKSH_DIR)/build
BUILD_LOG := $(MKSH_DIR)/build.log
TARGET_OS := OpenHarmony
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -Oz -fstack-protector-strong -D_FORTIFY_SOURCE=2
LOCAL_CFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
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 --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
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)
......@@ -64,8 +69,10 @@ endif
$(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:
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG)
.PHONY: all $(MKSH) clean
......@@ -38,6 +38,13 @@ 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)),)
$(HIDE)echo "not clean, rebuilding now";
......@@ -46,12 +53,14 @@ else
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
endif
$(HIDE)CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong --target=$(LLVM_TARGET) $(LLVM_SYSROOT)" CC="$(CC)" OUTNAME=$(OUTNAME) \
LDFLAGS="--target=$(LLVM_TARGET) $(LLVM_SYSROOT)" \
$(HIDE)CFLAGS="$(CFLAGS)" CC="$(CC)" OUTNAME="$(OUTNAME)" \
LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
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:
$(HIDE)$(RM) $(TOYBOX) $(BUILD_DIR) $(BUILD_LOG)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册