Bloat is bad. Here is how to remove unused functions from your binaries:

  • On MacOS: really easy, just use the -dead_strip linker option, that Steve Jobs in his infinite wisdom, has invented for us. The -dead_strip_dylibs will also remove references to unused dynamic libraries.
  • On Linux: a bit more tricky. You have to compile the sources with the -ffunction-sections -fdata-sections , and then link with the --gc-sections flag.
  • On Windows, with msvc: you have to compile the sources with /Gy option ("enable function-level linking"), and then link with /OPT:ref /RELEASE