diff --git a/arch/arm/src/Makefile b/arch/arm/src/Makefile index 0066baa028..98b85fca46 100644 --- a/arch/arm/src/Makefile +++ b/arch/arm/src/Makefile @@ -127,9 +127,6 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" -GCC_LIBDIR := ${shell dirname $(LIBGCC)} - VPATH += chip VPATH += common VPATH += $(ARCH_SUBDIR) @@ -168,7 +165,7 @@ nuttx$(EXEEXT): $(HEAD_OBJ) board$(DELIM)libboard$(LIBEXT) $(Q) echo "LD: nuttx" $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/arm/src/arm/Toolchain.defs b/arch/arm/src/arm/Toolchain.defs index 06fbde455d..ab0389c4ab 100644 --- a/arch/arm/src/arm/Toolchain.defs +++ b/arch/arm/src/arm/Toolchain.defs @@ -87,3 +87,18 @@ ifeq ($(CONFIG_ARM_TOOLCHAIN),GNU_EABI) ARCROSSDEV ?= arm-none-eabi- MAXOPTIMIZATION ?= -Os endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L ${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}} + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L ${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += lsupc++ + EXTRA_LIBPATHS += -L ${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} +endif diff --git a/arch/arm/src/armv6-m/Toolchain.defs b/arch/arm/src/armv6-m/Toolchain.defs index f3e8bf33ee..321fe3d24f 100644 --- a/arch/arm/src/armv6-m/Toolchain.defs +++ b/arch/arm/src/armv6-m/Toolchain.defs @@ -81,3 +81,18 @@ endif # optimization level will be set to -Os MAXOPTIMIZATION ?= -Os + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/arm/src/armv7-a/Toolchain.defs b/arch/arm/src/armv7-a/Toolchain.defs index eecf73d813..1fb4174874 100644 --- a/arch/arm/src/armv7-a/Toolchain.defs +++ b/arch/arm/src/armv7-a/Toolchain.defs @@ -105,3 +105,18 @@ ifeq ($(CONFIG_ARMV7A_TOOLCHAIN),GNU_EABI) ARCROSSDEV ?= $(TARGET_ARCH)-none-eabi- MAXOPTIMIZATION ?= -Os endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index a3cfdaa4d7..eaa2ff86e7 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -141,3 +141,18 @@ ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CLANG) MAXOPTIMIZATION ?= -Os ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/arm/src/armv7-r/Toolchain.defs b/arch/arm/src/armv7-r/Toolchain.defs index 3c93ce5d6a..4a3c780730 100644 --- a/arch/arm/src/armv7-r/Toolchain.defs +++ b/arch/arm/src/armv7-r/Toolchain.defs @@ -87,3 +87,18 @@ ifeq ($(CONFIG_ARMV7R_TOOLCHAIN),GNU_EABI) ARCROSSDEV ?= $(TARGET_ARCH)-none-eabi- MAXOPTIMIZATION ?= -Os endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/arm/src/armv8-m/Toolchain.defs b/arch/arm/src/armv8-m/Toolchain.defs index e8ffcca0fa..49c776ed20 100644 --- a/arch/arm/src/armv8-m/Toolchain.defs +++ b/arch/arm/src/armv8-m/Toolchain.defs @@ -131,3 +131,18 @@ ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),CLANG) MAXOPTIMIZATION ?= -Os ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/avr/src/Makefile b/arch/avr/src/Makefile index 913117e1f5..43dfcd80f2 100644 --- a/arch/avr/src/Makefile +++ b/arch/avr/src/Makefile @@ -99,8 +99,6 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" - VPATH = chip:common:$(ARCH_SUBDIR) all: $(HEAD_OBJ) libarch$(LIBEXT) @@ -121,8 +119,9 @@ board/libboard$(LIBEXT): nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) @echo "LD: nuttx" - $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/avr/src/avr/Toolchain.defs b/arch/avr/src/avr/Toolchain.defs index 07143f91ea..62ee983366 100644 --- a/arch/avr/src/avr/Toolchain.defs +++ b/arch/avr/src/avr/Toolchain.defs @@ -125,3 +125,18 @@ ifeq ($(CONFIG_AVR_TOOLCHAIN),WINAVR) MAXOPTIMIZATION ?= -O2 LDFLAGS += -nostartfiles -nodefaultlibs endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/avr/src/avr32/Toolchain.defs b/arch/avr/src/avr32/Toolchain.defs index 30b6af7a26..e85f418e62 100644 --- a/arch/avr/src/avr32/Toolchain.defs +++ b/arch/avr/src/avr32/Toolchain.defs @@ -50,3 +50,18 @@ CROSSDEV = avr32- ARCHCPUFLAGS = -mpart=uc3b0256 # AVR Tools or avr32-toolchain from https://github.com/jsnyder/avr32-toolchain + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/hc/src/Makefile b/arch/hc/src/Makefile index 634538eac9..40bfc1c5b2 100644 --- a/arch/hc/src/Makefile +++ b/arch/hc/src/Makefile @@ -100,7 +100,20 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif VPATH = chip:common:$(ARCH_SUBDIR) @@ -121,8 +134,9 @@ board/libboard$(LIBEXT): nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) $(Q) echo "LD: nuttx" - $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/mips/src/Makefile b/arch/mips/src/Makefile index bf1ca171be..899c9a2634 100644 --- a/arch/mips/src/Makefile +++ b/arch/mips/src/Makefile @@ -97,8 +97,6 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" - VPATH = chip:common:$(ARCH_SUBDIR) all: $(HEAD_OBJ) libarch$(LIBEXT) @@ -119,8 +117,9 @@ board/libboard$(LIBEXT): nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) @echo "LD: nuttx" - $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/mips/src/mips32/Toolchain.defs b/arch/mips/src/mips32/Toolchain.defs index 51f682e8fd..12936af98a 100644 --- a/arch/mips/src/mips32/Toolchain.defs +++ b/arch/mips/src/mips32/Toolchain.defs @@ -258,3 +258,13 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),PINGUINOW) LDFLAGS += -nostartfiles -nodefaultlibs LDSCRIPT = mips-elf-debug.ld endif + +# Add the builtin library + +EXTRA_LIBS += ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a} +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a} +endif +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a} +endif diff --git a/arch/misoc/src/Makefile b/arch/misoc/src/Makefile index 7b0488767d..d4f4507a2a 100644 --- a/arch/misoc/src/Makefile +++ b/arch/misoc/src/Makefile @@ -101,8 +101,6 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" - VPATH = chip:common:$(ARCH_SUBDIR) all: $(HEAD_OBJ) libarch$(LIBEXT) @@ -122,8 +120,9 @@ board/libboard$(LIBEXT): $(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" libboard$(LIBEXT) EXTRAFLAGS="$(EXTRAFLAGS)" nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) - $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/misoc/src/lm32/Toolchain.defs b/arch/misoc/src/lm32/Toolchain.defs index d0cc812479..f9123a74b6 100644 --- a/arch/misoc/src/lm32/Toolchain.defs +++ b/arch/misoc/src/lm32/Toolchain.defs @@ -91,3 +91,18 @@ ifeq ($(CONFIG_LM32_TOOLCHAIN),GNUL) ARCROSSDEV ?= lm32-elf- MAXOPTIMIZATION ?= -Os endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/misoc/src/minerva/Toolchain.defs b/arch/misoc/src/minerva/Toolchain.defs index 3036dcc1d1..4d6758d787 100644 --- a/arch/misoc/src/minerva/Toolchain.defs +++ b/arch/misoc/src/minerva/Toolchain.defs @@ -42,3 +42,18 @@ ARCHCPUFLAGS = -march=rv32i ifeq ($(CONFIG_DEBUG_SYMBOLS),) MAXOPTIMIZATION ?= -Os endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/or1k/src/Makefile b/arch/or1k/src/Makefile index e6bc759803..6564902990 100644 --- a/arch/or1k/src/Makefile +++ b/arch/or1k/src/Makefile @@ -118,9 +118,6 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" -GCC_LIBDIR := ${shell dirname $(LIBGCC)} - VPATH += chip VPATH += common VPATH += $(ARCH_SUBDIR) @@ -161,7 +158,7 @@ nuttx$(EXEEXT): $(HEAD_OBJ) board$(DELIM)libboard$(LIBEXT) $(Q) echo "LD: nuttx" $(Q) $(LD) --entry=0x100 $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/or1k/src/mor1kx/Toolchain.defs b/arch/or1k/src/mor1kx/Toolchain.defs index 720cb304e6..4c280c89e6 100644 --- a/arch/or1k/src/mor1kx/Toolchain.defs +++ b/arch/or1k/src/mor1kx/Toolchain.defs @@ -69,3 +69,18 @@ ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs LDSCRIPT = or1k-elf-debug.ld #endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/renesas/src/Makefile b/arch/renesas/src/Makefile index 275fa99707..334c1cc54f 100644 --- a/arch/renesas/src/Makefile +++ b/arch/renesas/src/Makefile @@ -93,7 +93,20 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = ${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name} +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif VPATH = chip:common @@ -115,8 +128,9 @@ board/libboard$(LIBEXT): nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) @echo "LD: nuttx" - $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/risc-v/src/Makefile b/arch/risc-v/src/Makefile index 1ba7a6e0e4..0bab78231d 100644 --- a/arch/risc-v/src/Makefile +++ b/arch/risc-v/src/Makefile @@ -122,9 +122,6 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" -GCC_LIBDIR := ${shell dirname $(LIBGCC)} - VPATH += chip VPATH += common VPATH += $(ARCH_SUBDIR) @@ -158,7 +155,7 @@ nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) $(Q) echo "LD: nuttx" $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/risc-v/src/rv32im/Toolchain.defs b/arch/risc-v/src/rv32im/Toolchain.defs index b1ba0e2894..66d6e378ae 100644 --- a/arch/risc-v/src/rv32im/Toolchain.defs +++ b/arch/risc-v/src/rv32im/Toolchain.defs @@ -103,3 +103,18 @@ endif ifeq ($(CONFIG_DEBUG_SYMBOLS),) MAXOPTIMIZATION ?= -Os endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/risc-v/src/rv64gc/Toolchain.defs b/arch/risc-v/src/rv64gc/Toolchain.defs index ea947c3948..712d84e966 100644 --- a/arch/risc-v/src/rv64gc/Toolchain.defs +++ b/arch/risc-v/src/rv64gc/Toolchain.defs @@ -83,3 +83,18 @@ endif ifeq ($(CONFIG_DEBUG_SYMBOLS),) MAXOPTIMIZATION ?= -Os endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/x86/src/Makefile b/arch/x86/src/Makefile index 24b00a88ff..a51dfde22f 100644 --- a/arch/x86/src/Makefile +++ b/arch/x86/src/Makefile @@ -97,14 +97,19 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" +# Add the builtin library -ifeq ($(HOSTOS),FreeBSD) - HOST_ARCH = ${shell uname -m 2>/dev/null || echo "Other"} - ifeq ($(HOST_ARCH),amd64) - LDFLAGS += -melf_i386 - LIBGCC = "/usr/lib32/libgcc.a" - endif +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" endif VPATH = chip:common:$(ARCH_SUBDIR) @@ -127,8 +132,9 @@ board/libboard$(LIBEXT): nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) @echo "LD: nuttx$(EXEEXT)" - $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/x86_64/src/Makefile b/arch/x86_64/src/Makefile index 214e2fd719..3056c69ef9 100644 --- a/arch/x86_64/src/Makefile +++ b/arch/x86_64/src/Makefile @@ -84,10 +84,19 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" +# Add the builtin library -ifeq ($(HOSTOS),FreeBSD) - HOST_ARCH = ${shell uname -m 2>/dev/null || echo "Other"} +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" endif VPATH = chip:common:$(ARCH_SUBDIR) @@ -118,8 +127,9 @@ board/libboard$(LIBEXT): nuttx$(EXEEXT): board/libboard$(LIBEXT) @echo "LD: nuttx$(EXEEXT)" - $(Q) $(LD) $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LIBGCC) --whole-archive --no-relax $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) + $(Q) $(LD) $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(EXTRA_LIBS) --whole-archive --no-relax $(LDLIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/xtensa/src/Makefile b/arch/xtensa/src/Makefile index 24de738236..7a52fcd6a3 100644 --- a/arch/xtensa/src/Makefile +++ b/arch/xtensa/src/Makefile @@ -98,8 +98,6 @@ ifeq ($(BOARDMAKE),y) LDLIBS += -lboard endif -LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" - VPATH = chip:common:$(ARCH_SUBDIR) all: $(STARTUP_OBJS) libarch$(LIBEXT) @@ -120,8 +118,9 @@ board/libboard$(LIBEXT): nuttx$(EXEEXT): $(STARTUP_OBJS) board/libboard$(LIBEXT) @echo "LD: nuttx" - $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(STARTUP_OBJS) $(EXTRA_OBJS) \ - $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) + $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ + -o $(NUTTX) $(STARTUP_OBJS) $(EXTRA_OBJS) \ + $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) $(Q) $(NM) $(NUTTX) | \ grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index c9222c0c36..8e0ec2c590 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -57,3 +57,18 @@ ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) else MAXOPTIMIZATION := -Os endif + +# Add the builtin library + +EXTRA_LIBS += -lgcc +EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcc.a}}" + +ifneq ($(CONFIG_LIBM),y) + EXTRA_LIBS += -lm + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}" +endif + +ifeq ($(CONFIG_CXX_LIBSUPCXX),y) + EXTRA_LIBS += -lsupc++ + EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}" +endif diff --git a/arch/z80/src/Makefile.sdccl b/arch/z80/src/Makefile.sdccl index e63dda8ce0..bc328d944d 100644 --- a/arch/z80/src/Makefile.sdccl +++ b/arch/z80/src/Makefile.sdccl @@ -74,10 +74,6 @@ BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board VPATH = chip:common:board -# Libraries - -LIBGCC = ${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name} - # Targets all: $(HEAD_OBJ) libarch$(LIBEXT) diff --git a/arch/z80/src/Makefile.sdccw b/arch/z80/src/Makefile.sdccw index cbcdb89584..016023f843 100644 --- a/arch/z80/src/Makefile.sdccw +++ b/arch/z80/src/Makefile.sdccw @@ -74,10 +74,6 @@ BOARDDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src\board VPATH = chip:common:board -# Libraries - -LIBGCC = ${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name} - # Targets all: $(HEAD_OBJ) libarch$(LIBEXT) diff --git a/boards/arm/imxrt/imxrt1050-evk/configs/libcxxtest/Make.defs b/boards/arm/imxrt/imxrt1050-evk/configs/libcxxtest/Make.defs index fd86272790..ace24c6721 100644 --- a/boards/arm/imxrt/imxrt1050-evk/configs/libcxxtest/Make.defs +++ b/boards/arm/imxrt/imxrt1050-evk/configs/libcxxtest/Make.defs @@ -54,10 +54,6 @@ else LDSCRIPT = flash-ocram.ld endif -LIBSUPXX = ${shell $(CC) $(CXXFLAGS) --print-file-name=libsupc++.a} -EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}" -EXTRA_LIBS = -lsupc++ - ifeq ($(CONFIG_CYGWIN_WINTOOL),y) ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}" else diff --git a/boards/arm/imxrt/imxrt1060-evk/configs/libcxxtest/Make.defs b/boards/arm/imxrt/imxrt1060-evk/configs/libcxxtest/Make.defs index 4384fcb50e..13c8b6956e 100644 --- a/boards/arm/imxrt/imxrt1060-evk/configs/libcxxtest/Make.defs +++ b/boards/arm/imxrt/imxrt1060-evk/configs/libcxxtest/Make.defs @@ -54,10 +54,6 @@ else LDSCRIPT = flash-ocram.ld endif -LIBSUPXX = ${shell $(CC) $(CXXFLAGS) --print-file-name=libsupc++.a} -EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}" -EXTRA_LIBS = -lsupc++ - ifeq ($(CONFIG_CYGWIN_WINTOOL),y) ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}" else diff --git a/boards/arm/lc823450/lc823450-xgevk/scripts/Make.defs b/boards/arm/lc823450/lc823450-xgevk/scripts/Make.defs index 1d10f41665..2b8f7d4f5a 100644 --- a/boards/arm/lc823450/lc823450-xgevk/scripts/Make.defs +++ b/boards/arm/lc823450/lc823450-xgevk/scripts/Make.defs @@ -135,5 +135,5 @@ endif # NEVER use 'override' variables # NUTTX_EXTRA_LIBS and NUTTX_EXTRA_LIBPATHS are defined by out-of-repository -EXTRA_LIBS := $(NUTTX_EXTRA_LIBS) $(ARCH_LIBS) -EXTRA_LIBPATHS := $(NUTTX_EXTRA_LIBPATHS) $(ARCH_LIBPATHS) +EXTRA_LIBS += $(NUTTX_EXTRA_LIBS) $(ARCH_LIBS) +EXTRA_LIBPATHS += $(NUTTX_EXTRA_LIBPATHS) $(ARCH_LIBPATHS) diff --git a/boards/arm/stm32/stm32f4discovery/configs/cxxtest/Make.defs b/boards/arm/stm32/stm32f4discovery/configs/cxxtest/Make.defs index 895f54ce7c..8419b275bc 100644 --- a/boards/arm/stm32/stm32f4discovery/configs/cxxtest/Make.defs +++ b/boards/arm/stm32/stm32f4discovery/configs/cxxtest/Make.defs @@ -33,10 +33,6 @@ OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump LDSCRIPT = ld.script -LIBSUPXX = ${shell $(CC) $(CXXFLAGS) --print-file-name=libsupc++.a} -EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}" -EXTRA_LIBS = -lsupc++ - ifeq ($(CONFIG_CYGWIN_WINTOOL),y) ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}" else diff --git a/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/Make.defs b/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/Make.defs index 28d75f3127..fc76b2a9ef 100644 --- a/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/Make.defs +++ b/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/Make.defs @@ -49,10 +49,6 @@ OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump LDSCRIPT = ld.script -LIBSUPXX = ${shell $(CC) $(CXXFLAGS) --print-file-name=libsupc++.a} -EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}" -EXTRA_LIBS = -lsupc++ - ifeq ($(CONFIG_CYGWIN_WINTOOL),y) ARCHSCRIPT = -T "${shell cygpath -w \ $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}" diff --git a/boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs b/boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs index b60b8e61d9..23b082c586 100644 --- a/boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs +++ b/boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs @@ -68,12 +68,6 @@ ifeq ($(CONFIG_LIBCXX),y) ifneq ($(CONFIG_CXX_EXCEPTION),y) CXXFLAGS += -fno-exceptions -fno-rtti -fcheck-new -D_LIBCPP_NO_EXCEPTIONS endif - - # supc++ is always needed with libcxx - - LIBSUPXX = ${shell $(CC) $(CFLAGS) --print-file-name=libsupc++.a} - EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}" - EXTRA_LIBS = -lsupc++ endif NXFLATLDFLAGS1 = -r -d -warn-common diff --git a/boards/sim/sim/sim/configs/cxxtest/Make.defs b/boards/sim/sim/sim/configs/cxxtest/Make.defs index 5c80c43ab3..18a95f2287 100644 --- a/boards/sim/sim/sim/configs/cxxtest/Make.defs +++ b/boards/sim/sim/sim/configs/cxxtest/Make.defs @@ -127,10 +127,6 @@ LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS -LIBSUPXX = ${shell $(CC) $(CXXFLAGS) --print-file-name=libsupc++.a} -EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}" -EXTRA_LIBS = -lsupc++ - ifeq ($(CONFIG_DEBUG_SYMBOLS),y) CCLINKFLAGS += -g endif diff --git a/tools/mkexport.sh b/tools/mkexport.sh index c10e9170a7..72a4c7a8f5 100755 --- a/tools/mkexport.sh +++ b/tools/mkexport.sh @@ -282,7 +282,6 @@ if [ "X${USRONLY}" != "Xy" ]; then echo "LDENDGROUP = ${LDENDGROUP}" >>"${EXPORTDIR}/scripts/Make.defs" echo "LDFLAGS = ${LDFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs" echo "LDSTARTGROUP = ${LDSTARTGROUP}" >>"${EXPORTDIR}/scripts/Make.defs" - echo "LIBGCC = ${LIBGCC}" >>"${EXPORTDIR}/scripts/Make.defs" fi # Copy the system map file(s)