Use the same rpaths for tests and binaries and cc and rust

Rust and cc binaries currently use $ORIGIN/lib64:$ORIGIN/../lib64 as the
rpath, and cc tests add $ORIGIN/../../lib64:$ORIGIN/../../../$ORIGIN:$ORIGIN.
This causes problems when a binary is included as test data in
out/host/linux-x86/testcases/<test dir>/<CPU>/<test>, as the
binaries can't find the libraries in out/host/linux-x86/lib64.

Use the same rpath for test and binaries, and for cc and rust.

Bug: 264604160
Test: m USE_HOST_MUSL=true out/host/linux-x86/testcases/acpi_tables_test_src_lib/x86_64/acpi_tables_test_src_lib && out/host/linux-x86/testcases/acpi_tables_test_src_lib/x86_64/acpi_tables_test_src_lib
Test: m USE_HOST_MUSL=true out/host/linux-x86/testcases/gen_sdk_test/x86_64/gen_sdk_test && out/host/linux-x86/testcases/gen_sdk_test/x86_64/toybox
Change-Id: I10fe5dc0de01d1f3c6aea8dbabbf60edab5989c3
This commit is contained in:
Colin Cross
2023-01-11 14:17:39 -08:00
parent 57b1e4064b
commit 225a37a7f0
4 changed files with 48 additions and 70 deletions

View File

@@ -311,23 +311,6 @@ func (test *testDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
return deps
}
func (test *testDecorator) linkerInit(ctx BaseModuleContext, linker *baseLinker) {
// 1. Add ../../lib[64] to rpath so that out/host/linux-x86/nativetest/<test dir>/<test> can
// find out/host/linux-x86/lib[64]/library.so
// 2. Add ../../../lib[64] to rpath so that out/host/linux-x86/testcases/<test dir>/<CPU>/<test> can
// also find out/host/linux-x86/lib[64]/library.so
runpaths := []string{"../../lib", "../../../lib"}
for _, runpath := range runpaths {
if ctx.toolchain().Is64Bit() {
runpath += "64"
}
linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, runpath)
}
// add "" to rpath so that test binaries can find libraries in their own test directory
linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, "")
}
func (test *testDecorator) linkerProps() []interface{} {
return []interface{}{&test.LinkerProperties}
}
@@ -356,11 +339,6 @@ func (test *testBinary) linkerProps() []interface{} {
return props
}
func (test *testBinary) linkerInit(ctx BaseModuleContext) {
test.testDecorator.linkerInit(ctx, test.binaryDecorator.baseLinker)
test.binaryDecorator.linkerInit(ctx)
}
func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = test.testDecorator.linkerDeps(ctx, deps)
deps = test.binaryDecorator.linkerDeps(ctx, deps)
@@ -535,11 +513,6 @@ func (test *testLibrary) linkerProps() []interface{} {
return append(props, test.libraryDecorator.linkerProps()...)
}
func (test *testLibrary) linkerInit(ctx BaseModuleContext) {
test.testDecorator.linkerInit(ctx, test.libraryDecorator.baseLinker)
test.libraryDecorator.linkerInit(ctx)
}
func (test *testLibrary) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = test.testDecorator.linkerDeps(ctx, deps)
deps = test.libraryDecorator.linkerDeps(ctx, deps)
@@ -610,15 +583,6 @@ func (benchmark *benchmarkDecorator) benchmarkBinary() bool {
return true
}
func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
runpath := "../../lib"
if ctx.toolchain().Is64Bit() {
runpath += "64"
}
benchmark.baseLinker.dynamicProperties.RunPaths = append(benchmark.baseLinker.dynamicProperties.RunPaths, runpath)
benchmark.binaryDecorator.linkerInit(ctx)
}
func (benchmark *benchmarkDecorator) linkerProps() []interface{} {
props := benchmark.binaryDecorator.linkerProps()
props = append(props, &benchmark.Properties)