rust: Mutate prebuilt modules dylib/rlib

This change makes it possible to use a single module to provide both
dylib and rlib varieties of a library. This allows the use of libstd and
libtest from a rustlibs property, allowing linkage type to change
for different variants.

Bug: 159718669
Test: cd external crates; mma; m crosvm.experimental
Change-Id: I477c4d2faec63703fdc6dd42ba020747d6a50714
This commit is contained in:
Matthew Maurer
2020-06-25 00:47:46 -07:00
parent 0f003b1851
commit c761eeca48
5 changed files with 76 additions and 36 deletions

View File

@@ -193,17 +193,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
stdlib = stdlib + "_" + ctx.toolchain().RustTriple()
}
// This check is technically insufficient - on the host, where
// static linking is the default, if one of our static
// dependencies uses a dynamic library, we need to dynamically
// link the stdlib as well.
if (len(deps.Dylibs) > 0) || ctx.Device() {
// Dynamically linked stdlib
deps.Dylibs = append(deps.Dylibs, stdlib)
} else if ctx.Host() && !ctx.TargetPrimary() {
// Otherwise use the static in-tree stdlib for host secondary arch
deps.Rlibs = append(deps.Rlibs, stdlib+".static")
}
deps.Rustlibs = append(deps.Rustlibs, stdlib)
}
}
return deps