Feature request: add way to compile a target with the equivalent of -ffunction-sections and -fdata-sections
On Linux, you can pass -ffunction-sections and -fdata-sections to most C compilers, and -Wl,-gc-sections to most linkers, which as I understand it puts each function and global variable in its own section, and -Wl,-gc-sections tells the linker to remove the ones that aren't needed. On Windows MinGW supports this, and the MSVC / Clang-CL equivalent is /Gw /Gy. The linker equivilent isn't required, but removing dead code still can be turned off and on with /opt:ref and /opt:noref, but I'm not sure which does which. It would be nice to have a target property or feature or something to enable this based on the current C compiler. My use case is compile Cython-made Python extension modules under Windows, where I've observed Cython modules getting at least 10% smaller after being compiled with /Gw /Gy. I couldn't find a way to do this that works on all platforms, though.