Move "-nostartfiles -nodefaultlibs" from Make.defs to Toolchian.defs

and replace "-nostartfiles -nodefaultlibs" with "-nostdlib"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-05-15 12:32:04 +08:00 committed by hartmannathan
parent d7f7867f76
commit b30e0a26ef
28 changed files with 41 additions and 64 deletions

View File

@ -147,7 +147,7 @@ Creating the project
set(AC_HW_FLAGS "${AC_HW_FLAGS} -isystem ${NUTTX_PATH}/include")
set(AC_HW_FLAGS "${AC_HW_FLAGS} -pipe")
set(AC_LINKER_FLAGS "--entry=__start -nostartfiles -nodefaultlibs -T${MCU_LINKER_SCRIPT}")
set(AC_LINKER_FLAGS "--entry=__start -nostdlib -T${MCU_LINKER_SCRIPT}")
* hellocpp/src/CMakeLists.txt

View File

@ -113,6 +113,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
@ -153,7 +155,6 @@ ifeq ($(CONFIG_LTO_FULL),y)
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fuse-linker-plugin
ARCHOPTIMIZATION += -fno-builtin
ARCHOPTIMIZATION += -nodefaultlibs
endif
endif

View File

@ -144,6 +144,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
@ -200,7 +202,6 @@ ifeq ($(CONFIG_LTO_FULL),y)
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fuse-linker-plugin
ARCHOPTIMIZATION += -fno-builtin
ARCHOPTIMIZATION += -nodefaultlibs
endif
endif

View File

@ -222,7 +222,6 @@ else
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fno-builtin
ARCHOPTIMIZATION += -nodefaultlibs
endif
endif
endif
@ -243,6 +242,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)

View File

@ -136,6 +136,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
@ -176,7 +178,6 @@ ifeq ($(CONFIG_LTO_FULL),y)
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fuse-linker-plugin
ARCHOPTIMIZATION += -fno-builtin
ARCHOPTIMIZATION += -nodefaultlibs
endif
endif

View File

@ -231,7 +231,6 @@ else
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fno-builtin
ARCHOPTIMIZATION += -nodefaultlibs
endif
endif
endif
@ -252,6 +251,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)

View File

@ -46,6 +46,6 @@ $(BOOT_STAGE2).bin: %.bin: %.elf
$(OBJCOPY) -Obinary $< $@
$(BOOT_STAGE2).elf: $(BOOT2SRC)
$(CC) -nostartfiles -nodefaultlibs $(ARCHSCRIPT) $(BOOT2CFLAGS) -o $@ $<
$(CC) -nostdlib $(ARCHSCRIPT) $(BOOT2CFLAGS) -o $@ $<
EXTRADELFILE = $(BOOT_STAGE2).*

View File

@ -158,6 +158,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)

View File

@ -112,6 +112,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# NuttX buildroot GCC toolchain under Linux or Cygwin
ifeq ($(CONFIG_AVR_TOOLCHAIN),BUILDROOT)

View File

@ -60,6 +60,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
CROSSDEV = avr32-
ARCHCPUFLAGS = -mpart=uc3b0256

View File

@ -145,7 +145,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),GNU_ELF)
CROSSDEV ?= mips-elf-
ARCHCPUFLAGS = -mlong32 -membedded-data -msoft-float -march=$(MIPS_MARCH) $(MIPS_MICROMIPS) -EL
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = mips-elf-debug.ld
endif
@ -155,7 +154,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),PINGUINOL)
CROSSDEV ?= p32-
ARCHCPUFLAGS = -mlong32 -membedded-data -msoft-float -march=$(MIPS_MARCH) $(MIPS_MICROMIPS) -EL
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = pinguino-debug.ld
endif
@ -165,7 +163,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),SOURCERY_CODEBENCH_LITE)
CROSSDEV ?= mips-sde-elf-
ARCHCPUFLAGS = -mlong32 -membedded-data -msoft-float -march=$(MIPS_MARCH) $(MIPS_MICROMIPS) -EL
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = sourcery-debug.ld
endif
@ -174,7 +171,6 @@ endif
ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPL_XC32)
CROSSDEV ?= xc32-
ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) -march=$(MIPS_MARCH) -EL $(MIPS_MICROMIPS) -msmart-io=0
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = xc32-debug.ld
endif
@ -184,7 +180,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPL)
CROSSDEV ?= pic32-
ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = xc32-debug.ld
endif
@ -193,7 +188,6 @@ endif
ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPW_XC32)
CROSSDEV ?= xc32-
ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) -march=$(MIPS_MARCH) -EL $(MIPS_MICROMIPS) -msmart-io=0
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = xc32-debug.ld
endif
@ -203,7 +197,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPW)
CROSSDEV ?= pic32-
ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = c32-debug.ld
endif
@ -213,7 +206,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPL_LITE)
CROSSDEV ?= pic32-
ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = xc32-debug.ld
endif
@ -223,7 +215,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPW_LITE)
CROSSDEV ?= pic32-
ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = c32-debug.ld
endif
@ -233,7 +224,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPOPENL)
CROSSDEV ?= mypic32-
ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = c32-debug.ld
endif
@ -243,7 +233,6 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),PINGUINOW)
CROSSDEV ?= p32-
ARCHCPUFLAGS = -mlong32 -membedded-data -msoft-float -march=$(MIPS_MARCH) $(MIPS_MICROMIPS) -EL
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = mips-elf-debug.ld
endif
@ -285,6 +274,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Default toolchain
CC = $(CROSSDEV)gcc

View File

@ -65,6 +65,8 @@ else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
LDFLAGS += -nostdlib
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
ARCHOPTIMIZATION += -g

View File

@ -37,6 +37,8 @@ else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
LDFLAGS += -nostdlib
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
ARCHOPTIMIZATION += -g

View File

@ -48,6 +48,8 @@ else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
LDFLAGS += -nostdlib
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
ARCHOPTIMIZATION += -g
@ -79,7 +81,6 @@ endif
CROSSDEV ?= or1k-elf-
ARCHCPUFLAGS = -mboard=de0_nano
ARCHPICFLAGS = -fpic -membedded-pic
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = or1k-elf-debug.ld
#endif

View File

@ -94,6 +94,8 @@ ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
LDFLAGS += -nostdlib
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
@ -187,7 +189,6 @@ ifeq ($(CONFIG_LTO_FULL),y)
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fuse-linker-plugin
ARCHOPTIMIZATION += -fno-builtin
ARCHOPTIMIZATION += -nodefaultlibs
endif
endif

View File

@ -89,11 +89,12 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# NuttX buildroot GCC toolchain under Linux or Cygwin
ifeq ($(CONFIG_SPARC_TOOLCHAIN),BUILDROOT)
CROSSDEV ?= sparc-gaisler-elf-
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = sparc-gaisler-elf-debug.ld
endif
@ -101,7 +102,6 @@ endif
ifeq ($(CONFIG_SPARC_TOOLCHAIN),CODEREDW)
CROSSDEV ?= sparc-elf-
LDFLAGS += -nostartfiles -nodefaultlibs
LDSCRIPT = sparc-elf-debug.ld
endif

View File

@ -85,6 +85,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)

View File

@ -85,6 +85,8 @@ ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)

View File

@ -72,6 +72,8 @@ else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
LDFLAGS += -nostdlib
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections

View File

@ -27,13 +27,9 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -nostdlib -ffreestanding
ARCHCXXFLAGS += -nostdlib -ffreestanding
else
ifneq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -funwind-tables
ARCHCXXFLAGS += -funwind-tables
endif
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe

View File

@ -25,12 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = f446re.ld
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -nostdlib -ffreestanding
ARCHCXXFLAGS += -nostdlib -ffreestanding
endif
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe

View File

@ -30,12 +30,6 @@ endif
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -nostdlib -ffreestanding
ARCHCXXFLAGS += -nostdlib -ffreestanding
endif
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe

View File

@ -27,13 +27,9 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -nostdlib -ffreestanding
ARCHCXXFLAGS += -nostdlib -ffreestanding
else
ifneq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -funwind-tables
ARCHCXXFLAGS += -funwind-tables
endif
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe

View File

@ -25,11 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = flash.ld
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -nostdlib -ffreestanding
ARCHCXXFLAGS += -nostdlib -ffreestanding
endif
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe

View File

@ -66,7 +66,5 @@ CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL_XC32),y)
LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0
else
LDFLAGS = # -no-isn32 --relax
LDFLAGS += --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0
endif

View File

@ -66,7 +66,5 @@ CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL_XC32),y)
LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0
else
LDFLAGS = # -no-isn32 --relax
LDFLAGS += --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0
endif

View File

@ -66,7 +66,5 @@ CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL_XC32),y)
LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0
else
LDFLAGS = # -no-isn32 --relax
LDFLAGS += --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0
endif

View File

@ -38,9 +38,3 @@ CXXELFFLAGS = $(CXXFLAGS)
LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld)
# Linker flags
ifneq ($(CROSSDEV),sparc-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif