arm-none-eabi-gcc "is not implemented and will always fail" messages

2.5k views Asked by At

I have two stm32 projects (one with stm32f103rb and the other with stm32f103re). Both projects are built using cmake and make based on stm32-cmake template and also use cubeMX HAL libraries. For both projects I use this printf library and overall structure of the source code and implemented functions are similar.

When I build the projects, I get these linker messages, but only in the 103re project and not the other one (both project build completely):

usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-closer.o): in function `_close_r':
/build/arm-none-eabi-newlib/src/build-nano/arm-none-eabi/thumb/v7-m/nofp/newlib/../../../../../../newlib-4.3.0.20230120/newlib/libc/reent/closer.c:47: warning: _close is not implemented and will always fail
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-lseekr.o): in function `_lseek_r':
/build/arm-none-eabi-newlib/src/build-nano/arm-none-eabi/thumb/v7-m/nofp/newlib/../../../../../../newlib-4.3.0.20230120/newlib/libc/reent/lseekr.c:49: warning: _lseek is not implemented and will always fail
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-readr.o): in function `_read_r':
/build/arm-none-eabi-newlib/src/build-nano/arm-none-eabi/thumb/v7-m/nofp/newlib/../../../../../../newlib-4.3.0.20230120/newlib/libc/reent/readr.c:49: warning: _read is not implemented and will always fail
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-writer.o): in function `_write_r':
/build/arm-none-eabi-newlib/src/build-nano/arm-none-eabi/thumb/v7-m/nofp/newlib/../../../../../../newlib-4.3.0.20230120/newlib/libc/reent/writer.c:49: warning: _write is not implemented and will always fail

What's the reason for these messages? and why the compiler behavior is different in two project?

PS: this wasn't the case couple of weeks ago and it happens recently probably after an update or something.

❮ pacman -Q | grep arm-none-eabi
arm-none-eabi-binutils 2.39-2
arm-none-eabi-gcc 12.2.0-1
arm-none-eabi-gdb 13.1-1
arm-none-eabi-newlib 4.3.0.20230120-1

Edit 1:

build flags, in gcc-arm-none-eabi.cmake module:

set(CMAKE_C_FLAGS_INIT
    "-fdata-sections -ffunction-sections --specs=nano.specs --specs=nosys.specs -Wl,--gc-sections")

compile options in CMakeLists.txt:

target_compile_options(${EXECUTABLE} PRIVATE
    ${CPU_PARAMETERS}
    -Wall
    -Wextra
    -Wpedantic
    -Wshadow
    -Wdouble-promotion
    -Wformat=2 -Wformat-truncation
    -Wundef
    -fno-common
    -Wno-unused-parameter
    $<$<COMPILE_LANGUAGE:CXX>:
        -Wconversion
        -Wno-volatile
        -Wold-style-cast
        -Wuseless-cast
        -Wsuggest-override>
    $<$<CONFIG:Debug>:-Og -g3 -ggdb>
    $<$<CONFIG:Release>:-Og -g0>)

and linker flags in CMakeLists.txt file:

target_link_options(${EXECUTABLE} PRIVATE
    -T${MCU_LINKER_SCRIPT}
    ${CPU_PARAMETERS}
    -Wl,-Map=${CMAKE_PROJECT_NAME}.map
    -Wl,--start-group
    -lc
    -lm
    -lnosys
    -lstdc++
    -Wl,--end-group
    -Wl,--print-memory-usage)

All these options are identical in both files

Edit 2:

Output of make VERBOSE=1 for one of the source files in both projects. I checked with vimdiff and they are identical (except -DSTM32F103xE which is -DSTM32F103xB on the other project:

[  3%] Building C object CMakeFiles/ap-v0.2-22-gd2cd.dir/Core/Src/dma.c.obj
/usr/bin/arm-none-eabi-gcc -DSTM32F103xE -DUSE_HAL_DRIVER -I/home/mehdi/wrk/code/ap -isystem /home/mehdi/wrk/code/ap/Core/Inc -isystem /home/mehdi/wrk/code/ap/Drivers/STM32F1xx_HAL_Driver/Inc -isystem /home/mehdi/wrk/code/ap/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -isystem /home/mehdi/wrk/code/ap/
Drivers/CMSIS/Device/ST/STM32F1xx/Include -isystem /home/mehdi/wrk/code/ap/Drivers/CMSIS/Include -fdata-sections -ffunction-sections --specs=nano.specs --specs=nosys.specs -Wl,--gc-sections -g -mcpu=cortex-m3 -mthumb -Wall -Wextra -Wpedantic -Wshadow -Wdouble-promotion -Wformat=2 -Wformat-truncati
on -Wundef -fno-common -Wno-unused-parameter -Og -g3 -ggdb -std=gnu11 -MD -MT CMakeFiles/ap-v0.2-22-gd2cd.dir/Core/Src/dma.c.obj -MF CMakeFiles/ap-v0.2-22-gd2cd.dir/Core/Src/dma.c.obj.d -o CMakeFiles/ap-v0.2-22-gd2cd.dir/Core/Src/dma.c.obj -c /home/mehdi/wrk/code/ap/Core/Src/dma.c

link command:

[100%] Linking C executable ap-v0.2-22-gd2cd.elf
/usr/bin/cmake -E cmake_link_script CMakeFiles/ap-v0.2-22-gd2cd.dir/link.txt --verbose=1
/usr/bin/arm-none-eabi-gcc -fdata-sections -ffunction-sections --specs=nano.specs --specs=nosys.specs -Wl,--gc-sections -g -T/home/mehdi/wrk/code/ap/CubeMX/STM32F103RETx_FLASH.ld -mcpu=cortex-m3 -mthumb -Wl,-Map=ap.map -Wl,--start-group -lc -lm -lnosys -lstdc++ -Wl,--end-group -Wl,--print-memory-u
sage "CMakeFiles/ap-v0.2-22-gd2cd.dir/Core/Src/dma.c.obj" ... all other sources

search results for _write_r in .map file:

in stm32f103rb project:

/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-writer.o)
                              /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-stdio.o) (_write_r)

 .text._write_r
                0x0000000008008c8c       0x24 /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-writer.o)
                0x0000000008008c8c                _write_r

in stm32f103re project:

/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-writer.o)
                              /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-stdio.o) (_write_r)

 .text          0x0000000000000000        0x0 /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-writer.o)
 .data          0x0000000000000000        0x0 /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-writer.o)
 .bss           0x0000000000000000        0x0 /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc_nano.a(libc_a-writer.o)
 .text._write_r
1

There are 1 answers

3
zylaputa On

This warning message defined in newlib-cygwin/libgloss/libnosys /warning.h , as a .gnu.warning.* section, you can remove it use objcopy.

Enter your arm-none-eabi tools install dir, use command:

find -name "libnosys.a" -exec arm-none-eabi-objcopy -R .gnu.warning.* {} \;