How to pass flags to final firmware.elf linkage?

Hello,

I am trying to use platformio to compile for the STM32F4 (specifically disco_f407vg) platform with hardware floating point. However, when I input the flags required for this through the build_flags variable in platformio.ini, those flags only show up in the compilation of the main.o, but not in the linkage of the firmware.elf file. This means that in this linking step it is trying to link software floating point with hardware floating point which logically causes an error. How do I pass these flags to the final linkage?

I set up a little test case repo here.

My results in this case:

[03/22/16 21:17:39] Processing disco_f407vg (platform: ststm32, board: disco_f407vg, framework: mbed, build_flags: -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16)
------------------------------------------------------------------------------------------------------ 
arm-none-eabi-gcc -o .pioenvs\disco_f407vg\src\main.o -c -std=gnu99 -fdata-sections -ffunction-sections -Wno-unused-parameter -fno-exceptions -Wextra -fno-delete-null-pointer-checks -fmessage-length=0 -mthumb -Wno-missing-field-initializers -c -fno-builtin -O2 -mfpu=fpv4-sp-d16 -fomit-frame-pointer -Wall -mfloat-abi=softfp -MMD -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DTARGET_RTOS_M4_M7 -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M4 -D__FPU_PRESENT=1 -DTARGET_CORTEX_M -DTARGET_DISCO_F407VG -DMBED_BUILD_TIMESTAMP=1457958256.74 -DTARGET_LIKE_CORTEX_M4 -DTARGET_M4 -D__MBED__=1 -DTARGET_STM -DTARGET_STM32F407 -DTARGET_STM32F4 -DTARGET_STM32F407VG -DARM_MATH_CM4 -DTARGET_LIKE_MBED -DSTM32F4 -DSTM32F407xx -DSTM32F40_41xxx -DPLATFORMIO=020805 -I.pioenvs\disco_f407vg\FrameworkMbedInc248832578 -I.pioenvs\disco_f407vg\FrameworkMbedInc-213564679 -I.pioenvs\disco_f407vg\FrameworkMbedInc-250686161 -I.pioenvs\disco_f407vg\FrameworkMbedInc1673490475 -I.pioenvs\disco_f407vg\FrameworkMbedInc-1521620303 -I.pioenvs\disco_f407vg\FrameworkMbedInc386691280 -I.pioenvs\disco_f407vg\FrameworkMbedInc1539812656 -I.pioenvs\disco_f407vg\FrameworkMbedInc-559263067 -I.pioenvs\disco_f407vg\FrameworkMbedInc1495453984 src\main.c
arm-none-eabi-ar rcs .pioenvs\disco_f407vg\libFrameworkMbed.a @"c:\users\arjen\appdata\local\temp\pioarargs-d98132170f26d86ca4e427d377b7989d"
arm-none-eabi-ranlib .pioenvs\disco_f407vg\libFrameworkMbed.a
arm-none-eabi-gcc -o .pioenvs\disco_f407vg\firmware.elf -Wl,--gc-sections -Wl,--wrap,main -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp --specs=nano.specs -u_printf_float -u_scanf_float -Wl,-T"C:\Users\arjen\.platformio\packages\framework-mbed\variant\DISCO_F407VG\mbed\TARGET_DISCO_F407VG\TOOLCHAIN_GCC_ARM\STM32F407XG.ld" .pioenvs\disco_f407vg\src\main.o -LC:\Users\arjen\.platformio\packages\ldscripts -LC:\Users\arjen\.platformio\packages\framework-mbed\variant\DISCO_F407VG\mbed\TARGET_DISCO_F407VG\TOOLCHAIN_GCC_ARM -L.pioenvs\disco_f407vg -Wl,--start-group -lsupc++ -lmbed -lc -lgcc -Wl,-whole-archive .pioenvs\disco_f407vg\libFrameworkMbed.a -Wl,-no-whole-archive -lc -lgcc -lm -lstdc++ -lnosys -Wl,--end-group
c:/users/arjen/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: error: .pioenvs\disco_f407vg\src\main.o uses VFP register arguments, .pioenvs\disco_f407vg\firmware.elf does not
c:/users/arjen/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pioenvs\disco_f407vg\src\main.o
collect2.exe: error: ld returned 1 exit status
scons: *** [.pioenvs\disco_f407vg\firmware.elf] Error 1
==================================== [ ERROR ] Took 1.14 seconds ====================================

Thanks for your time!

This is a bug. Please open an issue here Issues · platformio/platformio-core · GitHub

I see. Thanks for the quick response. Issue here.