Hi,
While upgrading a project from the 11.2 to 12.2 releases of the GNU ARM Embedded toolchain, I'm encountering a problem:
[344/346] cmd.exe /C "cd . && C:\tools\jetbrains\apps\CLion\ch-0\223.8617.54\bin\cmake\win\x64\bin\cmake.exe -E rm -f ext\soup\hal\libstm32h7_hal_resmgr.a && C:\PROGRA~2\ARMGNU~1\12DBAB~1.2RE\bin\ARM-NO~2.EXE qc ext\soup\hal\libstm32h7_hal_resmgr.a ext/soup/hal/CMakeFiles/stm32h7_hal_resmgr.dir/STM32CubeH7/Utilities/ResourcesManager/res_mgr.c.obj && C:\PROGRA~2\ARMGNU~1\12DBAB~1.2RE\bin\AR17F9~1.EXE ext\soup\hal\libstm32h7_hal_resmgr.a && cd ." [345/346] cmd.exe /C "cd . && C:\PROGRA~2\ARMGNU~1\12DBAB~1.2RE\bin\AR19DD~1.EXE -O0 -g3 -DDEBUG -TC:/src/h7-eval/CM4/STM32H757XIHX_FLASH.ld -Wl,--cref -Wl,--print-memory-usage -Wl,-Map=C:/src/cmake-build-h7m4-debug-gnu-arm-113/h7-eval/CM4/h7-eval-m4.map -mthumb -mcpu=cortex-m4 -mabi=aapcs --specs=nano.specs -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -static -Wl,--start-group -lc -lm -Wl,--end-group h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/Common/Src/system_stm32h7xx_dualcore_boot_cm4_cm7.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/adc.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/crc.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/cryp.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/dcmi.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/dma2d.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/eth.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/fmc.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/gpio.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/hash.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/i2c.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/main.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/resmgr_utility.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/rng.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/spi.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/stm32h7xx_hal_msp.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/stm32h7xx_it.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/syscalls.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/sysmem.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/tim.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/usart.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Startup/startup_stm32h757xihx.s.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/ThreadX/tx_initialize_low_level.S.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/ThreadX/stm32h7xx_hal_timebase_tim.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/__/ext/soup/threadx/threadx/utility/execution_profile_kit/tx_execution_profile.c.obj -o h7-eval\CM4\h7-eval-m4.elf ext/soup/hal/libstm32h7_hal.a ext/soup/hal/libstm32h7_hal_resmgr.a ext/soup/threadx/threadx/libthreadx.a ext/soup/hal/libstm32h7_hal.a && cd ." FAILED: h7-eval/CM4/h7-eval-m4.elf cmd.exe /C "cd . && C:\PROGRA~2\ARMGNU~1\12DBAB~1.2RE\bin\AR19DD~1.EXE -O0 -g3 -DDEBUG -TC:/src/h7-eval/CM4/STM32H757XIHX_FLASH.ld -Wl,--cref -Wl,--print-memory-usage -Wl,-Map=C:/src/cmake-build-h7m4-debug-gnu-arm-113/h7-eval/CM4/h7-eval-m4.map -mthumb -mcpu=cortex-m4 -mabi=aapcs --specs=nano.specs -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -static -Wl,--start-group -lc -lm -Wl,--end-group h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/Common/Src/system_stm32h7xx_dualcore_boot_cm4_cm7.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/adc.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/crc.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/cryp.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/dcmi.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/dma2d.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/eth.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/fmc.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/gpio.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/hash.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/i2c.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/main.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/resmgr_utility.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/rng.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/spi.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/stm32h7xx_hal_msp.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/stm32h7xx_it.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/syscalls.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/sysmem.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/tim.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Src/usart.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/Core/Startup/startup_stm32h757xihx.s.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/ThreadX/tx_initialize_low_level.S.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/ThreadX/stm32h7xx_hal_timebase_tim.c.obj h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/__/ext/soup/threadx/threadx/utility/execution_profile_kit/tx_execution_profile.c.obj -o h7-eval\CM4\h7-eval-m4.elf ext/soup/hal/libstm32h7_hal.a ext/soup/hal/libstm32h7_hal_resmgr.a ext/soup/threadx/threadx/libthreadx.a ext/soup/hal/libstm32h7_hal.a && cd ." c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj:C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:84: multiple definition of `__lock___sfp_recursive_mutex'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):(.bss.__lock___sfp_recursive_mutex+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj:C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:87: multiple definition of `__lock___atexit_recursive_mutex'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):(.bss.__lock___atexit_recursive_mutex+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj:C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:90: multiple definition of `__lock___at_quick_exit_mutex'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):(.bss.__lock___at_quick_exit_mutex+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj:C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:93: multiple definition of `__lock___malloc_recursive_mutex'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):(.bss.__lock___malloc_recursive_mutex+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj:C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:96: multiple definition of `__lock___env_recursive_mutex'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):(.bss.__lock___env_recursive_mutex+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj:C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:99: multiple definition of `__lock___tz_mutex'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):(.bss.__lock___tz_mutex+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj:C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:102: multiple definition of `__lock___dd_hash_mutex'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):(.bss.__lock___dd_hash_mutex+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj:C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:105: multiple definition of `__lock___arc4random_mutex'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):(.bss.__lock___arc4random_mutex+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_init': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:114: multiple definition of `__retarget_lock_init'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_init+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_init_recursive': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:123: multiple definition of `__retarget_lock_init_recursive'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_init_recursive+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_close': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:146: multiple definition of `__retarget_lock_close'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_close+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_close_recursive': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:155: multiple definition of `__retarget_lock_close_recursive'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_close_recursive+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_acquire': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:164: multiple definition of `__retarget_lock_acquire'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_acquire+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_acquire_recursive': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:174: multiple definition of `__retarget_lock_acquire_recursive'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_acquire_recursive+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_try_acquire': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:185: multiple definition of `__retarget_lock_try_acquire'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_try_acquire+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_try_acquire_recursive': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:196: multiple definition of `__retarget_lock_try_acquire_recursive'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_try_acquire_recursive+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_release': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:206: multiple definition of `__retarget_lock_release'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_release+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: h7-eval/CM4/CMakeFiles/h7-eval-m4.dir/__/ThreadSafe/newlib_lock_glue.c.obj: in function `__retarget_lock_release_recursive': C:/src/h7-eval/ThreadSafe/newlib_lock_glue.c:216: multiple definition of `__retarget_lock_release_recursive'; c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lock.o):lock.c:(.text.__retarget_lock_release_recursive+0x0): first defined here c:/progra~2/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: h7-eval\CM4\h7-eval-m4.elf has a LOAD segment with RWX permissions Memory region Used Size Region Size %age Used FLASH: 53940 B 1 MB 5.14% RAM: 7 KB 288 KB 2.43% collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
This is due to the version of libc_nano included with the 12.2 release including the retargetable locking functions (the stubs?). Is this a mistake? They aren't weak so can't be overridden by the project to provide its own locking implementation.
libc_a-lock.o: 00000000 B __lock___arc4random_mutex 00000000 B __lock___atexit_recursive_mutex 00000000 B __lock___at_quick_exit_mutex 00000000 B __lock___dd_hash_mutex 00000000 B __lock___env_recursive_mutex 00000000 B __lock___malloc_recursive_mutex 00000000 B __lock___sfp_recursive_mutex 00000000 B __lock___tz_mutex 00000001 T __retarget_lock_acquire 00000001 T __retarget_lock_acquire_recursive 00000001 T __retarget_lock_close 00000001 T __retarget_lock_close_recursive 00000001 T __retarget_lock_init 00000001 T __retarget_lock_init_recursive 00000001 T __retarget_lock_release 00000001 T __retarget_lock_release_recursive 00000001 T __retarget_lock_try_acquire 00000001 T __retarget_lock_try_acquire_recursive
These symbols were not exported by the 11.2 build. They conflict with the newlib_lock_glue.c generated by STM32CubeMX for STM32 projects (in this case, an H7 project). I thought these retargetable locking functions were supposed to be implemented by the user, and that a default implementation was not possible for a bare metal application. What is the intention for projects to do to work with GCC 12.2 newlib_nano?