Switch to nano version of newlib (#5180)

* Switch to nano version of newlib

save about 50k of flash and 2k of RAM on Taranis

* Make nano optional, default=off and use bin_alloc for it
This commit is contained in:
Arne Schwabe
2017-09-01 18:37:30 +02:00
committed by Bertrand Songis
parent fdacf83ad0
commit 5b5c88fb4e
+13
View File
@@ -41,6 +41,7 @@ option(TRACE_SIMPGMSPACE "Turn on traces in simpgmspace.cpp" ON)
option(TRACE_LUA_INTERNALS "Turn on traces for Lua internals" OFF)
option(BINDING_OPTIONS "Allow advanced frsky bindings" OFF)
option(FRSKY_STICKS "Reverse sticks for FrSky sticks" OFF)
option(NANO "Use nano newlib and binalloc")
# since we reset all default CMAKE compiler flags for firmware builds, provide an alternate way for user to specify additional flags.
set(FIRMWARE_C_FLAGS "" CACHE STRING "Additional flags for firmware target c compiler (note: all CMAKE_C_FLAGS[_*] are ignored for firmware/bootloader).")
@@ -467,7 +468,19 @@ if(NOT MSVC)
add_definitions(-DSEMIHOSTING)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=rdimon.specs")
endif()
# Use newlib nano, which saves a few kilobytes.
if(NOT NANO STREQUAL NO)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs")
if(NOT LUA STREQUAL NO)
# Lua needs %g and %f
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -u _printf_float -u _scanf_float")
endif()
# Nano's malloc does work well with lua, use our own
add_definitions(-DUSE_BIN_ALLOCATOR)
set(SRC ${SRC} bin_allocator.cpp)
endif()
if(PCB STREQUAL X9D OR PCB STREQUAL X9D+ OR PCB STREQUAL X9E OR PCB STREQUAL X7 OR PCB STREQUAL X7S)
add_subdirectory(targets/${TARGET_DIR}/bootloader)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/targets/${TARGET_DIR}/bootloader)