Skip to content

Commit 50547f5

Browse files
committed
Roman's comment
1 parent 799203b commit 50547f5

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

build-logic/conventions/src/main/kotlin/com/datadoghq/profiler/ProfilerTestPlugin.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -399,20 +399,16 @@ class ProfilerTestPlugin : Plugin<Project> {
399399
}
400400

401401
// Environment variables
402-
testConfig.environmentVariables.forEach { (key, value) ->
403-
execTask.environment(key, value)
404-
}
405-
406-
// CRITICAL FIX: Remove LD_LIBRARY_PATH to let RPATH work correctly
402+
// CRITICAL FIX: Filter out LD_LIBRARY_PATH to let RPATH work correctly
407403
// The test JDK's launcher has RPATH set to find its own libraries ($ORIGIN/../lib/jli)
408404
// But LD_LIBRARY_PATH overrides RPATH and causes it to load the wrong libjli.so
409-
// Solution: Unset LD_LIBRARY_PATH entirely to let RPATH take precedence
410-
execTask.doFirst {
411-
val currentLdLibPath = (execTask.environment["LD_LIBRARY_PATH"] as? String) ?: System.getenv("LD_LIBRARY_PATH")
412-
if (!currentLdLibPath.isNullOrEmpty()) {
413-
project.logger.info("Removing LD_LIBRARY_PATH to prevent cross-JDK library conflicts (was: $currentLdLibPath)")
414-
execTask.environment.remove("LD_LIBRARY_PATH")
405+
// Solution: Never propagate LD_LIBRARY_PATH so RPATH takes precedence
406+
testConfig.environmentVariables.forEach { (key, value) ->
407+
if (key == "LD_LIBRARY_PATH") {
408+
project.logger.info("Removing LD_LIBRARY_PATH to prevent cross-JDK library conflicts (was: $value)")
409+
return@forEach
415410
}
411+
execTask.environment(key, value)
416412
}
417413

418414
// Sanitizer conditions

0 commit comments

Comments
 (0)