On linux, clang
, following gcc
, has a -ffunction-sections
option that causes each function to be put in its own separate section (then one can use appropriate linking options to cause unused sections, thus unused functions, to be removed).
Yet, it seems that clang
silently ignores this option on MacOS: the assembly code is identical with or without it.
Is this normal? Any comment?
Remark number one, this behaviour does not happen with Apple clang when targeting linux (and thus generating an ELF object instead of a Mach-O object).
It looks like the TEXT segment is only meant to include a finite set of sections according to https://github.com/aidansteele/osx-abi-macho-file-format-reference
Consequently, while the driver should probably emit some sort of diagnostic, it is probably a consequence of the output binary format not supporting the option.