[gnome-builder] build: add option to link against tcmalloc_minimal



commit 4e2a12908a3a78bb721dc7f26b1f3f236407e641
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 12 21:19:47 2018 -0700

    build: add option to link against tcmalloc_minimal
    
    This allows us to test using something other than glibc malloc
    which provides more debugging tooling.

 meson.build       | 18 ++++++++++++------
 meson_options.txt |  1 +
 2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/meson.build b/meson.build
index 7a1b523a2..2bb7a5441 100644
--- a/meson.build
+++ b/meson.build
@@ -2,8 +2,7 @@ project('gnome-builder', 'c',
           license: 'GPL3+',
           version: '3.29.0',
     meson_version: '>= 0.44.0',
-  default_options: [
-                     'c_std=gnu11',
+  default_options: [ 'c_std=gnu11',
                      'cpp_std=c++11',
                      'warning_level=2',
                      'with_channel=other',
@@ -71,6 +70,7 @@ status += [
   'Profiling ............. : @0@'.format(get_option('enable_profiling')),
   'RDTSCP ................ : @0@'.format(get_option('enable_rdtscp')),
   'fusermount ............ : @0@'.format(get_option('fusermount_wrapper')),
+  'tcmalloc_minimal ...... : @0@'.format(get_option('with_tcmalloc')),
   '',
   'Help Docs ............. : @0@'.format(get_option('with_help')),
   'API Docs .............. : @0@'.format(get_option('with_docs')),
@@ -195,10 +195,16 @@ foreach link_arg: test_link_args
     global_link_args += link_arg
   endif
 endforeach
-add_project_link_arguments(
-  global_link_args,
-  language: 'c'
-)
+add_project_link_arguments(global_link_args, language: 'c')
+
+if get_option('with_tcmalloc')
+  tcmalloc_ldflags = [
+    '-Wl,--push-state,--no-as-needed',
+    '-ltcmalloc_minimal',
+    '-Wl,--pop-state'
+  ]
+  add_project_link_arguments(tcmalloc_ldflags, language: 'c')
+endif
 
 # Check if we can use version scripts for ABI exports
 ld_supports_version_script = cc.links('''
diff --git a/meson_options.txt b/meson_options.txt
index 84b4094b5..dc6a9413a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,7 @@ option('enable_tracing', type: 'boolean', value: false, description: 'Enable tra
 option('enable_profiling', type: 'boolean', value: false, description: 'Enable profiling of the Builder 
codebase')
 option('enable_rdtscp', type: 'boolean', value: false, description: 'High performance counters')
 option('fusermount_wrapper', type: 'boolean', value: false, description: 'Install fusermount-wrapper when 
distributing with flatpak')
+option('with_tcmalloc', type: 'boolean', value: false, description: 'Use tcmalloc for dynamic allocations')
 
 option('with_safe_path', type: 'string', value: '', description: 'PATH variable to run build commands 
(default: platform-specific)')
 option('with_channel',


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