From 9e29fe0abddd32da0f241bc11a2b007449ca8cfb Mon Sep 17 00:00:00 2001 From: Tido Klaassen Date: Wed, 14 Oct 2015 18:48:08 +0200 Subject: [PATCH] Debian newlib nano workaround - made use of newlib's nano version configurable by make variable USE_NANO - added paragraphs to README.md explaining how and when to use USE_NANO and FIX_DEBIAN --- ports/cortex-m/Makefile | 27 ++++++++++++++++++--------- ports/cortex-m/README.md | 11 +++++++++++ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ports/cortex-m/Makefile b/ports/cortex-m/Makefile index 7b1824a..9cde99e 100644 --- a/ports/cortex-m/Makefile +++ b/ports/cortex-m/Makefile @@ -8,6 +8,21 @@ ifeq ($(V),) MAKEFLAGS += --no-print-directory endif +# Use the size optimised nano version of newlib. +# This usually is the version of newlib you want to use, although it has some +# limitations, like printf not having support for floating point vars. +# This relies on your newlib installation to provide a working nano.specs +# file. On Debian you will need at least version 2.1.0+git20141201.db59ff3-2 +# of package libnewlib-arm-none-eabi +USE_NANO := true + +# Debian's libnewlib-arm-none-eabi package version 2.2.0+git20150830.5a3d536-1 +# ships with a buggy nano.specs file that does not set up a proper include +# path for finding the nano version of newlib.h. +# Also, the nano version has been built with the -fshort-wchar option, making +# it incompatible with object files using the standard ABI. +#FIX_DEBIAN := true + # Build directory ifdef O build_dir=$(shell readlink -f $(O)) @@ -136,21 +151,15 @@ LDLIBS += -l$(LIBNAME) NEWLIBS += -lc -lgcc ifneq ($(BOARD),qemu) -# Use the size optimised nano version of newlib. -# This usually is the version of newlib you want to use, although it has some -# limitations, like printf not having support for floating point vars. +ifeq ($(USE_NANO),true) SPECS := -specs=nano.specs -ifneq ($(FIX_DEBIAN),) -# Debian's libnewlib-arm-none-eabi package version 2.2.0+git20150830.5a3d536-1 -# ships with a buggy nano.specs file that does not set up a proper include -# path for finding the nano version of newlib.h. -# Also, the nano version has been built with the -fshort-wchar option, making -# it incompatible with object files using the standard ABI. +ifeq ($(FIX_DEBIAN),true) SPECS += -I/usr/include/newlib/nano LOCM3_FLAGS += -fshort-wchar CFLAGS += -fshort-wchar endif +endif # Uncomment to link against libnosys if you do not want to use the provided # stubs. diff --git a/ports/cortex-m/README.md b/ports/cortex-m/README.md index 7419e14..d02bb48 100644 --- a/ports/cortex-m/README.md +++ b/ports/cortex-m/README.md @@ -20,6 +20,17 @@ apt-get install gcc-arm-none-eabi binutils-arm-none-eabi apt-get install libnewlib-arm-none-eabi libnewlib-dev apt-get install openocd ``` +**N.B.** Usually you will want to compile and link against the size optimised +"nano" version of newlib. This is done by default. If your version +of newlib does not support this (Debian's libnewlib package version before +2.1.0+git20141201.db59ff3-2) you will have to comment out the line +`USE_NANO := true` in the Makefile or pass `USE_NANO=` as +a command line option to make. + +**N.B.** Debian's libnewlib-arm-none-eabi version 2.2.0+git20150830.5a3d536-1 +ships with broken nano support. To enable necessary workarounds, uncomment +the line `#FIX_DEBIAN := true` in the Makefile or pass `FIX_DEBIAN=true` +as a command line option to make. ## Code Layout The "classic" port components (code needed for task set-up and context