logoalt Hacker News

nlyyesterday at 7:47 PM1 replyview on HN

Do you typically just compile with -fno-rtti -fno-exceptions -nostdlib ?

Last time I did embedded work this was basically all that was required.


Replies

nulltraceyesterday at 10:13 PM

Those three flags cover most of it. One gotcha: -fno-exceptions makes `new` return nullptr instead of throwing, so if any library code expects exceptions you get silent corruption. We added -fcheck-new to catch that.

Also -nostdlib means no global constructors run, so static objects with nontrivial ctors need you to call __libc_init_array yourself.