[Bug] Can't use LTO (-flto) on macOS, because GNU Tools for STM32 is located in "Application Support" folder which contains a space
Create a new project on macOS using STM32CubeIDE for VSCode.
In the CMakeLists.txt file, add:
add_link_options(-flto=auto -ffat-lto-objects)Build the project.
You should get a linker error like this, because GNU Tools for STM32 is located in the “Application Support” folder which contains a space, so lto-wrapper can’t manage to access its dependencies:
[build] Linking C executable core_mcu_firmware.elf
[build] make[3]: /Users/romain/Library/Application: Permission denied
[build] make[3]: /Users/romain/Library/Application: Permission denied
[build] make[3]: *** [/var/folders/hb/49ldjdz961l9dtpyqq8dqhcr0000gn/T//ccLALceE.ltrans1.ltrans.o] Error 1
[build] make[3]: *** Waiting for unfinished jobs....
[build] make[3]: *** [/var/folders/hb/49ldjdz961l9dtpyqq8dqhcr0000gn/T//ccLALceE.ltrans0.ltrans.o] Error 1
[build] lto-wrapper: fatal error: make returned 2 exit status
[build] compilation terminated.
[build] /Users/romain/Library/Application Support/stm32cube/bundles/gnu-tools-for-stm32/14.3.1+st.2/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: error: lto-wrapper failed
[build] collect2: error: ld returned 1 exit status
