I could reproduce your error when libraries in lib/ are involved – they are indeed not built with hardfloat.
arm-none-eabi-gcc -o .pio\build\testing_debug\lib7b8\ADCTestLib\ADCTestLib.o -c -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -Og -g2 -ggdb2 -DPLATFORMIO=60112 -DSTM32L432xx -DWAVE_TRIG -DF_CPU=80000000L -D__PLATFORMIO_BUILD_DEBUG__ -Ilib\ADCTestLib -IC:\Users\Max.platformio\packages\framework-cmsis@2.50501.200527\CMSIS\Include -IC:\Users\Max.platformio\packages\framework-cmsis-stm32l4\Include lib\ADCTestLib\ADCTestLib.c
However, the fix seems simple: It has to be a pre: script instead of a post: script to properly affect libary sources too. Then, the projenv environment can be removed too.
I.e., I tested with
[env]
platform = ststm32@17.1.0
board = nucleo_l432kc
framework = cmsis
extra_scripts = pre:link_hardfloat.py
[env:testing_debug]
build_type = debug
build_flags = -D WAVE_TRIG
and script
Import("env")
for e in [env, DefaultEnvironment()]:
e.Append(
CCFLAGS=[
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16"
],
LINKFLAGS=[
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16"
]
)