aboutsummaryrefslogtreecommitdiff
path: root/spark-common
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2022-07-13 21:10:28 +0100
committerLuck <git@lucko.me>2022-07-13 21:10:28 +0100
commit06de991f44f3f0f33eed21fb92224a395a2a92ff (patch)
treec41e5a22aef1c74717583791ea0db8724d657329 /spark-common
parent73dd214ae66bab483ee8b4f0ed03881466da92e8 (diff)
downloadspark-06de991f44f3f0f33eed21fb92224a395a2a92ff.tar.gz
spark-06de991f44f3f0f33eed21fb92224a395a2a92ff.tar.bz2
spark-06de991f44f3f0f33eed21fb92224a395a2a92ff.zip
Support linux x64 musl
Diffstat (limited to 'spark-common')
-rw-r--r--spark-common/build.gradle9
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java24
-rwxr-xr-xspark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.sobin328432 -> 333864 bytes
-rwxr-xr-xspark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.sobin0 -> 304568 bytes
-rwxr-xr-xspark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.sobin342239 -> 347712 bytes
-rwxr-xr-xspark-common/src/main/resources/spark/macos/libasyncProfiler.sobin688400 -> 690128 bytes
6 files changed, 25 insertions, 8 deletions
diff --git a/spark-common/build.gradle b/spark-common/build.gradle
index bc493f3..fbd0db2 100644
--- a/spark-common/build.gradle
+++ b/spark-common/build.gradle
@@ -8,7 +8,7 @@ license {
dependencies {
api project(':spark-api')
- implementation 'com.github.jvm-profiling-tools:async-profiler:v2.7'
+ implementation 'com.github.jvm-profiling-tools:async-profiler:v2.8.1'
implementation 'org.ow2.asm:asm:9.1'
implementation 'com.google.protobuf:protobuf-javalite:3.15.6'
implementation 'com.squareup.okhttp3:okhttp:3.14.1'
@@ -37,13 +37,6 @@ dependencies {
compileOnly 'org.checkerframework:checker-qual:3.8.0'
}
-processResources {
- from(sourceSets.main.resources.srcDirs) {
- include 'spark/linux/libasyncProfiler.so'
- include 'spark/macosx/libasyncProfiler.so'
- }
-}
-
protobuf {
protoc {
if (System.getProperty("os.name") == "Mac OS X" && System.getProperty("os.arch") == "aarch64") {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java
index d642a53..ef2c035 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java
@@ -29,13 +29,16 @@ import me.lucko.spark.common.util.TemporaryFiles;
import one.profiler.AsyncProfiler;
import one.profiler.Events;
+import java.io.BufferedReader;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Locale;
import java.util.logging.Level;
+import java.util.stream.Collectors;
/**
* Provides a bridge between spark and async-profiler.
@@ -108,8 +111,13 @@ public enum AsyncProfilerAccess {
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT).replace(" ", "");
String arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT);
+ if (os.equals("linux") && arch.equals("amd64") && isLinuxMusl()) {
+ arch = "amd64-musl";
+ }
+
Table<String, String, String> supported = ImmutableTable.<String, String, String>builder()
.put("linux", "amd64", "linux/amd64")
+ .put("linux", "amd64-musl", "linux/amd64-musl")
.put("linux", "aarch64", "linux/aarch64")
.put("macosx", "amd64", "macos")
.put("macosx", "aarch64", "macos")
@@ -190,4 +198,20 @@ public enum AsyncProfilerAccess {
super("A runtime error occurred whilst loading the native library", cause);
}
}
+
+ // Checks if the system is using musl instead of glibc
+ private static boolean isLinuxMusl() {
+ try {
+ InputStream stream = new ProcessBuilder("sh", "-c", "ldd `which ls`")
+ .start()
+ .getInputStream();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+ String output = reader.lines().collect(Collectors.joining());
+ return output.contains("musl"); // shrug
+ } catch (Throwable e) {
+ // ignore
+ return false;
+ }
+ }
}
diff --git a/spark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.so b/spark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.so
index 35f83b2..c3c2eb2 100755
--- a/spark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.so
+++ b/spark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.so
Binary files differ
diff --git a/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so b/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so
new file mode 100755
index 0000000..4c69ab8
--- /dev/null
+++ b/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so
Binary files differ
diff --git a/spark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.so b/spark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.so
index edbf103..5612ad9 100755
--- a/spark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.so
+++ b/spark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.so
Binary files differ
diff --git a/spark-common/src/main/resources/spark/macos/libasyncProfiler.so b/spark-common/src/main/resources/spark/macos/libasyncProfiler.so
index ab818e9..1fc6ba3 100755
--- a/spark-common/src/main/resources/spark/macos/libasyncProfiler.so
+++ b/spark-common/src/main/resources/spark/macos/libasyncProfiler.so
Binary files differ