mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #6253 from gebart/pr/newlib-nano-include-dir-fix
LLVM+newlib include path search fixes
This commit is contained in:
commit
84b2910657
@ -70,7 +70,7 @@ $(OBJCXX): $(BINDIR)/$(MODULE)/%.o: %.cpp $(RIOTBUILD_CONFIG_HEADER_C)
|
|||||||
$(AD)$(CCACHE) $(CXX) \
|
$(AD)$(CCACHE) $(CXX) \
|
||||||
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \
|
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \
|
||||||
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
|
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
|
||||||
$(CXXFLAGS) $(INCLUDES) $(CXXINCLUDES) -MD -MP -c -o $@ $(abspath $<)
|
$(CXXFLAGS) $(CXXINCLUDES) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<)
|
||||||
|
|
||||||
$(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: %.s
|
$(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: %.s
|
||||||
$(AD)$(AS) $(ASFLAGS) -o $@ $(abspath $<)
|
$(AD)$(AS) $(ASFLAGS) -o $@ $(abspath $<)
|
||||||
|
@ -175,9 +175,6 @@ export TOOLCHAIN
|
|||||||
# will most likely not need to touch this.
|
# will most likely not need to touch this.
|
||||||
export PREFIX ?= $(if $(TARGET_ARCH),$(TARGET_ARCH)-)
|
export PREFIX ?= $(if $(TARGET_ARCH),$(TARGET_ARCH)-)
|
||||||
|
|
||||||
# Import all toolchain settings
|
|
||||||
include $(RIOTCPU)/Makefile.include.$(TOOLCHAIN)
|
|
||||||
|
|
||||||
# Add standard include directories
|
# Add standard include directories
|
||||||
INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include
|
INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include
|
||||||
INCLUDES += -I$(RIOTCPU)/$(CPU)/include
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/include
|
||||||
@ -189,6 +186,9 @@ include $(RIOTBASE)/Makefile.defaultmodules
|
|||||||
include $(RIOTBOARD)/$(BOARD)/Makefile.include
|
include $(RIOTBOARD)/$(BOARD)/Makefile.include
|
||||||
include $(RIOTCPU)/$(CPU)/Makefile.include
|
include $(RIOTCPU)/$(CPU)/Makefile.include
|
||||||
|
|
||||||
|
# Import all toolchain settings
|
||||||
|
include $(RIOTCPU)/Makefile.include.$(TOOLCHAIN)
|
||||||
|
|
||||||
# get number of interfaces straight before resolving dependencies
|
# get number of interfaces straight before resolving dependencies
|
||||||
GNRC_NETIF_NUMOF ?= 1
|
GNRC_NETIF_NUMOF ?= 1
|
||||||
|
|
||||||
|
@ -31,19 +31,24 @@ export DBG = $(GDBPREFIX)gdb
|
|||||||
GCC_CXX_INCLUDE_PATTERNS ?= \
|
GCC_CXX_INCLUDE_PATTERNS ?= \
|
||||||
/etc/alternatives/gcc-$(TARGET_ARCH)-include/c++/*/ \
|
/etc/alternatives/gcc-$(TARGET_ARCH)-include/c++/*/ \
|
||||||
/usr/$(TARGET_ARCH)/include/c++/*/ \
|
/usr/$(TARGET_ARCH)/include/c++/*/ \
|
||||||
|
/usr/lib/gcc/$(TARGET_ARCH)/*/include/g++-v8 \
|
||||||
|
/usr/lib/gcc/$(TARGET_ARCH)/*/include/g++-v7 \
|
||||||
|
/usr/lib/gcc/$(TARGET_ARCH)/*/include/g++-v6 \
|
||||||
/usr/lib/gcc/$(TARGET_ARCH)/*/include/g++-v5 \
|
/usr/lib/gcc/$(TARGET_ARCH)/*/include/g++-v5 \
|
||||||
#
|
#
|
||||||
|
|
||||||
# Try to find the proper multilib directory using GCC, this may fail if a cross-
|
# Try to find the proper multilib directory using GCC, this may fail if a cross-
|
||||||
# GCC is not installed.
|
# GCC is not installed.
|
||||||
ifeq ($(GCC_MULTI_DIR),)
|
ifeq ($(GCC_MULTI_DIR),)
|
||||||
GCC_MULTI_DIR := $(shell $(PREFIX)gcc -print-multi-directory $(CFLAGS) 2>/dev/null)
|
GCC_MULTI_DIR := $(shell $(PREFIX)gcc $(CFLAGS) -print-multi-directory 2>/dev/null)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(TARGET_ARCH))
|
||||||
# Tell clang to cross compile
|
# Tell clang to cross compile
|
||||||
export CFLAGS += -target $(TARGET_ARCH)
|
export CFLAGS += -target $(TARGET_ARCH)
|
||||||
export CXXFLAGS += -target $(TARGET_ARCH)
|
export CXXFLAGS += -target $(TARGET_ARCH)
|
||||||
export LINKFLAGS += -target $(TARGET_ARCH)
|
export LINKFLAGS += -target $(TARGET_ARCH)
|
||||||
|
endif
|
||||||
|
|
||||||
# Use the wildcard Makefile function to search for existing directories matching
|
# Use the wildcard Makefile function to search for existing directories matching
|
||||||
# the patterns above. We use the -isystem gcc/clang argument to add the include
|
# the patterns above. We use the -isystem gcc/clang argument to add the include
|
||||||
@ -54,8 +59,8 @@ export LINKFLAGS += -target $(TARGET_ARCH)
|
|||||||
# previous tool chain installations.
|
# previous tool chain installations.
|
||||||
GCC_CXX_INCLUDES ?= \
|
GCC_CXX_INCLUDES ?= \
|
||||||
$(addprefix \
|
$(addprefix \
|
||||||
-isystem $(lastword $(sort \
|
-isystem $(firstword \
|
||||||
$(foreach pat, $(GCC_CXX_INCLUDE_PATTERNS), $(wildcard $(pat))))), \
|
$(foreach pat, $(GCC_CXX_INCLUDE_PATTERNS), $(lastword $(sort $(wildcard $(pat)))))), \
|
||||||
/. /$(TARGET_ARCH)/$(GCC_MULTI_DIR) /backward \
|
/. /$(TARGET_ARCH)/$(GCC_MULTI_DIR) /backward \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ endif
|
|||||||
|
|
||||||
export LINKFLAGS += -lc -lnosys
|
export LINKFLAGS += -lc -lnosys
|
||||||
|
|
||||||
ifeq (1,$(USE_NEWLIB_NANO))
|
|
||||||
# Search for Newlib include directories
|
# Search for Newlib include directories
|
||||||
|
|
||||||
# Since Clang is not installed as a separate instance for each crossdev target
|
# Since Clang is not installed as a separate instance for each crossdev target
|
||||||
@ -49,13 +48,25 @@ NEWLIB_INCLUDE_DIR ?= $(firstword $(wildcard $(NEWLIB_INCLUDE_PATTERNS)))
|
|||||||
# If nothing was found we will try to fall back to searching for a cross-gcc in
|
# If nothing was found we will try to fall back to searching for a cross-gcc in
|
||||||
# the current PATH and use a relative path for the includes
|
# the current PATH and use a relative path for the includes
|
||||||
ifeq (,$(NEWLIB_INCLUDE_DIR))
|
ifeq (,$(NEWLIB_INCLUDE_DIR))
|
||||||
NEWLIB_INCLUDE_DIR := $(abspath $(wildcard $(dir $(shell which $(PREFIX)gcc))../$(TARGET_ARCH)/include))
|
NEWLIB_INCLUDE_DIR := $(abspath $(wildcard $(dir $(shell command -v $(PREFIX)gcc))../$(TARGET_ARCH)/include))
|
||||||
endif
|
|
||||||
NEWLIB_NANO_INCLUDE_DIR ?= $(NEWLIB_INCLUDE_DIR)/nano
|
|
||||||
# newlib-nano overrides newlib.h and its include dir should therefore go before
|
|
||||||
# the regular newlib include dir.
|
|
||||||
NEWLIB_INCLUDES := -isystem $(NEWLIB_NANO_INCLUDE_DIR)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Newlib includes should go before GCC includes.
|
ifeq ($(TOOLCHAIN),llvm)
|
||||||
export INCLUDES := $(NEWLIB_INCLUDES) $(INCLUDES)
|
# A cross GCC already knows the target libc include path (build-in at compile time)
|
||||||
|
# but Clang, when cross-compiling, needs to be told where to find the headers
|
||||||
|
# for the system being built.
|
||||||
|
# We also add -nostdinc to avoid including the host system headers by mistake
|
||||||
|
# in case some header is missing from the cross tool chain
|
||||||
|
NEWLIB_INCLUDES := -isystem $(NEWLIB_INCLUDE_DIR) -nostdinc
|
||||||
|
NEWLIB_INCLUDES += $(addprefix -isystem ,$(abspath $(wildcard $(dir $(NEWLIB_INCLUDE_DIR))/usr/include)))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq (1,$(USE_NEWLIB_NANO))
|
||||||
|
NEWLIB_NANO_INCLUDE_DIR ?= $(NEWLIB_INCLUDE_DIR)/newlib-nano
|
||||||
|
# newlib-nano overrides newlib.h and its include dir should therefore go before
|
||||||
|
# the regular system include dirs.
|
||||||
|
INCLUDES := -isystem $(NEWLIB_NANO_INCLUDE_DIR) $(INCLUDES)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Newlib includes should go after GCC includes.
|
||||||
|
export INCLUDES += $(NEWLIB_INCLUDES)
|
||||||
|
Loading…
Reference in New Issue
Block a user