rust: Add vendor and recovery dylib support.

Adds dylib support for vendor and recovery images.

This changes the default linkage for vendor and recovery images to
dylib, which matches the platform default linkage. This also means that
by default, dylib-std variants are used for rlib dependencies.

Bug: 204303985
Test: Soong tests.
Test: m dist vendor-snapshot
Test: RECOVERY_SNAPSHOT_VERSION=current m dist recovery-snapshot
Change-Id: If84074b8615a70c45e7e162abeb853dc8c34d49a
This commit is contained in:
Ivan Lozano
2023-07-13 11:01:41 -04:00
parent e3c11d0aad
commit add122a828
14 changed files with 378 additions and 147 deletions

View File

@@ -21,7 +21,6 @@ import (
"android/soong/android"
"android/soong/cc"
"android/soong/snapshot"
)
var (
@@ -236,10 +235,7 @@ func (library *libraryDecorator) setSource() {
}
func (library *libraryDecorator) autoDep(ctx android.BottomUpMutatorContext) autoDep {
if ctx.Module().(*Module).InVendor() {
// Vendor modules should statically link libstd.
return rlibAutoDep
} else if library.preferRlib() {
if library.preferRlib() {
return rlibAutoDep
} else if library.rlib() || library.static() {
return rlibAutoDep
@@ -251,10 +247,7 @@ func (library *libraryDecorator) autoDep(ctx android.BottomUpMutatorContext) aut
}
func (library *libraryDecorator) stdLinkage(ctx *depsContext) RustLinkage {
if ctx.RustModule().InVendor() {
// Vendor modules should statically link libstd.
return RlibLinkage
} else if library.static() || library.MutatedProperties.VariantIsStaticStd {
if library.static() || library.MutatedProperties.VariantIsStaticStd {
return RlibLinkage
} else if library.baseCompiler.preferRlib() {
return RlibLinkage
@@ -693,24 +686,6 @@ func LibraryMutator(mctx android.BottomUpMutatorContext) {
v.(*Module).Disable()
}
variation := v.(*Module).ModuleBase.ImageVariation().Variation
if strings.HasPrefix(variation, cc.VendorVariationPrefix) {
// TODO(b/204303985)
// Disable vendor dylibs until they are supported
v.(*Module).Disable()
}
if strings.HasPrefix(variation, cc.VendorVariationPrefix) &&
m.HasVendorVariant() &&
!snapshot.IsVendorProprietaryModule(mctx) &&
strings.TrimPrefix(variation, cc.VendorVariationPrefix) == mctx.DeviceConfig().VndkVersion() {
// cc.MutateImage runs before LibraryMutator, so vendor variations which are meant for rlibs only are
// produced for Dylibs; however, dylibs should not be enabled for boardVndkVersion for
// non-vendor proprietary modules.
v.(*Module).Disable()
}
case "source":
v.(*Module).compiler.(libraryInterface).setSource()
// The source variant does not produce any library.
@@ -747,10 +722,9 @@ func LibstdMutator(mctx android.BottomUpMutatorContext) {
dylib := modules[1].(*Module)
rlib.compiler.(libraryInterface).setRlibStd()
dylib.compiler.(libraryInterface).setDylibStd()
if dylib.ModuleBase.ImageVariation().Variation == android.VendorRamdiskVariation ||
strings.HasPrefix(dylib.ModuleBase.ImageVariation().Variation, cc.VendorVariationPrefix) {
if dylib.ModuleBase.ImageVariation().Variation == android.VendorRamdiskVariation {
// TODO(b/165791368)
// Disable rlibs that link against dylib-std on vendor and vendor ramdisk variations until those dylib
// Disable rlibs that link against dylib-std on vendor ramdisk variations until those dylib
// variants are properly supported.
dylib.Disable()
}