Mbed os 5.14/15 with gcc -flto option

I am looking to decrease firmware size with a project based on mbed os 5.14/15.

What happened was when I restructure the project to use the gcc-arm -flto (link time optimization) flag that brought code size savings to the project, but at the same time I found the AnalogIn.read_u16() function always returning 0 on previously configured AnalogIn pins. The SAADC driver that accesses the hardware directly apparently also failed.

I am not sure whether the -flto optimization works on the mbedos 5.14/15 series like it would work on mbedos 6.x series.