[jsonrpc-glib] build: add -Bsymbolic and disable asserts
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jsonrpc-glib] build: add -Bsymbolic and disable asserts
- Date: Wed, 10 Oct 2018 18:53:45 +0000 (UTC)
commit fd9ef12aec03b9b7cb6f58027c8d9e3f9c5d4a1c
Author: Christian Hergert <chergert redhat com>
Date: Wed Oct 10 11:53:06 2018 -0700
build: add -Bsymbolic and disable asserts
This improves the performance of release builds a bit and ensures that we
avoid calling functions through the linker table as well as disabling
asserts outside of developer builds.
meson.build | 22 ++++++++++++++++++++++
src/meson.build | 2 +-
2 files changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 1004eca..6be893a 100644
--- a/meson.build
+++ b/meson.build
@@ -125,6 +125,28 @@ if get_option('default_library') != 'static'
endif
endif
+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')
+
configure_file(
output: 'config.h',
configuration: config_h,
diff --git a/src/meson.build b/src/meson.build
index 4570260..12f8e32 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -52,7 +52,7 @@ libjsonrpc_glib = library(
'jsonrpc-glib-' + apiversion,
libjsonrpc_glib_sources,
- c_args: hidden_visibility_args,
+ c_args: hidden_visibility_args + release_args,
dependencies: libjsonrpc_glib_deps,
soversion: soversion,
version: libversion,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]