Link device binaries dynamically by default.
Device binaries currently are linked statically by default. Instead we
should be linking these dynamic by default. To avoid conflicts when
manually specifying rlib dependencies on modules, we always link libstd
dynamically for all device modules except static libraries.
This removes the "prefer_dynamic" property entirely to avoid confusion.
Bug: 165161105
Test: m profcollectd is built dynamically.
Test: cd external/rust/; mma
Test: cd external/crosvm/; mma
Change-Id: I25ac897040acbcc2d97c791a33e8e01610632272
diff --git a/rust/binary.go b/rust/binary.go
index 1a82c92..f750186 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -24,9 +24,6 @@
}
type BinaryCompilerProperties struct {
- // passes -C prefer-dynamic to rustc, which tells it to dynamically link the stdlib
- // (assuming it has no dylib dependencies already)
- Prefer_dynamic *bool
}
type binaryDecorator struct {
@@ -60,10 +57,6 @@
return module, binary
}
-func (binary *binaryDecorator) preferDynamic() bool {
- return Bool(binary.Properties.Prefer_dynamic)
-}
-
func (binary *binaryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
flags = binary.baseCompiler.compilerFlags(ctx, flags)
@@ -76,9 +69,6 @@
"-Wl,--no-undefined-version")
}
- if binary.preferDynamic() {
- flags.RustFlags = append(flags.RustFlags, "-C prefer-dynamic")
- }
return flags
}
@@ -132,8 +122,9 @@
return binary.coverageOutputZipFile
}
-func (binary *binaryDecorator) autoDep() autoDep {
- if binary.preferDynamic() {
+func (binary *binaryDecorator) autoDep(ctx BaseModuleContext) autoDep {
+ // Binaries default to dylib dependencies for device, rlib for host.
+ if ctx.Device() {
return dylibAutoDep
} else {
return rlibAutoDep