Merge "Fix the make name of rust snapshots" am: 9433998d9a
am: 88cd3710ee
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2490756 Change-Id: I9e578baf2bd04ab83938fe2043c46826fb77a09d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
1
cc/cc.go
1
cc/cc.go
@@ -3466,7 +3466,6 @@ func MakeLibName(ctx android.ModuleContext, c LinkableInterface, ccDep LinkableI
|
|||||||
nonSystemVariantsExist := ccDep.HasNonSystemVariants() || isLLndk
|
nonSystemVariantsExist := ccDep.HasNonSystemVariants() || isLLndk
|
||||||
|
|
||||||
if ccDepModule != nil {
|
if ccDepModule != nil {
|
||||||
// TODO(ivanlozano) Support snapshots for Rust-produced C library variants.
|
|
||||||
// Use base module name for snapshots when exporting to Makefile.
|
// Use base module name for snapshots when exporting to Makefile.
|
||||||
if snapshotPrebuilt, ok := ccDepModule.linker.(SnapshotInterface); ok {
|
if snapshotPrebuilt, ok := ccDepModule.linker.(SnapshotInterface); ok {
|
||||||
baseName := ccDepModule.BaseModuleName()
|
baseName := ccDepModule.BaseModuleName()
|
||||||
|
@@ -522,6 +522,8 @@ func (p *snapshotLibraryDecorator) nativeCoverage() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil)
|
||||||
|
|
||||||
func (p *snapshotLibraryDecorator) isSanitizerAvailable(t SanitizerType) bool {
|
func (p *snapshotLibraryDecorator) isSanitizerAvailable(t SanitizerType) bool {
|
||||||
switch t {
|
switch t {
|
||||||
case cfi:
|
case cfi:
|
||||||
@@ -644,8 +646,6 @@ func RecoverySnapshotHeaderFactory() android.Module {
|
|||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil)
|
|
||||||
|
|
||||||
// Module definitions for snapshots of executable binaries.
|
// Module definitions for snapshots of executable binaries.
|
||||||
//
|
//
|
||||||
// Modules (vendor|recovery)_snapshot_binary are defined here. They have their prebuilt executable
|
// Modules (vendor|recovery)_snapshot_binary are defined here. They have their prebuilt executable
|
||||||
|
@@ -43,6 +43,10 @@ func (mod *Module) SubAndroidMk(data *android.AndroidMkEntries, obj interface{})
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mod *Module) AndroidMkSuffix() string {
|
||||||
|
return mod.Properties.RustSubName + mod.Properties.SubName
|
||||||
|
}
|
||||||
|
|
||||||
func (mod *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
func (mod *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
if mod.Properties.HideFromMake || mod.hideApexVariantFromMake {
|
if mod.Properties.HideFromMake || mod.hideApexVariantFromMake {
|
||||||
|
|
||||||
@@ -79,8 +83,7 @@ func (mod *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
mod.SubAndroidMk(&ret, mod.sanitize)
|
mod.SubAndroidMk(&ret, mod.sanitize)
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.SubName += mod.Properties.RustSubName
|
ret.SubName += mod.AndroidMkSuffix()
|
||||||
ret.SubName += mod.Properties.SubName
|
|
||||||
|
|
||||||
return []android.AndroidMkEntries{ret}
|
return []android.AndroidMkEntries{ret}
|
||||||
}
|
}
|
||||||
@@ -152,6 +155,11 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *snapshotLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) {
|
||||||
|
ctx.SubAndroidMk(ret, library.libraryDecorator)
|
||||||
|
ret.SubName = library.SnapshotAndroidMkSuffix()
|
||||||
|
}
|
||||||
|
|
||||||
func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) {
|
func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) {
|
||||||
ctx.SubAndroidMk(ret, procMacro.baseCompiler)
|
ctx.SubAndroidMk(ret, procMacro.baseCompiler)
|
||||||
|
|
||||||
|
13
rust/rust.go
13
rust/rust.go
@@ -1111,6 +1111,17 @@ func (mod *Module) Prebuilt() *android.Prebuilt {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func rustMakeLibName(ctx android.ModuleContext, c cc.LinkableInterface, dep cc.LinkableInterface, depName string) string {
|
||||||
|
if rustDep, ok := dep.(*Module); ok {
|
||||||
|
// Use base module name for snapshots when exporting to Makefile.
|
||||||
|
if snapshotPrebuilt, ok := rustDep.compiler.(cc.SnapshotInterface); ok {
|
||||||
|
baseName := rustDep.BaseModuleName()
|
||||||
|
return baseName + snapshotPrebuilt.SnapshotAndroidMkSuffix() + rustDep.AndroidMkSuffix()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cc.MakeLibName(ctx, c, dep, depName)
|
||||||
|
}
|
||||||
|
|
||||||
func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
var depPaths PathDeps
|
var depPaths PathDeps
|
||||||
|
|
||||||
@@ -1142,7 +1153,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
|
|
||||||
if rustDep, ok := dep.(*Module); ok && !rustDep.CcLibraryInterface() {
|
if rustDep, ok := dep.(*Module); ok && !rustDep.CcLibraryInterface() {
|
||||||
//Handle Rust Modules
|
//Handle Rust Modules
|
||||||
makeLibName := cc.MakeLibName(ctx, mod, rustDep, depName+rustDep.Properties.RustSubName)
|
makeLibName := rustMakeLibName(ctx, mod, rustDep, depName+rustDep.Properties.RustSubName)
|
||||||
|
|
||||||
switch depTag {
|
switch depTag {
|
||||||
case dylibDepTag:
|
case dylibDepTag:
|
||||||
|
@@ -424,6 +424,14 @@ func TestVendorSnapshotUse(t *testing.T) {
|
|||||||
compile_multilib: "32",
|
compile_multilib: "32",
|
||||||
srcs: ["bin.rs"],
|
srcs: ["bin.rs"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rust_library {
|
||||||
|
name: "librust_vendor_available",
|
||||||
|
crate_name: "rust_vendor",
|
||||||
|
vendor_available: true,
|
||||||
|
srcs: ["client.rs"],
|
||||||
|
}
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
vndkBp := `
|
vndkBp := `
|
||||||
@@ -499,13 +507,6 @@ func TestVendorSnapshotUse(t *testing.T) {
|
|||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
rust_library {
|
|
||||||
name: "librust_vendor_available",
|
|
||||||
crate_name: "rust_vendor",
|
|
||||||
vendor_available: true,
|
|
||||||
srcs: ["client.rs"],
|
|
||||||
}
|
|
||||||
|
|
||||||
rust_ffi_shared {
|
rust_ffi_shared {
|
||||||
name: "libclient",
|
name: "libclient",
|
||||||
crate_name: "client",
|
crate_name: "client",
|
||||||
@@ -963,7 +964,7 @@ func TestVendorSnapshotUse(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
libclientAndroidMkRlibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkRlibs
|
libclientAndroidMkRlibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkRlibs
|
||||||
if g, w := libclientAndroidMkRlibs, []string{"librust_vendor_available.vendor_rlib.30.arm64.rlib-std", "libstd.vendor_rlib.30.arm64"}; !reflect.DeepEqual(g, w) {
|
if g, w := libclientAndroidMkRlibs, []string{"librust_vendor_available.vendor.rlib-std", "libstd.vendor"}; !reflect.DeepEqual(g, w) {
|
||||||
t.Errorf("wanted libclient libclientAndroidMkRlibs %q, got %q", w, g)
|
t.Errorf("wanted libclient libclientAndroidMkRlibs %q, got %q", w, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -978,10 +979,24 @@ func TestVendorSnapshotUse(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
libclientRustAndroidMkRlibs := ctx.ModuleForTests("libclient_rust", rlibVariant).Module().(*Module).Properties.AndroidMkRlibs
|
libclientRustAndroidMkRlibs := ctx.ModuleForTests("libclient_rust", rlibVariant).Module().(*Module).Properties.AndroidMkRlibs
|
||||||
if g, w := libclientRustAndroidMkRlibs, []string{"librust_vendor_available.vendor_rlib.30.arm64.rlib-std", "libstd.vendor_rlib.30.arm64"}; !reflect.DeepEqual(g, w) {
|
if g, w := libclientRustAndroidMkRlibs, []string{"librust_vendor_available.vendor.rlib-std", "libstd.vendor"}; !reflect.DeepEqual(g, w) {
|
||||||
t.Errorf("wanted libclient libclientAndroidMkRlibs %q, got %q", w, g)
|
t.Errorf("wanted libclient libclientAndroidMkRlibs %q, got %q", w, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rust vendor snapshot must have ".vendor" suffix in AndroidMk
|
||||||
|
librustVendorAvailableSnapshotModule := ctx.ModuleForTests("librust_vendor_available.vendor_rlib.30.arm64", rlibVariant).Module()
|
||||||
|
librustVendorSnapshotMkName := android.AndroidMkEntriesForTest(t, ctx, librustVendorAvailableSnapshotModule)[0].EntryMap["LOCAL_MODULE"][0]
|
||||||
|
expectedRustVendorSnapshotName := "librust_vendor_available.vendor.rlib-std"
|
||||||
|
if librustVendorSnapshotMkName != expectedRustVendorSnapshotName {
|
||||||
|
t.Errorf("Unexpected rust vendor snapshot name in AndroidMk: %q, expected: %q\n", librustVendorSnapshotMkName, expectedRustVendorSnapshotName)
|
||||||
|
}
|
||||||
|
|
||||||
|
rustVendorBinModule := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Module()
|
||||||
|
rustVendorBinMkRlibName := android.AndroidMkEntriesForTest(t, ctx, rustVendorBinModule)[0].EntryMap["LOCAL_RLIB_LIBRARIES"][0]
|
||||||
|
if rustVendorBinMkRlibName != expectedRustVendorSnapshotName {
|
||||||
|
t.Errorf("Unexpected rust rlib name in AndroidMk: %q, expected: %q\n", rustVendorBinMkRlibName, expectedRustVendorSnapshotName)
|
||||||
|
}
|
||||||
|
|
||||||
binWithoutSnapshotLdFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("rustc").Args["linkFlags"]
|
binWithoutSnapshotLdFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("rustc").Args["linkFlags"]
|
||||||
libVndkStaticOutputPaths := cc.GetOutputPaths(ctx, staticVariant, []string{"libvndk.vendor_static.30.arm64"})
|
libVndkStaticOutputPaths := cc.GetOutputPaths(ctx, staticVariant, []string{"libvndk.vendor_static.30.arm64"})
|
||||||
if !strings.Contains(binWithoutSnapshotLdFlags, libVndkStaticOutputPaths[0].String()) {
|
if !strings.Contains(binWithoutSnapshotLdFlags, libVndkStaticOutputPaths[0].String()) {
|
||||||
|
Reference in New Issue
Block a user