The common set: -fno-exceptions removes all exception machinery and unwind tables (and makes any throw a compile error, so you can't accidentally pull it in); -fno-rtti removes runtime type metadata and disables dynamic_cast/typeid; -fno-threadsafe-statics drops the thread-safe guard variables and locks the compiler otherwise emits around first-time initialization of function-local statics, which you don't need on a single-core bare-metal init path; and -Os optimizes for size with -ffunction-sections -fdata-sections plus linker --gc-sections to garbage-collect unused functions and data so nothing unreferenced bloats flash. Together these give you the cheap C++ features (classes, RAII, templates, constexpr) at C-like code size while compiling out the expensive ones. You'd verify the result by checking the map file and the .text/.data/.bss sizes against your part's flash and RAM budget.
C++ for Embedded · Interview question
What compiler flags configure a bare-metal C++ build, and what does each do?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
What to Avoid on MCUs
The three C++ features that cost more than they're worth on a microcontroller (exceptions, RTTI, and dynamic allocation): why they hurt, and the deterministic patterns to use instead.