Bug 89249 - mingw, paths with spaces, LTO -> collect2.exe: fatal error: CreateProcess: No such file or directory
Summary: mingw, paths with spaces, LTO -> collect2.exe: fatal error: CreateProcess: No...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 8.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-08 10:01 UTC by Liviu Ionescu
Modified: 2019-05-09 16:10 UTC (History)
0 users

See Also:
Host:
Target: mingw
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Liviu Ionescu 2019-02-08 10:01:47 UTC
I know that supporting Windows was always a big pain, so I can fully understand people not being over joyed when seeing such errors...

I also noticed that reports related to CreateProcess are usually refered to mingw; or that local configurations are blamed, like wrong paths.

However, in my case, the specifics may point to a possible bug in gcc, althougt I do not exclude an interraction with the mingw runtime.

The problem occured in a configuration which used spaces in the install path, and went away when I moved **exactly** the same toolchain to a folder without spaces in the names.

Another detail is that the problem occured only when using -flto, and did not occur when exactly the same project was compiled without -flto.

The linker output with the error:

---
Building target: f4b-lto.elf
Invoking: GNU ARM Cross C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -flto -fno-move-loop-invariants -Wall -Wextra  -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"f4b-lto.map" --specs=nano.specs -v -o "f4b-lto.elf"  ./system/src/stm32f4-hal/stm32f4xx_hal.o ./system/src/stm32f4-hal/stm32f4xx_hal_cortex.o ./system/src/stm32f4-hal/stm32f4xx_hal_dfsdm.o ./system/src/stm32f4-hal/stm32f4xx_hal_flash.o ./system/src/stm32f4-hal/stm32f4xx_hal_gpio.o ./system/src/stm32f4-hal/stm32f4xx_hal_iwdg.o ./system/src/stm32f4-hal/stm32f4xx_hal_pwr.o ./system/src/stm32f4-hal/stm32f4xx_hal_rcc.o  ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o  ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o  ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o  ./system/src/cmsis/system_stm32f4xx.o ./system/src/cmsis/vectors_stm32f407xx.o  ./src/BlinkLed.o ./src/Timer.o ./src/_initialize_hardware.o ./src/_write.o ./src/main.o ./src/stm32f4xx_hal_msp.o   
Using built-in specs.
Reading specs from c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/nano.specs
rename spec link to nano_link
rename spec link_gcc_c_sequence to nano_link_gcc_c_sequence
rename spec cpp_unique_options to nano_cpp_unique_options
COLLECT_GCC=arm-none-eabi-g++
COLLECT_LTO_WRAPPER=c:/users/ilg/desktop/8.2.1\ \ \ \ \ 1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/lto-wrapper.exe
Target: arm-none-eabi
Configured with: /Host/Work/arm-none-eabi-gcc-8.2.1-1.4/gcc/configure --prefix=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc --infodir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/info --mandir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/man --htmldir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/html --pdfdir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/pdf --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=arm-none-eabi --with-pkgversion='GNU MCU Eclipse ARM Embedded GCC\x2C 64-bit' --enable-languages=c,c++ --enable-mingw-wildcard --enable-plugins --enable-lto --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/arm-none-eabi --with-multilib-list=rmprofile --disable-rpath --disable-build-format-warnings --with-system-zlib
Thread model: single
gcc version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (GNU MCU Eclipse ARM Embedded GCC, 64-bit) 
COMPILER_PATH=c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../libexec/gcc/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/
LIBRARY_PATH=c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../arm-none-eabi/lib/
COLLECT_GCC_OPTIONS='-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-ffreestanding' '-flto' '-fno-move-loop-invariants' '-Wall' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v' '-o' 'f4b-lto.elf' '-march=armv7e-m'
 c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/collect2.exe -flto --sysroot=c:\users\ilg\desktop\8.2.1     1.4-20190207-1853\bin\../arm-none-eabi -X -o f4b-lto.elf -L../ldscripts -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../arm-none-eabi/lib/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1 -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../arm-none-eabi/lib --gc-sections -Map f4b-lto.map ./system/src/stm32f4-hal/stm32f4xx_hal.o ./system/src/stm32f4-hal/stm32f4xx_hal_cortex.o ./system/src/stm32f4-hal/stm32f4xx_hal_dfsdm.o ./system/src/stm32f4-hal/stm32f4xx_hal_flash.o ./system/src/stm32f4-hal/stm32f4xx_hal_gpio.o ./system/src/stm32f4-hal/stm32f4xx_hal_iwdg.o ./system/src/stm32f4-hal/stm32f4xx_hal_pwr.o ./system/src/stm32f4-hal/stm32f4xx_hal_rcc.o ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o ./system/src/cmsis/system_stm32f4xx.o ./system/src/cmsis/vectors_stm32f407xx.o ./src/BlinkLed.o ./src/Timer.o ./src/_initialize_hardware.o ./src/_write.o ./src/main.o ./src/stm32f4xx_hal_msp.o -lstdc++_nano -lm --start-group -lgcc -lg_nano -lc_nano --end-group --start-group -lgcc -lc_nano --end-group -T mem.ld -T libs.ld -T sections.ld
collect2.exe: fatal error: CreateProcess: No such file or directory
compilation terminated.
make: *** [makefile:64: f4b-lto.elf] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
---

The offending name is 'c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin'.

After replacing the spaces with a dash, the link step was ok:

---
Building target: f4b-lto.elf
Invoking: GNU ARM Cross C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -flto -fno-move-loop-invariants -Wall -Wextra  -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"f4b-lto.map" --specs=nano.specs -v -o "f4b-lto.elf"  ./system/src/stm32f4-hal/stm32f4xx_hal.o ./system/src/stm32f4-hal/stm32f4xx_hal_cortex.o ./system/src/stm32f4-hal/stm32f4xx_hal_dfsdm.o ./system/src/stm32f4-hal/stm32f4xx_hal_flash.o ./system/src/stm32f4-hal/stm32f4xx_hal_gpio.o ./system/src/stm32f4-hal/stm32f4xx_hal_iwdg.o ./system/src/stm32f4-hal/stm32f4xx_hal_pwr.o ./system/src/stm32f4-hal/stm32f4xx_hal_rcc.o  ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o  ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o  ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o  ./system/src/cmsis/system_stm32f4xx.o ./system/src/cmsis/vectors_stm32f407xx.o  ./src/BlinkLed.o ./src/Timer.o ./src/_initialize_hardware.o ./src/_write.o ./src/main.o ./src/stm32f4xx_hal_msp.o   
Using built-in specs.
Reading specs from c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/nano.specs
rename spec link to nano_link
rename spec link_gcc_c_sequence to nano_link_gcc_c_sequence
rename spec cpp_unique_options to nano_cpp_unique_options
COLLECT_GCC=arm-none-eabi-g++
COLLECT_LTO_WRAPPER=c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/lto-wrapper.exe
Target: arm-none-eabi
Configured with: /Host/Work/arm-none-eabi-gcc-8.2.1-1.4/gcc/configure --prefix=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc --infodir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/info --mandir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/man --htmldir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/html --pdfdir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/pdf --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=arm-none-eabi --with-pkgversion='GNU MCU Eclipse ARM Embedded GCC\x2C 64-bit' --enable-languages=c,c++ --enable-mingw-wildcard --enable-plugins --enable-lto --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/arm-none-eabi --with-multilib-list=rmprofile --disable-rpath --disable-build-format-warnings --with-system-zlib
Thread model: single
gcc version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (GNU MCU Eclipse ARM Embedded GCC, 64-bit) 
COMPILER_PATH=c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/
LIBRARY_PATH=c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../arm-none-eabi/lib/
COLLECT_GCC_OPTIONS='-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-ffreestanding' '-flto' '-fno-move-loop-invariants' '-Wall' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v' '-o' 'f4b-lto.elf' '-march=armv7e-m'
 c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/collect2.exe -flto --sysroot=c:\users\ilg\desktop\8.2.1-1.4-20190207-1853\bin\../arm-none-eabi -X -o f4b-lto.elf -L../ldscripts -Lc:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../arm-none-eabi/lib/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1 -Lc:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc -Lc:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib -Lc:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../arm-none-eabi/lib --gc-sections -Map f4b-lto.map ./system/src/stm32f4-hal/stm32f4xx_hal.o ./system/src/stm32f4-hal/stm32f4xx_hal_cortex.o ./system/src/stm32f4-hal/stm32f4xx_hal_dfsdm.o ./system/src/stm32f4-hal/stm32f4xx_hal_flash.o ./system/src/stm32f4-hal/stm32f4xx_hal_gpio.o ./system/src/stm32f4-hal/stm32f4xx_hal_iwdg.o ./system/src/stm32f4-hal/stm32f4xx_hal_pwr.o ./system/src/stm32f4-hal/stm32f4xx_hal_rcc.o ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o ./system/src/cmsis/system_stm32f4xx.o ./system/src/cmsis/vectors_stm32f407xx.o ./src/BlinkLed.o ./src/Timer.o ./src/_initialize_hardware.o ./src/_write.o ./src/main.o ./src/stm32f4xx_hal_msp.o -lstdc++_nano -lm --start-group -lgcc -lg_nano -lc_nano --end-group --start-group -lgcc -lc_nano --end-group -T mem.ld -T libs.ld -T sections.ld
c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/lto-wrapper.exe ./system/src/stm32f4-hal/stm32f4xx_hal.o ./system/src/stm32f4-hal/stm32f4xx_hal_cortex.o ./system/src/stm32f4-hal/stm32f4xx_hal_dfsdm.o ./system/src/stm32f4-hal/stm32f4xx_hal_flash.o ./system/src/stm32f4-hal/stm32f4xx_hal_gpio.o ./system/src/stm32f4-hal/stm32f4xx_hal_iwdg.o ./system/src/stm32f4-hal/stm32f4xx_hal_pwr.o ./system/src/stm32f4-hal/stm32f4xx_hal_rcc.o ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o ./system/src/cmsis/system_stm32f4xx.o ./system/src/cmsis/vectors_stm32f407xx.o ./src/BlinkLed.o ./src/Timer.o ./src/_initialize_hardware.o ./src/_write.o ./src/main.o ./src/stm32f4xx_hal_msp.o 
arm-none-eabi-g++ @C:\Users\ilg\AppData\Local\Temp\ccEwHABd
Using built-in specs.
Reading specs from c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/nano.specs
rename spec link to nano_link
rename spec link_gcc_c_sequence to nano_link_gcc_c_sequence
rename spec cpp_unique_options to nano_cpp_unique_options
COLLECT_GCC=arm-none-eabi-g++
Target: arm-none-eabi
Configured with: /Host/Work/arm-none-eabi-gcc-8.2.1-1.4/gcc/configure --prefix=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc --infodir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/info --mandir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/man --htmldir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/html --pdfdir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/pdf --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=arm-none-eabi --with-pkgversion='GNU MCU Eclipse ARM Embedded GCC\x2C 64-bit' --enable-languages=c,c++ --enable-mingw-wildcard --enable-plugins --enable-lto --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/arm-none-eabi --with-multilib-list=rmprofile --disable-rpath --disable-build-format-warnings --with-system-zlib
Thread model: single
gcc version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (GNU MCU Eclipse ARM Embedded GCC, 64-bit) 
COLLECT_GCC_OPTIONS='-c' '-fno-openmp' '-fno-openacc' '-mcpu=cortex-m4' '-mfloat-abi=soft'  '-Og' '-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-fno-move-loop-invariants' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v'  '-dumpdir' './' '-dumpbase' 'f4b-lto.elf.wpa' '-fltrans-output-list=C:\Users\ilg\AppData\Local\Temp\cc7QvyUG.ltrans.out' '-fwpa' '-march=armv7e-m'
 c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/lib/gcc/../../libexec/gcc/arm-none-eabi/8.2.1/lto1.exe -quiet -dumpdir ./ -dumpbase f4b-lto.elf.wpa -mcpu=cortex-m4 -mfloat-abi=soft -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -march=armv7e-m -auxbase stm32f4xx_hal -g3 -Og -Og -Wextra -version -fno-openmp -fno-openacc -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-move-loop-invariants -fltrans-output-list=C:\Users\ilg\AppData\Local\Temp\cc7QvyUG.ltrans.out -fwpa @C:\Users\ilg\AppData\Local\Temp\ccNMzFgH
GNU GIMPLE (GNU MCU Eclipse ARM Embedded GCC, 64-bit) version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (arm-none-eabi)
	compiled by GNU C version 7.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU GIMPLE (GNU MCU Eclipse ARM Embedded GCC, 64-bit) version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (arm-none-eabi)
	compiled by GNU C version 7.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COMPILER_PATH=c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/lib/gcc/../../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/lib/gcc/../../libexec/gcc/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/
LIBRARY_PATH=c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../arm-none-eabi/lib/
COLLECT_GCC_OPTIONS='-c' '-fno-openmp' '-fno-openacc' '-mcpu=cortex-m4' '-mfloat-abi=soft'  '-Og' '-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-fno-move-loop-invariants' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v'  '-dumpdir' './' '-dumpbase' 'f4b-lto.elf.wpa' '-fltrans-output-list=C:\Users\ilg\AppData\Local\Temp\cc7QvyUG.ltrans.out' '-fwpa' '-march=armv7e-m'
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -march=armv7e-m -r -nostdlib -o C:\Users\ilg\AppData\Local\Temp\ccXSGpBYdebugobj C:\Users\ilg\AppData\Local\Temp\cckhSqwJdebugobjtem C:\Users\ilg\AppData\Local\Temp\cc5FxM2wdebugobjtem C:\Users\ilg\AppData\Local\Temp\cckuo93mdebugobjtem C:\Users\ilg\AppData\Local\Temp\cch75PPgdebugobjtem C:\Users\ilg\AppData\Local\Temp\cc8C50hddebugobjtem C:\Users\ilg\AppData\Local\Temp\cc5vvwYbdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccezFo7cdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccRJrCCfdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccsn1FFkdebugobjtem C:\Users\ilg\AppData\Local\Temp\cctYKysodebugobjtem C:\Users\ilg\AppData\Local\Temp\cc4jVjSvdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccDSQRqCdebugobjtem C:\Users\ilg\AppData\Local\Temp\cc6t99rMdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccR8QIyWdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccXRnUxYdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccvnwwnZdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccbzifT2debugobjtem C:\Users\ilg\AppData\Local\Temp\cchyjUR7debugobjtem C:\Users\ilg\AppData\Local\Temp\ccnV6hGgdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccJMPhksdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccDx0FuFdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccNESo4Sdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccL1ttg9debugobjtem C:\Users\ilg\AppData\Local\Temp\cczjpscrdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccTJERdIdebugobjtem C:\Users\ilg\AppData\Local\Temp\ccxESMi3debugobjtem C:\Users\ilg\AppData\Local\Temp\cc7CjJFqdebugobjtem
arm-none-eabi-g++ @C:\Users\ilg\AppData\Local\Temp\ccTzgy7o
Using built-in specs.
Reading specs from c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/nano.specs
rename spec link to nano_link
rename spec link_gcc_c_sequence to nano_link_gcc_c_sequence
rename spec cpp_unique_options to nano_cpp_unique_options
COLLECT_GCC=arm-none-eabi-g++
Target: arm-none-eabi
Configured with: /Host/Work/arm-none-eabi-gcc-8.2.1-1.4/gcc/configure --prefix=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc --infodir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/info --mandir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/man --htmldir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/html --pdfdir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/pdf --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=arm-none-eabi --with-pkgversion='GNU MCU Eclipse ARM Embedded GCC\x2C 64-bit' --enable-languages=c,c++ --enable-mingw-wildcard --enable-plugins --enable-lto --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/arm-none-eabi --with-multilib-list=rmprofile --disable-rpath --disable-build-format-warnings --with-system-zlib
Thread model: single
gcc version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (GNU MCU Eclipse ARM Embedded GCC, 64-bit) 
COLLECT_GCC_OPTIONS='-c' '-fno-openmp' '-fno-openacc' '-mcpu=cortex-m4' '-mfloat-abi=soft'  '-Og' '-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-fno-move-loop-invariants' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v'  '-dumpdir' './' '-dumpbase' 'f4b-lto.elf.ltrans0' '-fltrans' '-o' 'C:\Users\ilg\AppData\Local\Temp\cc7QvyUG.ltrans0.ltrans.o' '-march=armv7e-m'
 c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/lib/gcc/../../libexec/gcc/arm-none-eabi/8.2.1/lto1.exe -quiet -dumpdir ./ -dumpbase f4b-lto.elf.ltrans0 -mcpu=cortex-m4 -mfloat-abi=soft -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -march=armv7e-m -auxbase-strip C:\Users\ilg\AppData\Local\Temp\cc7QvyUG.ltrans0.ltrans.o -g3 -Og -Og -Wextra -version -fno-openmp -fno-openacc -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-move-loop-invariants -fltrans @C:\Users\ilg\AppData\Local\Temp\cc6fdxVa -o C:\Users\ilg\AppData\Local\Temp\ccqmesT9.s
GNU GIMPLE (GNU MCU Eclipse ARM Embedded GCC, 64-bit) version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (arm-none-eabi)
	compiled by GNU C version 7.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU GIMPLE (GNU MCU Eclipse ARM Embedded GCC, 64-bit) version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (arm-none-eabi)
	compiled by GNU C version 7.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-c' '-fno-openmp' '-fno-openacc' '-mcpu=cortex-m4' '-mfloat-abi=soft'  '-Og' '-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-fno-move-loop-invariants' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v'  '-dumpdir' './' '-dumpbase' 'f4b-lto.elf.ltrans0' '-fltrans' '-o' 'C:\Users\ilg\AppData\Local\Temp\cc7QvyUG.ltrans0.ltrans.o' '-march=armv7e-m'
 c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/as.exe -v -march=armv7e-m -mfloat-abi=soft -mfloat-abi=soft -meabi=5 -o C:\Users\ilg\AppData\Local\Temp\cc7QvyUG.ltrans0.ltrans.o C:\Users\ilg\AppData\Local\Temp\ccqmesT9.s
GNU assembler version 2.31.51 (arm-none-eabi) using BFD version (GNU MCU Eclipse ARM Embedded GCC, 64-bit) 2.31.51.20181213
COMPILER_PATH=c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/lib/gcc/../../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/lib/gcc/../../libexec/gcc/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../libexec/gcc/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/
LIBRARY_PATH=c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/;c:/users/ilg/desktop/8.2.1-1.4-20190207-1853/bin/../arm-none-eabi/lib/
COLLECT_GCC_OPTIONS='-c' '-fno-openmp' '-fno-openacc' '-mcpu=cortex-m4' '-mfloat-abi=soft'  '-Og' '-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-fno-move-loop-invariants' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v'  '-dumpdir' './' '-dumpbase' 'f4b-lto.elf.ltrans0' '-fltrans' '-o' 'C:\Users\ilg\AppData\Local\Temp\cc7QvyUG.ltrans0.ltrans.o' '-march=armv7e-m'
COLLECT_GCC_OPTIONS='-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-ffreestanding' '-flto' '-fno-move-loop-invariants' '-Wall' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v' '-o' 'f4b-lto.elf' '-march=armv7e-m'
Finished building target: f4b-lto.elf
---

In the initial folder using spaces, a project not using -flto link passed:

---
Building target: f4b.elf
Invoking: GNU ARM Cross C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra  -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"f4b.map" --specs=nano.specs -v -o "f4b.elf"  ./system/src/stm32f4-hal/stm32f4xx_hal.o ./system/src/stm32f4-hal/stm32f4xx_hal_cortex.o ./system/src/stm32f4-hal/stm32f4xx_hal_dfsdm.o ./system/src/stm32f4-hal/stm32f4xx_hal_flash.o ./system/src/stm32f4-hal/stm32f4xx_hal_gpio.o ./system/src/stm32f4-hal/stm32f4xx_hal_iwdg.o ./system/src/stm32f4-hal/stm32f4xx_hal_pwr.o ./system/src/stm32f4-hal/stm32f4xx_hal_rcc.o  ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o  ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o  ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o  ./system/src/cmsis/system_stm32f4xx.o ./system/src/cmsis/vectors_stm32f407xx.o  ./src/BlinkLed.o ./src/Timer.o ./src/_initialize_hardware.o ./src/_write.o ./src/main.o ./src/stm32f4xx_hal_msp.o   
Using built-in specs.
Reading specs from c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/nano.specs
rename spec link to nano_link
rename spec link_gcc_c_sequence to nano_link_gcc_c_sequence
rename spec cpp_unique_options to nano_cpp_unique_options
COLLECT_GCC=arm-none-eabi-g++
COLLECT_LTO_WRAPPER=c:/users/ilg/desktop/8.2.1\ \ \ \ \ 1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/lto-wrapper.exe
Target: arm-none-eabi
Configured with: /Host/Work/arm-none-eabi-gcc-8.2.1-1.4/gcc/configure --prefix=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc --infodir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/info --mandir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/man --htmldir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/html --pdfdir=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/share/doc/pdf --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=arm-none-eabi --with-pkgversion='GNU MCU Eclipse ARM Embedded GCC\x2C 64-bit' --enable-languages=c,c++ --enable-mingw-wildcard --enable-plugins --enable-lto --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/Host/Work/arm-none-eabi-gcc-8.2.1-1.4/install/win64/arm-none-eabi-gcc/arm-none-eabi --with-multilib-list=rmprofile --disable-rpath --disable-build-format-warnings --with-system-zlib
Thread model: single
gcc version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (GNU MCU Eclipse ARM Embedded GCC, 64-bit) 
COMPILER_PATH=c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../libexec/gcc/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/
LIBRARY_PATH=c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../arm-none-eabi/lib/thumb/v7e-m/nofp/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../arm-none-eabi/lib/
COLLECT_GCC_OPTIONS='-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-ffreestanding' '-fno-move-loop-invariants' '-Wall' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v' '-o' 'f4b.elf' '-march=armv7e-m'
 c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/collect2.exe --sysroot=c:\users\ilg\desktop\8.2.1     1.4-20190207-1853\bin\../arm-none-eabi -X -o f4b.elf -L../ldscripts -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../arm-none-eabi/lib/thumb/v7e-m/nofp -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1 -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/lib -Lc:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../arm-none-eabi/lib --gc-sections -Map f4b.map ./system/src/stm32f4-hal/stm32f4xx_hal.o ./system/src/stm32f4-hal/stm32f4xx_hal_cortex.o ./system/src/stm32f4-hal/stm32f4xx_hal_dfsdm.o ./system/src/stm32f4-hal/stm32f4xx_hal_flash.o ./system/src/stm32f4-hal/stm32f4xx_hal_gpio.o ./system/src/stm32f4-hal/stm32f4xx_hal_iwdg.o ./system/src/stm32f4-hal/stm32f4xx_hal_pwr.o ./system/src/stm32f4-hal/stm32f4xx_hal_rcc.o ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o ./system/src/cmsis/system_stm32f4xx.o ./system/src/cmsis/vectors_stm32f407xx.o ./src/BlinkLed.o ./src/Timer.o ./src/_initialize_hardware.o ./src/_write.o ./src/main.o ./src/stm32f4xx_hal_msp.o -lstdc++_nano -lm --start-group -lgcc -lg_nano -lc_nano --end-group --start-group -lgcc -lc_nano --end-group -T mem.ld -T libs.ld -T sections.ld
COLLECT_GCC_OPTIONS='-mcpu=cortex-m4' '-mthumb' '-mfloat-abi=soft' '-Og' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-ffreestanding' '-fno-move-loop-invariants' '-Wall' '-Wextra' '-g3' '-T' 'mem.ld' '-T' 'libs.ld' '-T' 'sections.ld' '-nostartfiles' '-L../ldscripts' '-specs=nano.specs' '-v' '-o' 'f4b.elf' '-march=armv7e-m'
Finished building target: f4b.elf
---


I might be wrong, but, if I read the message 'collect2.exe: fatal error: CreateProcess...' correctly, it looks like collect2 is not able to start a subprocess, probably lto-wrapper.exe or lto1.exe.

A possible reason for this is that collect2 gets confused by the space in the path. lto*.exe are not in the system path, only '<top>/bin' is, where gcc/g++ are located. From here gcc/g++ probably compute a relative path to '<top>/libexec/gcc/arm-none-eabi/8.2.1', where they find collect2.

collect2 must do the same to locate lto*.exe.

I'm not very familiar with the source code, so I don't know exactly where to search for, but one starting point would be to investigate why gcc/g++ properly identify collect2, and collect2 fails to identify lto*. Normally they shuld all share the code to compute the relative path, but maybe they do not, or do not call it the same.

If someone with more deep knowledge on how things work can suggest a place to add extra debug messages, I can build new binaries to further investigate.
Comment 1 Liviu Ionescu 2019-02-08 10:08:16 UTC
possibly related: 

- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89066
Comment 2 Richard Biener 2019-02-08 12:03:37 UTC
I see COLLECT_LTO_WRAPPER with properly escaped spaces but COMPILER_PATH not.
This is build from gcc.c:build_search_list which is simplistic so 'paths'
and 'prefix' have to be escaped properly already.

The paths are populated from find_a_file.
Comment 3 Liviu Ionescu 2019-02-08 13:01:47 UTC
Hi Richard,

Thank you for taking the time to investigate.

Indeed, COLLECT_LTO_WRAPPER is escaped, while COMPILER_PATH is not:

COLLECT_LTO_WRAPPER=c:/users/ilg/desktop/8.2.1\ \ \ \ \ 1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/lto-wrapper.exe
...
COMPILER_PATH=c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../libexec/gcc/arm-none-eabi/8.2.1/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../libexec/gcc/;c:/users/ilg/desktop/8.2.1     1.4-20190207-1853/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/

However, COMPILER_PATH is also not escaped in the no-LTO case, which works, so I guess it is escaped somewhere else, and this is missing in the LTO code.

The only meaningful place where COMPILER_PATH is used is in gcc.c:driver::maybe_run_linker():

      putenv_from_prefixes (&exec_prefixes, "COMPILER_PATH", false);
      putenv_from_prefixes (&startfile_prefixes, LIBRARY_PATH_ENV, true);

Right now I see convert_white_space() called only twice:

    lto_wrapper_file = find_a_file (&exec_prefixes, "lto-wrapper",
				    X_OK, false);

and 

	      linker_plugin_file_spec = convert_white_space (temp_spec);


From what I undestand, the path in 'exec_prefixes' should have been converted before putenv_from_prefixes() is called.

'exec_prefixes' seems constructed via

	add_prefix (&exec_prefixes, arg, NULL,
		    PREFIX_PRIORITY_B_OPT, 0, 0);

From here... I'm kind of lost, the logic to manage paths is complex and I can't estimate the impacts of changes, but I think that this path change mandatory for Windows should be done in a single place, not everywhere the paths are finally consumed.


So, we got a bit of understanding, but the ploblem seems to require more thinking and a careful solution, which I'm not able to provide.

However, if someone can, I'm ready to try it.
Comment 4 Liviu Ionescu 2019-02-13 13:47:09 UTC
I added a printf() in pex_win32_exec_child() to see why the lto invocation fails, and here is the result:


>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1     1.4-20190213-0923/bin/../libexec/gcc/arm-none-eabi/8.2.1/collect2.exe') <<<<<
>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1     1.4-20190213-0923/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe') <<<<<
>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1     1.4-20190213-0923/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/nm.exe') <<<<<
>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1     1.4-20190213-0923/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/nm.exe') <<<<<
>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1     1.4-20190213-0923/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/nm.exe') <<<<<
>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1     1.4-20190213-0923/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/nm.exe') <<<<<
>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1     1.4-20190213-0923/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/nm.exe') <<<<<
>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1     1.4-20190213-0923/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/nm.exe') <<<<<
>>>>> pex_win32_exec_child (executable='c:/users/ilg/desktop/8.2.1\ \ \ \ \ 1.4-20190213-0923/bin/../libexec/gcc/arm-none-eabi/8.2.1/lto-wrapper.exe') <<<<<
collect2.exe: fatal error: CreateProcess: No such file or directory
compilation terminated.

C:\Users\ilg\tmp\lto>



it looks like the win32 api is not happy with the escaped spaces in the lto-wrapper path.


I conditionally removed the white space conversion in gcc.c (around line 7741) and the problem was fixed:


#if defined (__MINGW32__)
      // Win32 fails to CreateProcess if spaces are escaped.
      lto_wrapper_spec = lto_wrapper_file;
#else
      lto_wrapper_file = convert_white_space (lto_wrapper_file);
#endif


I did the same for the second reference to convert_white_space(), while processing the linker_plugin_file_spec, but I do not have a clear reason why this is needed, since aparently the name of the temporary files used for the specs file is generate by win32 in the 8.3 format, and has no spaces.


I tried to remove the conversion entirely, but then ld fails to load the plugin:


/home/ilg/Desktop/8.2.1        1.4-20190213-1020/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: /home/ilg/Desktop/8.2.1: error loading plugin: /home/ilg/Desktop/8.2.1: cannot open shared object file: No such file or directory
collect2: error: ld returned 1 exit status
ilg@ilg-ud18lts64-gme:~/tmp/lto$ 



I'll apply a patch to build my distribution, but I think a more elaborate solution is needed.


Although not related to this issue, another curious thing was the sequence of 6 calls to nm shown by the trace. Are they expected?
Comment 5 Liviu Ionescu 2019-02-13 14:04:18 UTC
The patch is wrong, it should read:

#if defined (__MINGW32__)
      // Win32 fails to CreateProcess if spaces are escaped.
#else
      lto_wrapper_file = convert_white_space (lto_wrapper_file);
#endif
Comment 6 Liviu Ionescu 2019-05-09 16:10:18 UTC
I upgraded my mingw to 5.0.4 and I can no longer reproduce the problem, so I suggest we close this ticket for now and reopen if necessary.