arm-none-eabi-gcc“未实现且将始终失败”消息

snz8szmq  于 2023-06-05  发布在  其他
关注(0)|答案(1)|浏览(664)

我有两个stm32项目(一个使用stm32f103rb,另一个使用stm32f103re)。这两个项目都是使用cmake和基于stm32-cmake模板的make构建的,并且还使用了cubeMX HAL库。对于这两个项目我都使用this printf库,源代码的整体结构和实现的功能都是相似的.
当我构建项目时,我得到这些链接器消息,但仅在103re项目中,而不是另一个项目(两个项目都完全构建):

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

这些信息的原因是什么?以及为什么两个项目中编译器的行为不同?
附言:这不是几个星期前的情况,它发生在最近,可能是在更新或什么之后。

❮ 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

编辑一:

构建标志,在gcc-arm-none-eabi.cmake模块中:

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

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>)

CMakeLists.txt文件中的链接器标志:

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)

所有这些选项在两个文件中相同

编辑二:

两个项目中的一个源文件的make VERBOSE=1输出。我检查了vimdiff,它们是相同的(除了-DSTM32F103xE,在另一个项目中是-DSTM32F103xB

[  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命令:

[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

.map文件中搜索_write_r的结果:

stm32f103rb项目中:

/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

stm32f103re项目中:

/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
fgw7neuy

fgw7neuy1#

输入arm-none-eabi工具的安装目录,使用命令:

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

相关问题