summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rust/binary.go7
-rw-r--r--rust/compiler.go14
-rw-r--r--rust/library.go9
-rw-r--r--rust/rust.go7
-rw-r--r--rust/test.go4
5 files changed, 28 insertions, 13 deletions
diff --git a/rust/binary.go b/rust/binary.go
index e95cb3afc..2758ae077 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -145,6 +145,9 @@ func (binary *binaryDecorator) autoDep(ctx BaseModuleContext) autoDep {
}
}
-func (binary *binaryDecorator) staticStd(ctx *depsContext) bool {
- return binary.baseCompiler.staticStd(ctx) || Bool(binary.Properties.Prefer_rlib)
+func (binary *binaryDecorator) stdLinkage(ctx *depsContext) RustLinkage {
+ if Bool(binary.Properties.Prefer_rlib) {
+ return RlibLinkage
+ }
+ return binary.baseCompiler.stdLinkage(ctx)
}
diff --git a/rust/compiler.go b/rust/compiler.go
index aeb904b37..102f9dc8d 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -24,6 +24,14 @@ import (
"android/soong/rust/config"
)
+type RustLinkage int
+
+const (
+ DefaultLinkage RustLinkage = iota
+ RlibLinkage
+ DylibLinkage
+)
+
func (compiler *baseCompiler) edition() string {
return proptools.StringDefault(compiler.Properties.Edition, config.DefaultEdition)
}
@@ -146,12 +154,12 @@ func (compiler *baseCompiler) coverageOutputZipPath() android.OptionalPath {
panic("baseCompiler does not implement coverageOutputZipPath()")
}
-func (compiler *baseCompiler) staticStd(ctx *depsContext) bool {
+func (compiler *baseCompiler) stdLinkage(ctx *depsContext) RustLinkage {
// For devices, we always link stdlibs in as dylibs by default.
if ctx.Device() {
- return false
+ return DylibLinkage
} else {
- return true
+ return RlibLinkage
}
}
diff --git a/rust/library.go b/rust/library.go
index 2792c5b4a..7a77706a9 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -158,9 +158,12 @@ func (library *libraryDecorator) static() bool {
return library.MutatedProperties.VariantIsStatic
}
-func (library *libraryDecorator) staticStd(ctx *depsContext) bool {
- // libraries should only request the staticStd when building a static FFI or when variant is staticStd
- return library.static() || library.MutatedProperties.VariantIsStaticStd
+func (library *libraryDecorator) stdLinkage(ctx *depsContext) RustLinkage {
+ // libraries should only request the RlibLinkage when building a static FFI or when variant is StaticStd
+ if library.static() || library.MutatedProperties.VariantIsStaticStd {
+ return RlibLinkage
+ }
+ return DefaultLinkage
}
func (library *libraryDecorator) source() bool {
diff --git a/rust/rust.go b/rust/rust.go
index 22b81f135..f88b310da 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -294,7 +294,7 @@ type compiler interface {
Disabled() bool
SetDisabled()
- staticStd(ctx *depsContext) bool
+ stdLinkage(ctx *depsContext) RustLinkage
}
type exportedFlagsProducer interface {
@@ -997,8 +997,9 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
commonDepVariations = append(commonDepVariations,
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
}
+
stdLinkage := "dylib-std"
- if mod.compiler.staticStd(ctx) {
+ if mod.compiler.stdLinkage(ctx) == RlibLinkage {
stdLinkage = "rlib-std"
}
@@ -1030,7 +1031,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
}
if deps.Stdlibs != nil {
- if mod.compiler.staticStd(ctx) {
+ if mod.compiler.stdLinkage(ctx) == RlibLinkage {
actx.AddVariationDependencies(
append(commonDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: "rlib"}),
rlibDepTag, deps.Stdlibs...)
diff --git a/rust/test.go b/rust/test.go
index 067944858..bc7f53c7c 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -134,6 +134,6 @@ func RustTestHostFactory() android.Module {
return module.Init()
}
-func (test *testDecorator) staticStd(ctx *depsContext) bool {
- return true
+func (test *testDecorator) stdLinkage(ctx *depsContext) RustLinkage {
+ return RlibLinkage
}