westfw:
(...snip...)It puzzles me why -g is used together with -Os...
Why? -g controls debugging info generated; it doesn't turn off optimization or add code. Optimized code can sometimes get re-ordered, with local variables eliminated or reused, making debugging a bit more "exciting" than usual, but it's not awful. I like the quote on the page you reference:
Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.
My (I guess wrong) assumption was that debug information has to be stored into the final executable, thus making it bigger. But we are optimizing for size as we are on small devices... What am I missing here ?