Building STM32F4 with Hard Floating Point

I have a project that uses STM32F4 Discovery and STM32Cube which I have been building using Eclipse. The project uses hard floating point. I was able to get it to build under Platformio without floating point. I added the -mfloat-abi=hard -mfpu=fpv4-sp-d16 to my build_flags to enable hard floating point. When I did this I got an error in linking. I looked at the eclipse link and found that these flags need to be passed to the arm-none-eabi-g++ command the performs the link. I tried doing this using the -Wl option, but the -Wl option is retained and arm-none-eabi-g++ needs the option with the -Wl.

To get it to work I finally edited stm32cube.py to add the flags to both the compiler (for convenience) and linker:

CCFLAGS=[
    "-Os",  # optimize for size
    "-ffunction-sections",  # place each function in its own section
    "-fdata-sections",
    "-Wall",
    "-mthumb",
    "-mfloat-abi=hard",
    "-mfpu=fpv4-sp-d16",
    "-mcpu=%s" % env.BoardConfig().get("build.cpu"),
    "-nostdlib"
]

LINKFLAGS=[
    "-Os",
    "-Wl,--gc-sections,--relax",
    "-mthumb",
    "-mfloat-abi=hard",
    "-mfpu=fpv4-sp-d16",
    "-mcpu=%s" % env.BoardConfig().get("build.cpu"),
    "--specs=nano.specs",
    "--specs=nosys.specs"
],

You need extra scripting. See example Redirecting...