Skip to content

Commit edbc46b

Browse files
committed
Fix os_variant_has_internal_diagnostics link issue on Linux
1 parent 71b6cd8 commit edbc46b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Sources/OpenGraphCxx/DebugServer/interpose.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,33 @@
22
// interpose.c
33
// OpenGraphCxx
44

5+
#include <OpenGraph/OGBase.h>
56
#include "stdio.h"
67
#include "stdbool.h"
78
#include "string.h"
89

9-
#define DYLD_INTERPOSE(_replacement,_replacee) \
10-
__attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee \
11-
__attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee };
12-
10+
#if OG_TARGET_OS_DARWIN
1311
extern bool os_variant_has_internal_diagnostics(const char *subsystem);
12+
#endif
1413

1514
bool og_variant_has_internal_diagnostics(const char *subsystem) {
1615
if (strcmp(subsystem, "org.OpenSwiftUIProject.OpenGraph") == 0) {
1716
return true;
1817
} else if (strcmp(subsystem, "com.apple.AttributeGraph") == 0) {
1918
return true;
2019
} else {
20+
#if OG_TARGET_OS_DARWIN
2121
return os_variant_has_internal_diagnostics(subsystem);
22+
#else
23+
return false;
24+
#endif
2225
}
2326
}
2427

28+
#if OG_TARGET_OS_DARWIN
29+
#define DYLD_INTERPOSE(_replacement,_replacee) \
30+
__attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee \
31+
__attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee };
32+
2533
DYLD_INTERPOSE(og_variant_has_internal_diagnostics, os_variant_has_internal_diagnostics)
34+
#endif

0 commit comments

Comments
 (0)