diff --git a/Makefile b/Makefile index e0949c7018ae17ba877ab21bc90e0b3764f6539c..5f95f673734126e1954bb6ce8fbae1ab0c271883 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,11 @@ $(LITEOS_TARGET): ifeq ($(OS), Linux) $(call update_from_baselib_file) endif +ifeq ($(LD), $(CC)) + $(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Wl,-Map=$(OUT)/$@.map -o $(OUT)/$@.elf -Wl,--start-group $(LITEOS_BASELIB) -Wl,--end-group +else $(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@.elf --start-group $(LITEOS_BASELIB) --end-group +endif ifeq ($(LOSCFG_FAMILY_RASPBERRY), y) ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y) $(OBJCOPY) -O binary $(OUT)/$@.elf $(OUT)/kernel8.img diff --git a/build/mk/compiler_gcc.mk b/build/mk/compiler_gcc.mk index bd2f1ee7fd3b15a22031f0ae19f54f1587a0c5de..f3fbd24110dd29dfa49a6202e1dbebb6b2684e61 100644 --- a/build/mk/compiler_gcc.mk +++ b/build/mk/compiler_gcc.mk @@ -72,6 +72,9 @@ ifeq ($(LOSCFG_COMPILER_ARM_NONE_EABI), y) ifeq ($(shell if [ $(shell echo $(VERSION_NUM) | tr -d ".") -lt 921 ]; then echo y; fi), y) $(error The compiler version is too early. You are advised to use a version later than gcc-arm-none-eabi-9-2019-q4-major) endif + ifeq ($(shell if [ $(shell echo $(VERSION_NUM) | tr -d ".") -gt 1021 ]; then echo y; fi), y) + LD = $(CC) + endif endif # Generally 32 bit and 64 bit compilers has different libgcc paths. diff --git a/build/mk/los_config.mk b/build/mk/los_config.mk index fd61e528fd76afb8def321547f5a3f2a988f982d..221c78dc8d0dd5aa279a5f3e94cc109f34a9a064 100644 --- a/build/mk/los_config.mk +++ b/build/mk/los_config.mk @@ -287,7 +287,11 @@ LITEOS_GCOV_OPTS := -fprofile-arcs -ftest-coverage -Wno-maybe-uninitialized LITEOS_BASELIB += -lgcov endif -LITEOS_LD_OPTS += -static --gc-sections +ifeq ($(LD), $(CC)) + LITEOS_LD_OPTS += -static -Wl,-gc-sections +else + LITEOS_LD_OPTS += -static --gc-sections +endif ifeq ($(LOSCFG_COMPILER_ARM_NONE_EABI)_$(shell if [ $(shell echo $(VERSION_NUM) | tr -d ".") -gt 1021 ]; then echo y; fi), y_y) LITEOS_LD_OPTS += else