rust: Set the rpath for rust_test modules
Set the rpath for rust_test modules to allow the runtime linker to find
libraries defined in data_libs.
Bug: 171710847
Test: m
Change-Id: I1b67f0256826a3161a4c3193076e2ee4aef8c093
diff --git a/rust/test.go b/rust/test.go
index 9833ffd..25ea463 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -242,6 +242,10 @@
flags.RustFlags = append(flags.RustFlags, "-Z panic_abort_tests")
}
+ // Add a default rpath to allow tests to dlopen libraries specified in data_libs.
+ flags.GlobalLinkFlags = append(flags.GlobalLinkFlags, `-Wl,-rpath,\$$ORIGIN/lib64`)
+ flags.GlobalLinkFlags = append(flags.GlobalLinkFlags, `-Wl,-rpath,\$$ORIGIN/lib`)
+
return flags
}