From 988fd85fae454a0d9fe01ef1c921b4f3667d5ac8 Mon Sep 17 00:00:00 2001 From: arvinzzz Date: Fri, 10 Sep 2021 10:51:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=E7=A1=AC=E6=B5=AE?= =?UTF-8?q?=E7=82=B9=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 通过本工程的gn编译时,需要在device目录下,单板的关于内核的config.gn中指定-mfloat-abi的等级,并在单板相关代码的编译选项中保持-mfloat-abi一致 2. 通过本工程的Makefile编译时,需要在kernel/liteos_m/targets/下添加单板相关的代码配置,在Makefile中设置-mfloat-abi即可 3. 通过IDE编译本工程时,需要在IDE的汇编文件相关编译选项中加入 -imacros $(LITEOSTOPDIR)/kernel/include/los_config.h,保证浮点等级在汇编文件中生效 close: #I48KJP Signed-off-by: arvinzzz Change-Id: Ibf9b750b922be2530de349981d55e40b5919933f --- BUILD.gn | 8 +++++ components/cppsupport/los_cppsupport.c | 5 +-- .../riscv_nuclei_demo_soc_gcc/GCC/Makefile | 2 +- .../riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk | 4 ++- .../GCC/Makefile | 2 +- .../GCC/liteos_m.mk | 4 ++- utils/los_compiler.h | 32 +++++++++---------- 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index e069f52d..aa5e3a7f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -29,9 +29,17 @@ import("config.gni") +LITEOS_LOS_CONFIG_H = rebase_path("$LITEOSTOPDIR/kernel/include/los_config.h") + config("los_config") { cflags = [ "-Werror" ] + asmflags = [ + "-DCLZ=CLZ", + "-imacros", + "$LITEOS_LOS_CONFIG_H", + ] + include_dirs = [ "//kernel/liteos_m/kernel/include", "//kernel/liteos_m/kernel/arch/include", diff --git a/components/cppsupport/los_cppsupport.c b/components/cppsupport/los_cppsupport.c index 057c3ba2..0603dfa6 100644 --- a/components/cppsupport/los_cppsupport.c +++ b/components/cppsupport/los_cppsupport.c @@ -31,7 +31,6 @@ #include "los_cppsupport.h" - typedef VOID (*InitFunc)(VOID); INT32 LOS_CppSystemInit(UINTPTR initArrayStart, UINTPTR initArrayEnd) @@ -39,12 +38,10 @@ INT32 LOS_CppSystemInit(UINTPTR initArrayStart, UINTPTR initArrayEnd) UINTPTR *start; InitFunc initFunc = NULL; - for (start = (UINTPTR *)initArrayStart; start < (UINTPTR *)initArrayEnd; start++){ + for (start = (UINTPTR *)initArrayStart; start < (UINTPTR *)initArrayEnd; start++) { initFunc = (InitFunc)(*start); initFunc(); } return 0; } - - diff --git a/targets/riscv_nuclei_demo_soc_gcc/GCC/Makefile b/targets/riscv_nuclei_demo_soc_gcc/GCC/Makefile index 94f5b63f..3c0d34c5 100644 --- a/targets/riscv_nuclei_demo_soc_gcc/GCC/Makefile +++ b/targets/riscv_nuclei_demo_soc_gcc/GCC/Makefile @@ -176,7 +176,7 @@ $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ + $(AS) -c $(CFLAGS) $(ASFLAGS) $< -o $@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile $(LDSCRIPT) $(CC) $(OBJECTS) $(LDFLAGS) -o $@ diff --git a/targets/riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk b/targets/riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk index fa673356..0ac24ece 100644 --- a/targets/riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk +++ b/targets/riscv_nuclei_demo_soc_gcc/GCC/liteos_m.mk @@ -36,9 +36,11 @@ C_INCLUDES += -I. \ -I$(LITEOSTOPDIR)/kernel/arch/include \ -I$(LITEOSTOPDIR)/kernel/arch/risc-v/nuclei/gcc +ASFLAGS += -imacros $(LITEOSTOPDIR)/kernel/include/los_config.h -DCLZ=CLZ + # list of ASM .S program objects OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASMS_SOURCES:.S=.o))) vpath %.S $(sort $(dir $(ASMS_SOURCES))) $(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) $< -o $@ + $(CC) -c $(CFLAGS) $(ASFLAGS) $< -o $@ diff --git a/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/Makefile b/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/Makefile index 2405a7a2..2d47e18b 100644 --- a/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/Makefile +++ b/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/Makefile @@ -178,7 +178,7 @@ $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ + $(AS) -c $(CFLAGS) $(ASFLAGS) $< -o $@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile $(LDSCRIPT) $(CC) $(OBJECTS) $(LDFLAGS) -o $@ diff --git a/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/liteos_m.mk b/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/liteos_m.mk index c6202e32..cd59fec8 100644 --- a/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/liteos_m.mk +++ b/targets/riscv_nuclei_gd32vf103_soc_gcc/GCC/liteos_m.mk @@ -36,9 +36,11 @@ C_INCLUDES += -I. \ -I$(LITEOSTOPDIR)/kernel/arch/include \ -I$(LITEOSTOPDIR)/kernel/arch/risc-v/nuclei/gcc +ASFLAGS += -imacros $(LITEOSTOPDIR)/kernel/include/los_config.h -DCLZ=CLZ + # list of ASM .S program objects OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASMS_SOURCES:.S=.o))) vpath %.S $(sort $(dir $(ASMS_SOURCES))) $(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) $< -o $@ + $(CC) -c $(CFLAGS) $(ASFLAGS) $< -o $@ diff --git a/utils/los_compiler.h b/utils/los_compiler.h index d5b2cdee..33add0f8 100644 --- a/utils/los_compiler.h +++ b/utils/los_compiler.h @@ -194,7 +194,7 @@ extern "C" { * Allow inline sections */ #ifndef LITE_OS_SEC_ALW_INLINE -#define LITE_OS_SEC_ALW_INLINE //__attribute__((always_inline)) +#define LITE_OS_SEC_ALW_INLINE // __attribute__((always_inline)) #endif /** @@ -210,7 +210,7 @@ extern "C" { * .Text section (Code section) */ #ifndef LITE_OS_SEC_TEXT -#define LITE_OS_SEC_TEXT //__attribute__((section(".sram.text"))) +#define LITE_OS_SEC_TEXT // __attribute__((section(".sram.text"))) #endif /** @@ -226,7 +226,7 @@ extern "C" { * .Text.init section */ #ifndef LITE_OS_SEC_TEXT_INIT -#define LITE_OS_SEC_TEXT_INIT //__attribute__((section(".dyn.text"))) +#define LITE_OS_SEC_TEXT_INIT // __attribute__((section(".dyn.text"))) #endif /** @@ -234,7 +234,7 @@ extern "C" { * .Data section */ #ifndef LITE_OS_SEC_DATA -#define LITE_OS_SEC_DATA //__attribute__((section(".dyn.data"))) +#define LITE_OS_SEC_DATA // __attribute__((section(".dyn.data"))) #endif /** @@ -242,7 +242,7 @@ extern "C" { * .Data.init section */ #ifndef LITE_OS_SEC_DATA_INIT -#define LITE_OS_SEC_DATA_INIT //__attribute__((section(".dyn.data"))) +#define LITE_OS_SEC_DATA_INIT // __attribute__((section(".dyn.data"))) #endif /** @@ -250,7 +250,7 @@ extern "C" { * Not initialized variable section */ #ifndef LITE_OS_SEC_BSS -#define LITE_OS_SEC_BSS //__attribute__((section(".sym.bss"))) +#define LITE_OS_SEC_BSS // __attribute__((section(".sym.bss"))) #endif /** @@ -270,34 +270,34 @@ extern "C" { #endif #ifndef LITE_OS_SEC_TEXT_DATA -#define LITE_OS_SEC_TEXT_DATA //__attribute__((section(".dyn.data"))) -#define LITE_OS_SEC_TEXT_BSS //__attribute__((section(".dyn.bss"))) -#define LITE_OS_SEC_TEXT_RODATA //__attribute__((section(".dyn.rodata"))) +#define LITE_OS_SEC_TEXT_DATA // __attribute__((section(".dyn.data"))) +#define LITE_OS_SEC_TEXT_BSS // __attribute__((section(".dyn.bss"))) +#define LITE_OS_SEC_TEXT_RODATA // __attribute__((section(".dyn.rodata"))) #endif #ifndef LITE_OS_SEC_SYMDATA -#define LITE_OS_SEC_SYMDATA //__attribute__((section(".sym.data"))) +#define LITE_OS_SEC_SYMDATA // __attribute__((section(".sym.data"))) #endif #ifndef LITE_OS_SEC_SYMBSS -#define LITE_OS_SEC_SYMBSS //__attribute__((section(".sym.bss"))) +#define LITE_OS_SEC_SYMBSS // __attribute__((section(".sym.bss"))) #endif #ifndef LITE_OS_SEC_KEEP_DATA_DDR -#define LITE_OS_SEC_KEEP_DATA_DDR //__attribute__((section(".keep.data.ddr"))) +#define LITE_OS_SEC_KEEP_DATA_DDR // __attribute__((section(".keep.data.ddr"))) #endif #ifndef LITE_OS_SEC_KEEP_TEXT_DDR -#define LITE_OS_SEC_KEEP_TEXT_DDR //__attribute__((section(".keep.text.ddr"))) +#define LITE_OS_SEC_KEEP_TEXT_DDR // __attribute__((section(".keep.text.ddr"))) #endif #ifndef LITE_OS_SEC_KEEP_DATA_SRAM -#define LITE_OS_SEC_KEEP_DATA_SRAM //__attribute__((section(".keep.data.sram"))) +#define LITE_OS_SEC_KEEP_DATA_SRAM // __attribute__((section(".keep.data.sram"))) #endif #ifndef LITE_OS_SEC_KEEP_TEXT_SRAM -#define LITE_OS_SEC_KEEP_TEXT_SRAM //__attribute__((section(".keep.text.sram"))) +#define LITE_OS_SEC_KEEP_TEXT_SRAM // __attribute__((section(".keep.text.sram"))) #endif #ifndef LITE_OS_SEC_BSS_MINOR @@ -378,7 +378,7 @@ typedef signed int INTPTR; * @ingroup los_base * Align the tail of the object with the base address addr, with size bytes being the smallest unit of alignment. */ -#define TRUNCATE(addr, size) ((addr) & ~((size)-1)) +#define TRUNCATE(addr, size) ((addr) & ~((size) - 1)) /**