meson: use -f{function,data}-sections for optimized builds
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 24 Apr 2017 23:28:04 +0000 (19:28 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 24 Apr 2017 23:28:04 +0000 (19:28 -0400)
meson.build

index a4c93de..949f636 100644 (file)
@@ -303,6 +303,21 @@ foreach arg : ['-Wl,-z,relro',
         endif
 endforeach
 
+if get_option('buildtype') != 'debug'
+        foreach arg : ['-ffunction-sections',
+                       '-fdata-sections']
+                if cc.has_argument(arg)
+                        add_project_arguments(arg, language : 'c')
+                endif
+        endforeach
+
+        foreach arg : ['-Wl,--gc-sections']
+                if cc.has_argument(arg)
+                        add_project_link_arguments(arg, language : 'c')
+                endif
+        endforeach
+endif
+
 cpp = ' '.join(cc.cmd_array()) + ' -E'
 
 #####################################################################