I can think of two things that might be driving up code size.
1. Keil MDK vs GCC
Online compiler uses Keil MDK, which is very good at generating small code. What did you use when compiling offline? I am going to guess GCC compiler since it is free? GCC reliably produces much larger code size than Keil's compiler.
2. Newlib vs Newlib Nano
This may or may not be affecting you, but it does cause mbed OS 5 to generate larger code. If you are using GCC and mbed OS 5 with multithreads you must use GCC Newlib, not Newlib Nano (in MDK nano is called microlib). Offline, this linker option sets newlib nano. If doing multithread, this must not be included. Unfortunately, compiling without nano increases the baseline code size.
Here is a simple program I compiled in GCC with and without newlib nano.
- compile with nano: 32k
- compile without nano: 58k
-Graham
Has the code size changed from mbed 2 online, to mbed 5 offline ?
it seems to be 50k larger ?