From 36a66a7243126bc8f38d3c4bdea46bce18ff5a7a Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 2 Jan 2020 15:52:13 +0100 Subject: [PATCH] newlib: use --specs=nano.specs to enable "nano" version of C library esp2020r1 toolchain includes a nano.specs file, which instructs GCC to substitute libc.a with libc_nano.a. In the build system, this simplifies handling of the nano formatting option, eliminating LIBC and LIBM global variables. --- components/app_trace/CMakeLists.txt | 2 +- components/newlib/CMakeLists.txt | 6 +++++- components/newlib/project_include.cmake | 7 ------- 3 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 components/newlib/project_include.cmake diff --git a/components/app_trace/CMakeLists.txt b/components/app_trace/CMakeLists.txt index e982d1911..3ee0ff655 100644 --- a/components/app_trace/CMakeLists.txt +++ b/components/app_trace/CMakeLists.txt @@ -39,4 +39,4 @@ target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-c # Force app_trace to also appear later than gcov in link line idf_component_get_property(app_trace app_trace COMPONENT_LIB) -target_link_libraries(${COMPONENT_LIB} INTERFACE $ gcov $ ${LIBC}) +target_link_libraries(${COMPONENT_LIB} INTERFACE $ gcov $ c) diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index 2738e130d..1ffa52b6f 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -29,7 +29,7 @@ idf_component_register(SRCS "${srcs}" # Toolchain libraries require code defined in this component idf_component_get_property(newlib newlib COMPONENT_LIB) -target_link_libraries(${COMPONENT_LIB} INTERFACE ${LIBC} ${LIBM} gcc "$") +target_link_libraries(${COMPONENT_LIB} INTERFACE c m gcc "$") set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin) @@ -40,3 +40,7 @@ list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl") list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl") list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl") target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}") + +if(CONFIG_NEWLIB_NANO_FORMAT) + target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs") +endif() diff --git a/components/newlib/project_include.cmake b/components/newlib/project_include.cmake deleted file mode 100644 index 4a1784908..000000000 --- a/components/newlib/project_include.cmake +++ /dev/null @@ -1,7 +0,0 @@ -if(CONFIG_NEWLIB_NANO_FORMAT) - set(LIBC c_nano) -else() - set(LIBC c) -endif() - -set(LIBM m)