meson: add support for dtrace/systemtap

Still at least one FIXME. And untested so far. It builds.
This commit is contained in:
Tim-Philipp Müller 2017-01-25 17:02:51 +00:00 committed by Matthias Clasen
parent 9fdcb2bf37
commit d29f022b0b
5 changed files with 101 additions and 0 deletions

View File

@ -681,8 +681,17 @@ install_data([
],
install_dir: join_paths(get_option('datadir'), 'bash-completion/completions'))
if enable_dtrace
gio_dtrace_obj = dtrace_obj_gen.process('gio_probes.d')
gio_dtrace_hdr = dtrace_hdr_gen.process('gio_probes.d')
else
gio_dtrace_obj = []
gio_dtrace_hdr = []
endif
libgio = shared_library('gio-2.0',
gioenumtypes_h, gioenumtypes_c, gnetworking_h, gio_sources,
gio_dtrace_hdr, gio_dtrace_obj,
version : library_version,
soversion : soversion,
install : true,
@ -802,6 +811,14 @@ if host_system != 'windows'
dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
endif
if enable_systemtap
gio_stp = configure_file(input : 'gio.stp.in',
output : '@0@.stp'.format(libgio.full_path().split('/').get(-1)),
configuration : stp_cdata,
install_dir : tapset_install_dir,
install : true)
endif
if host_system != 'windows'
subdir('tests')
endif

View File

@ -199,7 +199,16 @@ else
platform_deps = []
endif
if enable_dtrace
glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
else
glib_dtrace_obj = []
glib_dtrace_hdr = []
endif
libglib = shared_library('glib-2.0',
glib_dtrace_obj, glib_dtrace_hdr,
sources : [deprecated_sources, glib_sources, thread_src, plat_src],
version : library_version,
soversion : soversion,
@ -264,6 +273,14 @@ configure_file(
install_dir: join_paths(get_option('datadir'), 'gdb/auto-load' + glib_libdir)
)
if enable_systemtap
glib_stp = configure_file(input : 'glib.stp.in',
output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
configuration : stp_cdata,
install_dir : tapset_install_dir,
install : true)
endif
# gtester doesn't work on native windows
if cc.get_id() != 'msvc'
subdir('tests')

View File

@ -45,7 +45,16 @@ gobject_c_sources = [
'gvaluetypes.c',
]
if enable_dtrace
gobject_dtrace_obj = dtrace_obj_gen.process('gobject_probes.d')
gobject_dtrace_hdr = dtrace_hdr_gen.process('gobject_probes.d')
else
gobject_dtrace_obj = []
gobject_dtrace_hdr = []
endif
libgobject = shared_library('gobject-2.0',
gobject_dtrace_obj, gobject_dtrace_hdr,
sources : [gobject_c_sources],
version : library_version,
soversion : soversion,
@ -94,4 +103,12 @@ configure_file(
install_dir: join_paths(get_option('datadir'), 'gdb/auto-load/' + glib_libdir)
)
if enable_systemtap
gobject_stp = configure_file(input : 'gobject.stp.in',
output : '@0@.stp'.format(libgobject.full_path().split('/').get(-1)),
configuration : stp_cdata,
install_dir : tapset_install_dir,
install : true)
endif
subdir('tests')

View File

@ -1340,6 +1340,50 @@ glib_conf.set('GIO_MODULE_DIR', '${libdir}/gio/modules')
# @G_MODULE_LIBS@ @SELINUX_LIBS@ @COCOA_LIBS@ @CARBON_LIBS@ @G_LIBS_EXTRA@
# @PCRE_REQUIRES@ @GLIB_EXTRA_CFLAGS@ @G_THREAD_CFLAGS@
# Tracing: dtrace
want_dtrace = get_option('enable-dtrace')
enable_dtrace = false
# Since dtrace support is opt-in we just error out if it was requested but
# is not available. We don't bother with autodetection yet.
if want_dtrace
if glib_have_carbon
error('GLib dtrace support not yet compatible with macOS dtrace')
endif
dtrace = find_program('dtrace', required : true) # error out if not found
if not cc.has_header('sys/sdt.h')
error('dtrace support needs sys/sdt.h header')
endif
# FIXME: autotools build also passes -fPIC -DPIC but is it needed in this case?
dtrace_obj_gen = generator(dtrace,
output : '@BASENAME@.o',
arguments : ['-G', '-s', '@INPUT@', '-o', '@OUTPUT@'])
# FIXME: $(SED) -e "s,define STAP_HAS_SEMAPHORES 1,undef STAP_HAS_SEMAPHORES,"
# -e "s,define _SDT_HAS_SEMAPHORES 1,undef _SDT_HAS_SEMAPHORES,"
dtrace_hdr_gen = generator(dtrace,
output : '@BASENAME@.h',
arguments : ['-h', '-s', '@INPUT@', '-o', '@OUTPUT@'])
glib_conf.set('HAVE_DTRACE', 1)
enable_dtrace = true
endif
# systemtap
want_systemtap = get_option('enable-systemtap')
enable_systemtap = false
if want_systemtap and enable_dtrace
tapset_install_dir = get_option('tapset-install-dir')
if tapset_install_dir == ''
tapset_install_dir = join_paths(get_option('datadir'), 'systemtap/tapset')
endif
stp_cdata = configuration_data()
stp_cdata.set('ABS_GLIB_RUNTIME_LIBDIR', glib_libdir)
stp_cdata.set('LT_CURRENT', minor_version.to_int() * 100)
stp_cdata.set('LT_REVISION', micro_version.to_int())
enable_systemtap = true
endif
subdir('glib')
subdir('gobject')
subdir('gthread')

View File

@ -1,3 +1,9 @@
option('with-docs', type : 'boolean', value : false)
option('with-man', type : 'boolean', value : true)
option('enable-libmount', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'yes')
option('enable-dtrace', type : 'boolean', value : false,
description : 'include tracing support for dtrace')
option('enable-systemtap', type : 'boolean', value : false,
description : 'include tracing support for systemtap')
option('tapset-install-dir', type : 'string', value : '',
description : 'path where systemtap tapsets are installed')