From a4f7e562efe513602bf043df81fbfb153cb7cbe0 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 17 Feb 2017 05:54:56 -0800 Subject: [PATCH] Makefile.toolchain.zephyr: fix xtensa support Building zephyr for xtensa with gcc requires additional include paths and additional library (libhal). Add xtensa sysroot and include paths to CFLAGS when building for xtensa. The root Makefile then does the right thing adding these parameters to KBUILD_CFLAGS and KBUILD_ASFLAGS. Add xtensa libhal to the TOOLCHAIN_LIBS_xtensa. Modify TOOLICHAIN_LIBS to include arch-specific libraries. Seems that it would be nice to have TOOLCHAIN_CFLAGS_$(ARCH) with the same behavior as TOOLCHAIN_LIBS_$(ARCH). It also seems that the SYSROOT definition doesn't have to be restricted to MAKEFILE_TOOLCHAIN_DO_PASS2. Change-Id: Ia6703ca067b964ac2f8be8fe8513ca28f101a6a3 Signed-off-by: Max Filippov --- scripts/Makefile.toolchain.zephyr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.toolchain.zephyr b/scripts/Makefile.toolchain.zephyr index 8aa81ddae25..e0e04dfb8b5 100644 --- a/scripts/Makefile.toolchain.zephyr +++ b/scripts/Makefile.toolchain.zephyr @@ -87,6 +87,11 @@ CROSS_COMPILE_nios2=$(TOOLCHAIN_HOME)/usr/bin/$(CROSS_COMPILE_TARGET_nios2)/$(CR CROSS_COMPILE_TARGET_xtensa = xtensa-$(TOOLCHAIN_VENDOR)-elf SYSROOT_TARGET_xtensa = xtensa-$(TOOLCHAIN_VENDOR)-elf CROSS_COMPILE_xtensa=$(TOOLCHAIN_HOME)/usr/bin/$(CROSS_COMPILE_TARGET_xtensa)/$(CROSS_COMPILE_TARGET_xtensa)- +ifeq ($(ARCH),xtensa) +SYSROOT := ${ZEPHYR_SDK_INSTALL_DIR}/sysroots/${SYSROOT_TARGET_${ARCH}} +CFLAGS += --sysroot=$(SYSROOT) -I=/usr/include -I=/usr/include/arch/include +endif +TOOLCHAIN_LIBS_xtensa = hal # riscv32 (pass1) CROSS_COMPILE_TARGET_riscv32 = riscv32-$(TOOLCHAIN_VENDOR)-elf @@ -117,7 +122,7 @@ endif QEMU_BIN_PATH ?= $(TOOLCHAIN_HOME)/usr/bin QEMU_BIOS=$(TOOLCHAIN_HOME)/usr/share/qemu -TOOLCHAIN_LIBS = gcc +TOOLCHAIN_LIBS = gcc ${TOOLCHAIN_LIBS_${ARCH}} DTC = ${TOOLCHAIN_HOME}/usr/bin/dtc OPENOCD ?= ${TOOLCHAIN_HOME}/usr/bin/openocd