I have developed an embedded program for STM32L151 and I compiled it with GCC release 7.2.0
I noted that the program if I compiled with optimize flag for size, or with optimize flag for visualgdb debug, the produced code differ for only 2KB (78K in visualGBD and 76K when compiled for size)
Most likely you are not using newlib-nano, so most of your program size comes from the standard library. Please try switching to the nano version.
Please also check the Embedded Memory Explorer to see where does the size come from. E.g. your program might contain some binary resources or other artifacts that cannot be optimized.