]> git.ipfire.org Git - thirdparty/libarchive.git/commit
cmake: enable -fdata/function-sections and --gc-sections
authorEmil Velikov <emil.l.velikov@gmail.com>
Sun, 21 Nov 2021 17:38:28 +0000 (17:38 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sun, 21 Nov 2021 19:17:33 +0000 (19:17 +0000)
commit3beea10fceea4d58958aaafcdbcf1264b667613f
tree50fe0d1e06199e3990f3c5251e1c209671b40ff9
parent1b50bca40b0bb78f7250eef176a8a0a1464e2751
cmake: enable -fdata/function-sections and --gc-sections

The former two split the functions and data into separate sections
within the object file. Which makes it easier for the latter to properly
garbage collect and discard unused sections. For example

   text    data     bss     dec     hex filename
 208268    2056    4424  214748   346dc bsdcat -- before
  93396    1304    4360   99060   182f4 bsdcat -- after
1059167   12112   24176 1095455  10b71f bsdcpio -- before
1002538    7320   23984 1033842   fc672 bsdcpio -- after
1093676   14248    6608 1114532  1101a4 bsdtar -- before
1062231   14176    6416 1082823  1085c7 bsdtar -- after
1097259   15032    6408 1118699  1111eb libarchive.so.18 -- before
1095675   14992    6216 1116883  110ad3 libarchive.so.18 -- after

Note:
This is enabled only with gcc/clang on non-Mac platforms. Ideally we'll
have a compile-time check, albeit that seems impossible with our ancient
cmake requirement.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
CMakeLists.txt