diff --git a/arch/arm/src/armv6-m/Toolchain.defs b/arch/arm/src/armv6-m/Toolchain.defs index bb184aac86192..04f9fe33a0c2c 100644 --- a/arch/arm/src/armv6-m/Toolchain.defs +++ b/arch/arm/src/armv6-m/Toolchain.defs @@ -185,10 +185,12 @@ endif # Add the builtin library COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name) -ifeq ($(wildcard $(COMPILER_RT_LIB)),) - # if "--print-libgcc-file-name" unable to find the correct libgcc PATH - # then go ahead and try "--print-file-name" - COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) +ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),CLANG) + ifeq ($(wildcard $(COMPILER_RT_LIB)),) + # if "--print-libgcc-file-name" unable to find the correct libgcc PATH + # then go ahead and try "--print-file-name" + COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) + endif endif EXTRA_LIBS += $(COMPILER_RT_LIB) diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index 680f208de2941..2c4289f99cb7d 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -257,10 +257,12 @@ endif # Add the builtin library COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name) -ifeq ($(wildcard $(COMPILER_RT_LIB)),) - # if "--print-libgcc-file-name" unable to find the correct libgcc PATH - # then go ahead and try "--print-file-name" - COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CLANG) + ifeq ($(wildcard $(COMPILER_RT_LIB)),) + # if "--print-libgcc-file-name" unable to find the correct libgcc PATH + # then go ahead and try "--print-file-name" + COMPILER_RT_LIB := -$(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) + endif endif EXTRA_LIBS += $(COMPILER_RT_LIB) diff --git a/arch/arm/src/armv8-m/Toolchain.defs b/arch/arm/src/armv8-m/Toolchain.defs index 1302e676e2899..ee6bf7d86aa97 100644 --- a/arch/arm/src/armv8-m/Toolchain.defs +++ b/arch/arm/src/armv8-m/Toolchain.defs @@ -266,10 +266,12 @@ endif # Add the builtin library COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name) -ifeq ($(wildcard $(COMPILER_RT_LIB)),) - # if "--print-libgcc-file-name" unable to find the correct libgcc PATH - # then go ahead and try "--print-file-name" - COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) +ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),CLANG) + ifeq ($(wildcard $(COMPILER_RT_LIB)),) + # if "--print-libgcc-file-name" unable to find the correct libgcc PATH + # then go ahead and try "--print-file-name" + COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) + endif endif EXTRA_LIBS += $(COMPILER_RT_LIB)