Merge "Add $ORIGIN to rpath for cc_test modules" into main

This commit is contained in:
Colin Cross 2024-05-13 20:59:01 +00:00 committed by Gerrit Code Review
commit 783fa37807

View file

@ -359,6 +359,12 @@ func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
flags = test.binaryDecorator.linkerFlags(ctx, flags)
flags = test.testDecorator.linkerFlags(ctx, flags)
// Add a default rpath to allow tests to dlopen libraries specified in data_libs.
// Host modules already get an rpath specified in linker.go.
if !ctx.Host() {
flags.Global.LdFlags = append(flags.Global.LdFlags, `-Wl,-rpath,\$$ORIGIN`)
}
return flags
}