Skip to content

Commit 1a45019

Browse files
jbachorikclaude
andcommitted
Fix asan/tsan build detection and skip sanitizers on musl
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8485ec7 commit 1a45019

2 files changed

Lines changed: 53 additions & 23 deletions

File tree

.github/workflows/test_workflow.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ jobs:
1515
cache-jdks:
1616
# This job is used to cache the JDKs for the test jobs
1717
uses: ./.github/workflows/cache_java.yml
18+
filter-musl-configs:
19+
# Sanitizers (asan/tsan) are not supported on musl - filter them out
20+
runs-on: ubuntu-latest
21+
outputs:
22+
configs: ${{ steps.filter.outputs.configs }}
23+
has_configs: ${{ steps.filter.outputs.has_configs }}
24+
steps:
25+
- id: filter
26+
run: |
27+
configs=$(echo '${{ inputs.configuration }}' | jq -c '[.[] | select(. != "asan" and . != "tsan")]')
28+
if [ "$configs" = "[]" ]; then
29+
echo "has_configs=false" >> $GITHUB_OUTPUT
30+
else
31+
echo "has_configs=true" >> $GITHUB_OUTPUT
32+
fi
33+
echo "configs=$configs" >> $GITHUB_OUTPUT
1834
test-linux-glibc-amd64:
1935
needs: cache-jdks
2036
strategy:
@@ -132,12 +148,13 @@ jobs:
132148
path: test-reports
133149

134150
test-linux-musl-amd64:
135-
needs: cache-jdks
151+
needs: [cache-jdks, filter-musl-configs]
152+
if: needs.filter-musl-configs.outputs.has_configs == 'true'
136153
strategy:
137154
fail-fast: false
138155
matrix:
139156
java_version: [ "8-librca", "11-librca", "17-librca", "21-librca", "25-librca" ]
140-
config: ${{ fromJson(inputs.configuration) }}
157+
config: ${{ fromJson(needs.filter-musl-configs.outputs.configs) }}
141158
runs-on: ubuntu-latest
142159
container:
143160
image: "alpine:3.21"
@@ -368,12 +385,13 @@ jobs:
368385
path: test-reports
369386

370387
test-linux-musl-aarch64:
371-
needs: cache-jdks
388+
needs: [cache-jdks, filter-musl-configs]
389+
if: needs.filter-musl-configs.outputs.has_configs == 'true'
372390
strategy:
373391
fail-fast: false
374392
matrix:
375393
java_version: [ "8-librca", "11-librca", "17-librca", "21-librca", "25-librca" ]
376-
config: ${{ fromJson(inputs.configuration) }}
394+
config: ${{ fromJson(needs.filter-musl-configs.outputs.configs) }}
377395
runs-on:
378396
group: ARM LINUX SHARED
379397
labels: arm-4core-linux-ubuntu24.04

build-logic/conventions/src/main/kotlin/com/datadoghq/native/util/PlatformUtils.kt

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,31 +86,43 @@ object PlatformUtils {
8686
return null
8787
}
8888

89-
return try {
90-
// Try the specified compiler first, fall back to gcc
91-
val compilerToUse = if (isCompilerAvailable(compiler)) {
92-
compiler
93-
} else if (compiler != "gcc" && isCompilerAvailable("gcc")) {
94-
"gcc"
95-
} else {
96-
return null
89+
// Try the specified compiler first
90+
if (isCompilerAvailable(compiler)) {
91+
try {
92+
val process = ProcessBuilder(compiler, "-print-file-name=$libName.so")
93+
.redirectErrorStream(true)
94+
.start()
95+
96+
val output = process.inputStream.bufferedReader().readText().trim()
97+
process.waitFor()
98+
99+
if (process.exitValue() == 0 && output != "$libName.so") {
100+
return output
101+
}
102+
} catch (e: Exception) {
103+
// Fall through to try gcc
97104
}
105+
}
98106

99-
val process = ProcessBuilder(compilerToUse, "-print-file-name=$libName.so")
100-
.redirectErrorStream(true)
101-
.start()
107+
// If the specified compiler didn't find it, try gcc as fallback
108+
if (compiler != "gcc" && isCompilerAvailable("gcc")) {
109+
try {
110+
val process = ProcessBuilder("gcc", "-print-file-name=$libName.so")
111+
.redirectErrorStream(true)
112+
.start()
102113

103-
val output = process.inputStream.bufferedReader().readText().trim()
104-
process.waitFor()
114+
val output = process.inputStream.bufferedReader().readText().trim()
115+
process.waitFor()
105116

106-
if (process.exitValue() == 0 && !output.endsWith("$libName.so")) {
107-
output
108-
} else {
109-
null
117+
if (process.exitValue() == 0 && output != "$libName.so") {
118+
return output
119+
}
120+
} catch (e: Exception) {
121+
// Fall through to return null
110122
}
111-
} catch (e: Exception) {
112-
null
113123
}
124+
125+
return null
114126
}
115127

116128
fun locateLibasan(compiler: String = "gcc"): String? = locateLibrary("libasan", compiler)

0 commit comments

Comments
 (0)