[libdazzle] build: setup various link args and disable asserts



commit 24223b4f8831e571dce26bfa62775212647cca87
Author: Christian Hergert <chergert redhat com>
Date:   Mon Oct 8 18:09:10 2018 -0700

    build: setup various link args and disable asserts
    
    We do this in other projects alrady, somehow missed it here.

 meson.build     | 22 ++++++++++++++++++++++
 src/meson.build |  2 +-
 2 files changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 70b699e..899f1fb 100644
--- a/meson.build
+++ b/meson.build
@@ -128,6 +128,28 @@ endif
 
 add_project_arguments(global_c_args, language: 'c')
 
+release_args = []
+global_link_args = []
+test_link_args = [
+  '-Wl,-z,relro',
+  '-Wl,-z,now',
+]
+if not get_option('buildtype').startswith('debug')
+  # TODO: Maybe reuse 'b_ndebug' option
+  add_global_arguments(['-DG_DISABLE_CAST_CHECKS'], language: 'c')
+  release_args += [ '-DG_DISABLE_ASSERT' ]
+  test_link_args += [
+    '-Wl,-Bsymbolic',
+    '-fno-plt',
+  ]
+endif
+foreach link_arg: test_link_args
+  if cc.links('int main () { return 0; }', name: link_arg, args: link_arg)
+    global_link_args += link_arg
+  endif
+endforeach
+add_project_link_arguments(global_link_args, language: 'c')
+
 # Setup various paths that subdirectory meson.build files need
 package_subdir = get_option('package_subdir') # When used as subproject
 libdir = join_paths(get_option('libdir'), package_subdir)
diff --git a/src/meson.build b/src/meson.build
index 0dbc9b2..6ff8a6a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -102,7 +102,7 @@ libdazzle = shared_library(
   libdazzle_sources,
 
             soversion: 0,
-               c_args: libdazzle_args,
+               c_args: libdazzle_args + release_args,
          dependencies: libdazzle_deps,
   include_directories: [ root_inc, src_inc ],
               install: true,


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