[gtksourceview] build: add optimization flags for production builds



commit 049d73e4a89cf6665077d29c06c61b5aa90a5285
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 29 09:13:21 2020 -0800

    build: add optimization flags for production builds
    
    When doing production builds (such as release or plain --buildtype), we
    can disable a number of internal consistency checks as well as use various
    linking options to avoid extra overhead within calls between the library.

 meson.build | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/meson.build b/meson.build
index 43cb8c4f..3baae99c 100644
--- a/meson.build
+++ b/meson.build
@@ -252,6 +252,24 @@ endif
 
 add_project_arguments(global_c_args, language: 'c')
 
+# Various optimizations for non-debug builds including disabling of
+# cast checks, asserts, and additional link options.
+global_link_args = []
+test_link_args = ['-Wl,-z,relro', '-Wl,-z,now']
+if not get_option('buildtype').startswith('debug')
+  add_global_arguments([
+    '-DG_DISABLE_ASSERT',
+    '-DG_DISABLE_CAST_CHECKS',
+  ], language: 'c')
+  test_link_args += ['-Wl,-Bsymbolic', '-fno-plt']
+endif
+foreach link_arg: test_link_args
+  if cc.has_link_argument(link_arg)
+    global_link_args += link_arg
+  endif
+endforeach
+add_project_link_arguments(global_link_args, language: 'c')
+
 configure_file(
          output: 'config.h',
   configuration: config_h


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]