[sysprof] build: various build fixes for macOS
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] build: various build fixes for macOS
- Date: Wed, 29 May 2019 22:15:11 +0000 (UTC)
commit 63bcfc2b0e21bd6cfce687c8eb06e88b7b0c4025
Author: Christian Hergert <chergert redhat com>
Date: Tue May 7 22:59:56 2019 -0700
build: various build fixes for macOS
This doesn't make profiling useful in any way, but it does get things
to the point where I can actually open a capture file. And it would
be nice if we could progress to the point of loading capture files
(with correct data in-tact) and this helps us move down that path.
To really do that correctly, we should make some of the widgetry
disabled when it isn't useful. We also need to ensure that we add extra
decoding information to capture files during shutdown so that any
platform can read it back. This would also help the situation of
running and reading on separate architectures.
src/libsysprof-capture/meson.build | 1 +
src/libsysprof-ui/meson.build | 1 -
src/libsysprof/elfparser.c | 7 +++++-
src/libsysprof/meson.build | 43 ++++++++++++++++++++++++----------
src/libsysprof/sp-callgraph-profile.c | 4 ++--
src/libsysprof/sp-process-model-item.c | 12 ++++++----
src/libsysprof/sysprof.h | 14 +++++++----
src/shared/meson.build | 6 ++---
src/shared/sp-address-fallback.h | 6 +++++
src/shared/sp-address.c | 6 ++++-
src/shared/sp-clock.c | 2 ++
src/sysprof/meson.build | 4 +++-
src/sysprof/sp-window.c | 2 ++
src/tests/meson.build | 21 ++++++++++++-----
src/tools/meson.build | 22 ++++++++++-------
15 files changed, 103 insertions(+), 48 deletions(-)
---
diff --git a/src/libsysprof-capture/meson.build b/src/libsysprof-capture/meson.build
index 54427de..4aa41b2 100644
--- a/src/libsysprof-capture/meson.build
+++ b/src/libsysprof-capture/meson.build
@@ -12,6 +12,7 @@ libsysprof_capture_sources = [
'sp-capture-cursor.c',
'sp-capture-reader.c',
'sp-capture-writer.c',
+ 'sp-capture-util.c',
]
configure_file(
diff --git a/src/libsysprof-ui/meson.build b/src/libsysprof-ui/meson.build
index 92c5f61..15efb12 100644
--- a/src/libsysprof-ui/meson.build
+++ b/src/libsysprof-ui/meson.build
@@ -56,7 +56,6 @@ libsysprof_ui_deps = [
dependency('gio-2.0', version: glib_req_version),
dependency('gtk+-3.0', version: gtk_req_version),
libsysprof_dep,
- libshared_dep,
]
libsysprof_ui = shared_library('sysprof-ui-@0@'.format(libsysprof_api_version),
diff --git a/src/libsysprof/elfparser.c b/src/libsysprof/elfparser.c
index 881bcc2..59b7815 100644
--- a/src/libsysprof/elfparser.c
+++ b/src/libsysprof/elfparser.c
@@ -15,9 +15,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
#include <stdlib.h>
#include <string.h>
-#include <elf.h>
+#ifdef __APPLE__
+# include <libelf.h>
+#else
+# include <elf.h>
+#endif
#include <sys/mman.h>
#include "demangle.h"
diff --git a/src/libsysprof/meson.build b/src/libsysprof/meson.build
index 597597b..c86aa5e 100644
--- a/src/libsysprof/meson.build
+++ b/src/libsysprof/meson.build
@@ -1,20 +1,17 @@
+libsysprof_c_args = [ '-DSYSPROF_COMPILATION' ]
+
libsysprof_public_sources = [
'sp-callgraph-profile.c',
'sp-capture-gobject.c',
'sp-elf-symbol-resolver.c',
- 'sp-gjs-source.c',
'sp-hostinfo-source.c',
'sp-jitmap-symbol-resolver.c',
'sp-kernel-symbol.c',
'sp-kernel-symbol-resolver.c',
'sp-local-profiler.c',
'sp-map-lookaside.c',
- 'sp-memory-source.c',
- 'sp-perf-counter.c',
- 'sp-perf-source.c',
'sp-process-model.c',
'sp-process-model-item.c',
- 'sp-proc-source.c',
'sp-profile.c',
'sp-profiler.c',
'sp-selection.c',
@@ -28,19 +25,14 @@ libsysprof_public_headers = [
'sp-callgraph-profile-private.h',
'sp-capture-gobject.h',
'sp-elf-symbol-resolver.h',
- 'sp-gjs-source.h',
'sp-hostinfo-source.h',
'sp-jitmap-symbol-resolver.h',
'sp-kernel-symbol.h',
'sp-kernel-symbol-resolver.h',
'sp-local-profiler.h',
'sp-map-lookaside.h',
- 'sp-memory-source.h',
- 'sp-perf-counter.h',
- 'sp-perf-source.h',
'sp-process-model.h',
'sp-process-model-item.h',
- 'sp-proc-source.h',
'sp-profile.h',
'sp-profiler.h',
'sp-selection.h',
@@ -59,13 +51,38 @@ libsysprof_private_sources = [
]
libsysprof_deps = [
- cxx.find_library('stdc++'),
dependency('gio-2.0', version: glib_req_version),
dependency('gio-unix-2.0', version: glib_req_version),
libsysprof_capture_dep,
- libshared_dep,
]
+if host_machine.system() == 'linux'
+ libsysprof_public_sources += [
+ 'sp-gjs-source.c',
+ 'sp-memory-source.c',
+ 'sp-perf-counter.c',
+ 'sp-perf-source.c',
+ 'sp-proc-source.c',
+ ]
+
+ libsysprof_public_headers += [
+ 'sp-gjs-source.h',
+ 'sp-memory-source.h',
+ 'sp-perf-counter.h',
+ 'sp-perf-source.h',
+ 'sp-proc-source.h',
+ ]
+endif
+
+if host_machine.system() == 'darwin'
+ libsysprof_deps += [ dependency('libelf') ]
+ libsysprof_c_args = [ '-DNT_GNU_BUILD_ID=3', '-DELF_NOTE_GNU="GNU"', '-D__LIBELF_INTERNAL__' ]
+endif
+
+if host_machine.system() != 'darwin'
+ libsysprof_deps += [cxx.find_library('stdc++')]
+endif
+
if get_option('with_sysprofd') != 'none'
libsysprof_deps += dependency('polkit-gobject-1')
endif
@@ -73,7 +90,7 @@ endif
libsysprof = shared_library('sysprof-@0@'.format(libsysprof_api_version),
libsysprof_public_sources + libsysprof_private_sources,
dependencies: libsysprof_deps,
- c_args: [ '-DSYSPROF_COMPILATION' ],
+ c_args: libsysprof_c_args,
install: true,
install_dir: get_option('libdir'),
)
diff --git a/src/libsysprof/sp-callgraph-profile.c b/src/libsysprof/sp-callgraph-profile.c
index 5bb90b8..119ebb9 100644
--- a/src/libsysprof/sp-callgraph-profile.c
+++ b/src/libsysprof/sp-callgraph-profile.c
@@ -340,7 +340,7 @@ sp_callgraph_profile_generate_worker (GTask *task,
last_context = SP_ADDRESS_CONTEXT_NONE;
#endif
- node = stack_stash_add_trace (stash, sample->addrs, sample->n_addrs, 1);
+ node = stack_stash_add_trace (stash, (gpointer)sample->addrs, sample->n_addrs, 1);
for (iter = node; iter != NULL; iter = iter->parent)
len++;
@@ -410,7 +410,7 @@ sp_callgraph_profile_generate_worker (GTask *task,
g_array_index (resolved, guint64, len++) = POINTER_TO_U64 ("[Everything]");
- stack_stash_add_trace (resolved_stash, (SpAddress *)(gpointer)resolved->data, len, 1);
+ stack_stash_add_trace (resolved_stash, (gpointer)resolved->data, len, 1);
}
ret = TRUE;
diff --git a/src/libsysprof/sp-process-model-item.c b/src/libsysprof/sp-process-model-item.c
index 7d4b62a..61cbaf5 100644
--- a/src/libsysprof/sp-process-model-item.c
+++ b/src/libsysprof/sp-process-model-item.c
@@ -19,7 +19,9 @@
#include <string.h>
#include "sp-process-model-item.h"
-#include "sp-proc-source.h"
+#ifdef __linux__
+# include "sp-proc-source.h"
+#endif
struct _SpProcessModelItem
{
@@ -134,11 +136,13 @@ sp_process_model_item_init (SpProcessModelItem *self)
SpProcessModelItem *
sp_process_model_item_new (GPid pid)
{
+ g_autofree gchar *cmdline = NULL;
SpProcessModelItem *ret;
- gchar *cmdline;
- gboolean is_kernel;
+ gboolean is_kernel = FALSE;
+#ifdef __linux__
cmdline = sp_proc_source_get_command_line (pid, &is_kernel);
+#endif
ret = g_object_new (SP_TYPE_PROCESS_MODEL_ITEM,
"command-line", cmdline,
@@ -146,8 +150,6 @@ sp_process_model_item_new (GPid pid)
NULL);
ret->is_kernel = is_kernel;
- g_free (cmdline);
-
return ret;
}
diff --git a/src/libsysprof/sysprof.h b/src/libsysprof/sysprof.h
index fa50c34..3c4030d 100644
--- a/src/libsysprof/sysprof.h
+++ b/src/libsysprof/sysprof.h
@@ -29,12 +29,7 @@ G_BEGIN_DECLS
# include "sp-local-profiler.h"
# include "sp-profile.h"
# include "sp-profiler.h"
-# include "sp-gjs-source.h"
-# include "sp-hostinfo-source.h"
# include "sp-map-lookaside.h"
-# include "sp-memory-source.h"
-# include "sp-perf-source.h"
-# include "sp-proc-source.h"
# include "sp-source.h"
# include "sp-elf-symbol-resolver.h"
# include "sp-jitmap-symbol-resolver.h"
@@ -44,6 +39,15 @@ G_BEGIN_DECLS
# include "sp-symbol-resolver.h"
# include "sp-map-lookaside.h"
# include "sp-selection.h"
+
+#ifdef __linux__
+# include "sp-gjs-source.h"
+# include "sp-hostinfo-source.h"
+# include "sp-memory-source.h"
+# include "sp-perf-source.h"
+# include "sp-proc-source.h"
+#endif
+
#undef SYSPROF_INSIDE
G_END_DECLS
diff --git a/src/shared/meson.build b/src/shared/meson.build
index 980c7b5..a3afb30 100644
--- a/src/shared/meson.build
+++ b/src/shared/meson.build
@@ -4,6 +4,7 @@ shared_sources = [
'sp-error.c',
'sp-line-reader.c',
'sp-platform.c',
+ 'sp-kallsyms.c',
]
shared_public_headers = [
@@ -11,14 +12,11 @@ shared_public_headers = [
'sp-clock.h',
'sp-error.h',
'sp-platform.h',
+ 'sp-kallsyms.h',
]
install_headers(shared_public_headers, subdir: sysprof_header_subdir)
-if host_machine.system() == 'linux'
- shared_sources += ['sp-kallsyms.c']
-endif
-
libshared_deps = [
dependency('glib-2.0'),
]
diff --git a/src/shared/sp-address-fallback.h b/src/shared/sp-address-fallback.h
new file mode 100644
index 0000000..6dcbf32
--- /dev/null
+++ b/src/shared/sp-address-fallback.h
@@ -0,0 +1,6 @@
+#define PERF_CONTEXT_GUEST_USER (-2560)
+#define PERF_CONTEXT_GUEST_KERNEL (-2176)
+#define PERF_CONTEXT_GUEST (-2048)
+#define PERF_CONTEXT_USER (-512)
+#define PERF_CONTEXT_KERNEL (-128)
+#define PERF_CONTEXT_HV (-32)
diff --git a/src/shared/sp-address.c b/src/shared/sp-address.c
index 4f3415c..bf9ba65 100644
--- a/src/shared/sp-address.c
+++ b/src/shared/sp-address.c
@@ -18,7 +18,11 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#include <linux/perf_event.h>
+#ifdef __linux__
+# include <linux/perf_event.h>
+#else
+# include "sp-address-fallback.h"
+#endif
#include "sp-address.h"
diff --git a/src/shared/sp-clock.c b/src/shared/sp-clock.c
index 4b6a4e7..24e3793 100644
--- a/src/shared/sp-clock.c
+++ b/src/shared/sp-clock.c
@@ -28,8 +28,10 @@ sp_clock_init (void)
static const gint clock_ids[] = {
CLOCK_MONOTONIC,
CLOCK_MONOTONIC_RAW,
+#ifdef __linux__
CLOCK_MONOTONIC_COARSE,
CLOCK_REALTIME_COARSE,
+#endif
CLOCK_REALTIME,
};
diff --git a/src/sysprof/meson.build b/src/sysprof/meson.build
index 72c11a4..f64a233 100644
--- a/src/sysprof/meson.build
+++ b/src/sysprof/meson.build
@@ -14,6 +14,9 @@ sysprof_resources = gnome.compile_resources('sysprof-resources', 'sysprof.gresou
sysprof_deps = [
cc.find_library('m', required: false),
+ libshared_dep,
+ libsysprof_capture_dep,
+ libsysprof_dep,
libsysprof_ui_dep,
]
@@ -22,7 +25,6 @@ sysprof = executable('sysprof', sysprof_resources + sysprof_sources,
gui_app: true,
install_dir: get_option('bindir'),
install: true,
- pie: true,
)
endif
diff --git a/src/sysprof/sp-window.c b/src/sysprof/sp-window.c
index b2655dd..faf6d70 100644
--- a/src/sysprof/sp-window.c
+++ b/src/sysprof/sp-window.c
@@ -400,6 +400,7 @@ static void
sp_window_add_sources (SpWindow *window,
SpProfiler *profiler)
{
+#ifdef __linux__
g_autoptr(SpSource) host_source = NULL;
g_autoptr(SpSource) proc_source = NULL;
g_autoptr(SpSource) perf_source = NULL;
@@ -419,6 +420,7 @@ sp_window_add_sources (SpWindow *window,
memory_source = sp_memory_source_new ();
sp_profiler_add_source (profiler, memory_source);
+#endif
}
static void
diff --git a/src/tests/meson.build b/src/tests/meson.build
index dde1483..1fdd5e1 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -6,18 +6,22 @@ test_env = [
'MALLOC_CHECK_=2',
]
+test_deps = [
+ libsysprof_dep,
+]
+
test_cflags = [
'-DTEST_DATA_DIR="@0@/data/"'.format(meson.current_source_dir()),
]
test_capture = executable('test-capture', 'test-capture.c',
c_args: test_cflags,
- dependencies: libsysprof_capture_dep,
+ dependencies: test_deps,
)
test_capture_cursor = executable('test-capture-cursor', 'test-capture-cursor.c',
c_args: test_cflags,
- dependencies: libsysprof_capture_dep,
+ dependencies: test_deps,
)
test('test-capture', test_capture, env: test_env)
@@ -26,24 +30,29 @@ test('test-capture-cursor', test_capture_cursor, env: test_env)
# Use ./tests/test-kallsyms /proc/kallsyms to test (as user or root)
test_kallsyms = executable('test-kallsyms', 'test-kallsyms.c',
c_args: test_cflags,
- dependencies: libsysprof_dep,
+ dependencies: test_deps,
)
if get_option('enable_gtk')
+ test_ui_deps = [
+ libsysprof_dep,
+ libsysprof_ui_dep,
+ ]
+
test_model_filter = executable('test-model-filter', 'test-model-filter.c',
c_args: test_cflags,
- dependencies: libsysprof_ui_dep,
+ dependencies: test_ui_deps,
)
test_process_model = executable('test-process-model', 'test-process-model.c',
c_args: test_cflags,
- dependencies: libsysprof_ui_dep,
+ dependencies: test_ui_deps,
)
test_zoom = executable('test-zoom', 'test-zoom.c',
c_args: test_cflags,
- dependencies: libsysprof_ui_dep,
+ dependencies: test_ui_deps,
)
test('test-model-filter', test_model_filter, env: test_env)
diff --git a/src/tools/meson.build b/src/tools/meson.build
index 97ad825..d896e6e 100644
--- a/src/tools/meson.build
+++ b/src/tools/meson.build
@@ -1,20 +1,24 @@
+tools_deps = [
+ libshared_dep,
+ libsysprof_capture_dep,
+]
-sysprof_cli = executable('sysprof-cli', 'sysprof-cli.c',
- dependencies: libsysprof_dep,
- install_dir: get_option('bindir'),
- install: true,
-)
+if host_machine.system() == 'linux'
+ sysprof_cli = executable('sysprof-cli', 'sysprof-cli.c',
+ dependencies: tools_deps + [libsysprof_dep],
+ install_dir: get_option('bindir'),
+ install: true,
+ )
+endif
sysprof_cat = executable('sysprof-cat', 'sysprof-cat.c',
- dependencies: libsysprof_capture_dep,
+ dependencies: tools_deps,
install_dir: get_option('bindir'),
install: true,
- pie: true,
)
sysprof_dump = executable('sysprof-dump', 'sysprof-dump.c',
- dependencies: libsysprof_capture_dep,
+ dependencies: tools_deps,
install_dir: get_option('bindir'),
install: true,
- pie: true,
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]