toolchain: add libm to EXTRA_LIBS only if it is provided by the compiler

Some toolchains may be built without libm support, but using
such toochain should not generate any errors in case if math
functions are not used in the program

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko 2022-01-21 22:33:13 +02:00 committed by Xiang Xiao
parent f73abc76d5
commit 6c27f3c19d
19 changed files with 166 additions and 52 deletions

View File

@ -104,14 +104,20 @@ OBJDUMP = $(CROSSDEV)objdump
# Add the builtin library
EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L ${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L ${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += lsupc++
EXTRA_LIBPATHS += -L ${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}
EXTRA_LIBS += -lsupc++
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}"
endif

View File

@ -99,8 +99,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -125,8 +125,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -158,8 +158,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -107,8 +107,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -157,8 +157,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -130,8 +130,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -54,8 +54,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -88,16 +88,22 @@ endif
# Add the builtin library
EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}}"
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += -lsupc++
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}"
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}"
endif
VPATH = chip:common:$(ARCH_SUBDIR)

View File

@ -280,14 +280,20 @@ OBJDUMP = $(CROSSDEV)objdump
# Add the builtin library
EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L ${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L ${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += lsupc++
EXTRA_LIBPATHS += -L ${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}
EXTRA_LIBS += -lsupc++
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}"
endif

View File

@ -91,8 +91,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -45,8 +45,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -72,8 +72,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -81,16 +81,22 @@ endif
# Add the builtin library
EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L"${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
EXTRA_LIBPATHS += -L""${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}""
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L"${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += -lsupc++
EXTRA_LIBPATHS += -L"${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}"
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}"
endif
VPATH = chip:common

View File

@ -133,8 +133,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -85,16 +85,22 @@ endif
# Add the builtin library
EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}}"
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += -lsupc++
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}"
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}"
endif
VPATH = chip:common:$(ARCH_SUBDIR)

View File

@ -87,16 +87,22 @@ endif
# Add the builtin library
EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}}"
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += -lsupc++
EXTRA_LIBPATHS += -L "${dir ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}"
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}"
endif
VPATH = chip:common:$(ARCH_SUBDIR)

View File

@ -83,8 +83,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)

View File

@ -83,8 +83,14 @@ EXTRA_LIBS += -lgcc
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
# Check if libm is provided by the compiler
ifneq ($(LIBM_PATH),".")
EXTRA_LIBS += -lm
EXTRA_LIBPATHS += -L $(LIBM_PATH)
endif
endif
ifeq ($(CONFIG_LIBSUPCXX),y)