Skip to content

Commit 35576dc

Browse files
committed
v1
1 parent f523bb2 commit 35576dc

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

ddprof-lib/build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'java'
44
id 'maven-publish'
55
id 'signing'
6+
id 'assembler'
67

78
id 'com.github.ben-manes.versions' version '0.27.0'
89
id 'de.undercouch.download' version '4.1.1'
@@ -606,7 +607,22 @@ tasks.register('javadocJar', Jar) {
606607
}
607608

608609
tasks.register('asmTask', Exec) {
609-
commandLine 'clang', '-D__aarch64__', 'src/main/asm/safefetch.S', '-o', 'build/obj/safefetch.o'
610+
String reportedArch = System.getProperty('os.arch')
611+
String arch
612+
if (reportedArch == 'x86_64') {
613+
arch = '-D__x86_64__'
614+
} else {
615+
arch = '-D__aarch64__'
616+
}
617+
618+
String os
619+
if (osIdentifier() == 'macos') {
620+
os = '-D__APPLE__'
621+
} else {
622+
os = '-D__LINUX__'
623+
}
624+
625+
commandLine 'gcc', arch, os, 'src/main/assembler/safefetch.S', '-c', 'build/obj/safefetch.o'
610626
}
611627

612628
tasks.register('scanBuild', Exec) {
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
#ifdef __APPLE__
2+
# macOS prefixes symbols with _
3+
#define SYMBOL(s) _ ## s
4+
5+
#define DECLARE_FUNC(func) \
6+
.globl SYMBOL(func) %% \
7+
.private_extern SYMBOL(func) %% \
8+
SYMBOL(func)
9+
#else
10+
#define SYMBOL(s) s
111

2-
#define DECLARE_FUNC(func) \
3-
.globl func %% \
4-
.hidden func %% \
5-
.type func, %function %% \
12+
#define DECLARE_FUNC(func) \
13+
.globl func ; \
14+
.hidden func ; \
15+
.type func, %function ; \
616
func
17+
#endif // __APPLE__
718

819
#if defined(__x86_64__)
920
.text

0 commit comments

Comments
 (0)