dtrace: fix on macOS (except in the package)

The package needs https://github.com/NixOS/nixpkgs/pull/392918

CC: https://git.lix.systems/lix-project/lix/issues/757
Change-Id: Id040a83d845f98fa1093b782cce2a015b5c85d9f
This commit is contained in:
Jade Lovelace
2025-03-26 10:40:50 -07:00
parent 4181796ed2
commit c1961eb900
4 changed files with 39 additions and 10 deletions
+6 -2
View File
@@ -9,11 +9,15 @@
#include "lix/libutil/strings.hh"
#include "lix/libutil/thread-name.hh"
#include "lix/libutil/tracepoint.hh"
#include <cstddef>
#include <cstddef>
#include <cstdio>
#include <kj/encoding.h>
#if ENABLE_DTRACE
#include "trace-probes.gen.hh"
#endif
#if ENABLE_S3
#include <aws/core/client/ClientConfiguration.h>
#endif
@@ -948,7 +952,7 @@ struct curlFileTransfer : public FileTransfer
size_t read(char * data, size_t len) override
{
TRACE(DTRACE_PROBE2(lix_store, filetransfer__read, uri.c_str(), len));
TRACE(LIX_STORE_FILETRANSFER_READ(uri.c_str(), len));
size_t total = 0;
while (total < len && awaitData()) {
+6 -2
View File
@@ -1,9 +1,13 @@
// I don't know how the rest of these stability attrs work and tbh I don't care
// either; these probes are not stable API and we don't need to be more
// specific about exactly how.
#pragma D attributes Unstable/Unstable/Common provider lix_store provider
provider lix_store {
/** See filetransfer.cc; this is the consumption side, not the curl/production side. */
probe filetransfer__read(string url, size_t length);
probe filetransfer__read(const char * url, size_t length);
};
#pragma D attributes Unstable/Unstable/Common provider lix_store provider
#pragma D attributes Unstable/Unstable/Common provider lix_store module
#pragma D attributes Unstable/Unstable/Common provider lix_store function
#pragma D attributes Unstable/Unstable/Common provider lix_store name
#pragma D attributes Unstable/Unstable/Common provider lix_store args
+5 -2
View File
@@ -15,10 +15,13 @@
#include "lix/config.h"
// NOTE: glib disables this for the clang static analyzer, idk if we need to also
#if HAVE_DTRACE
// The clang static analyzer is busted on these and throws reserved-identifier
// lints at the crimes they put in the headers. Oh well.
#if HAVE_DTRACE && !defined(__clang_analyzer__)
#define ENABLE_DTRACE 1
#define TRACE(body) body
#include <sys/sdt.h>
#else
#define ENABLE_DTRACE 0
#define TRACE(body)
#endif
+22 -4
View File
@@ -417,11 +417,29 @@ if dtrace_feature.enabled()
# NOTE: glib seems to have had to hack some stuff up that we are not hacking
# up. I don't know why.
# https://github.com/GNOME/glib/blob/03f7c1fbf3a3784cb4c3604f83ca3645e9225577/meson.build#L2420-L2434
dtrace_object_gen = generator(dtrace_exe,
output : '@BASENAME@.o',
arguments : ['-G', '-s', '@INPUT@', '-o', '@OUTPUT@'])
# Darwin doesn't require an object generator for dtrace, but it's preferable
# to still have the build structured the same, so we generate empty object
# files with clang.
if is_darwin
dtrace_object_gen = generator(bash,
output : '@BASENAME@.o',
arguments : [
'-c',
'exec "$@"',
'--',
cxx.cmd_array(),
'-xc++',
'-c', '/dev/null',
'-o', '@OUTPUT@'
])
else
dtrace_object_gen = generator(dtrace_exe,
output : '@BASENAME@.o',
arguments : ['-G', '-s', '@INPUT@', '-o', '@OUTPUT@'])
endif
dtrace_header_gen = generator(dtrace_exe,
output : '@BASENAME@.gen.h',
output : '@BASENAME@.gen.hh',
arguments : ['-h', '-s', '@INPUT@', '-o', '@OUTPUT@'])
endif
configdata += {