Skip to content

Commit 5f410b7

Browse files
jbachorikclaude
andcommitted
fix(build): remove explicit -lasan/-lubsan from ASAN linker args
When clang++ is the compiler, -fsanitize=address links libclang_rt.asan-x86_64.so while the explicit -lasan links GCC's libasan.so.X from the gcc fallback path. Both end up in the binary's NEEDED entries, causing "incompatible ASan runtimes" at startup. -fsanitize=address/-fsanitize=undefined handle runtime linking correctly for both GCC and clang without the explicit flags. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent dc82752 commit 5f410b7

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

build-logic/conventions/src/main/kotlin/com/datadoghq/native/config/ConfigurationPresets.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,18 @@ object ConfigurationPresets {
187187
config.compilerArgs.set(asanCompilerArgs + commonLinuxCompilerArgs(version))
188188

189189
val libasan = PlatformUtils.locateLibasan(compiler)
190-
val asanLinkerArgs = if (libasan != null) {
191-
listOf(
192-
"-L${File(libasan).parent}",
193-
"-lasan",
194-
"-lubsan",
195-
"-fsanitize=address",
196-
"-fsanitize=undefined",
197-
"-fno-omit-frame-pointer"
198-
)
199-
} else {
200-
emptyList()
201-
}
190+
// Do not add -lasan/-lubsan explicitly: clang links its own
191+
// libclang_rt.asan via -fsanitize=address, and combining that
192+
// with an explicit -lasan (GCC's runtime) puts two incompatible
193+
// ASan runtimes into the binary's NEEDED entries, causing an
194+
// immediate "incompatible ASan runtimes" abort at startup.
195+
// -fsanitize=address/-fsanitize=undefined handle the runtime
196+
// link correctly for both GCC and clang.
197+
val asanLinkerArgs = listOf(
198+
"-fsanitize=address",
199+
"-fsanitize=undefined",
200+
"-fno-omit-frame-pointer"
201+
)
202202

203203
config.linkerArgs.set(commonLinuxLinkerArgs() + asanLinkerArgs)
204204

0 commit comments

Comments
 (0)