summaryrefslogtreecommitdiff
path: root/rust/rust.go
diff options
context:
space:
mode:
author Maciej Żenczykowski <maze@google.com> 2024-12-17 06:08:02 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-12-17 06:08:02 -0800
commitaea639d61264b9b22027d8c274180883d1143ea7 (patch)
treea52113bf022d30df9b7607d2f15eb686ad8ab435 /rust/rust.go
parent9e1f9b9d73dae437aadd9b204136b2fcc8fc4a98 (diff)
parent806efd3885d6eecfa1b1bd1697431c0ab073a76a (diff)
Merge "rust: Alias rust_ffi_rlib to rust_library_rlib" into main
Diffstat (limited to 'rust/rust.go')
-rw-r--r--rust/rust.go33
1 files changed, 21 insertions, 12 deletions
diff --git a/rust/rust.go b/rust/rust.go
index 6fc682f25..0c48154bb 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -595,7 +595,7 @@ func (mod *Module) CcLibraryInterface() bool {
if mod.compiler != nil {
// use build{Static,Shared}() instead of {static,shared}() here because this might be called before
// VariantIs{Static,Shared} is set.
- if lib, ok := mod.compiler.(libraryInterface); ok && (lib.buildShared() || lib.buildStatic()) {
+ if lib, ok := mod.compiler.(libraryInterface); ok && (lib.buildShared() || lib.buildStatic() || lib.buildRlib()) {
return true
}
}
@@ -681,15 +681,6 @@ func (mod *Module) BuildRlibVariant() bool {
panic(fmt.Errorf("BuildRlibVariant called on non-library module: %q", mod.BaseModuleName()))
}
-func (mod *Module) IsRustFFI() bool {
- if mod.compiler != nil {
- if library, ok := mod.compiler.(libraryInterface); ok {
- return library.isFFILibrary()
- }
- }
- return false
-}
-
func (mod *Module) BuildSharedVariant() bool {
if mod.compiler != nil {
if library, ok := mod.compiler.(libraryInterface); ok {
@@ -1237,6 +1228,8 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
ctx.VisitDirectDeps(func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
depTag := ctx.OtherModuleDependencyTag(dep)
+ modStdLinkage := mod.compiler.stdLinkage(ctx.Device())
+
if _, exists := skipModuleList[depName]; exists {
return
}
@@ -1265,6 +1258,14 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.transitiveImplementationDeps = append(depPaths.transitiveImplementationDeps, info.ImplementationDeps)
}
+ if !rustDep.compiler.noStdlibs() {
+ rustDepStdLinkage := rustDep.compiler.stdLinkage(ctx.Device())
+ if rustDepStdLinkage != modStdLinkage {
+ ctx.ModuleErrorf("Rust dependency %q has the wrong StdLinkage; expected %#v, got %#v", depName, modStdLinkage, rustDepStdLinkage)
+ return
+ }
+ }
+
case depTag == rlibDepTag:
rlib, ok := rustDep.compiler.(libraryInterface)
if !ok || !rlib.rlib() {
@@ -1285,6 +1286,14 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.transitiveImplementationDeps = append(depPaths.transitiveImplementationDeps, info.ImplementationDeps)
}
+ if !rustDep.compiler.noStdlibs() {
+ rustDepStdLinkage := rustDep.compiler.stdLinkage(ctx.Device())
+ if rustDepStdLinkage != modStdLinkage {
+ ctx.ModuleErrorf("Rust dependency %q has the wrong StdLinkage; expected %#v, got %#v", depName, modStdLinkage, rustDepStdLinkage)
+ return
+ }
+ }
+
case depTag == procMacroDepTag:
directProcMacroDeps = append(directProcMacroDeps, rustDep)
mod.Properties.AndroidMkProcMacroLibs = append(mod.Properties.AndroidMkProcMacroLibs, makeLibName)
@@ -1603,7 +1612,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
stdLinkage := "dylib-std"
- if mod.compiler.stdLinkage(ctx) == RlibLinkage {
+ if mod.compiler.stdLinkage(ctx.Device()) == RlibLinkage {
stdLinkage = "rlib-std"
}
@@ -1670,7 +1679,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
// stdlibs
if deps.Stdlibs != nil {
- if mod.compiler.stdLinkage(ctx) == RlibLinkage {
+ if mod.compiler.stdLinkage(ctx.Device()) == RlibLinkage {
for _, lib := range deps.Stdlibs {
actx.AddVariationDependencies(append(commonDepVariations, []blueprint.Variation{{Mutator: "rust_libraries", Variation: "rlib"}}...),
rlibDepTag, lib)