diff options
author | Ivan Lozano <ivanlozano@google.com> | 2020-09-28 11:56:30 -0400 |
---|---|---|
committer | Ivan Lozano <ivanlozano@google.com> | 2020-09-28 12:01:47 -0400 |
commit | 11200870b0cd84e9bbccb89b66cf59b5ed4db526 (patch) | |
tree | 24eee171123051ea4cd5cacfc94eded4c7b63481 /rust/binary.go | |
parent | e0510d7a696b97b2477e82f35df69b5072165060 (diff) |
rust: Add prefer_rlib property for static libstd.
Adds the prefer_rlib property to allow linking libstd statically for
device rust binaries. This also changes the default behavior of rustlibs
to also prefer rlib linkage. This is because dylibs do not provide
rlib-libstd variants and always link in libstd dynamically. Thus a
binary requesting libstd rlib linkage should not attempt to link against
dylibs that link libstd dynamically.
Bug: 168729404
Test: New Soong test passes.
Change-Id: Idf8dfbbce8fd936f55a3fb323b17a1a7f0ee954e
Diffstat (limited to 'rust/binary.go')
-rw-r--r-- | rust/binary.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rust/binary.go b/rust/binary.go index 1d02453db..e95cb3afc 100644 --- a/rust/binary.go +++ b/rust/binary.go @@ -24,6 +24,10 @@ func init() { } type BinaryCompilerProperties struct { + // Change the rustlibs linkage to select rlib linkage by default for device targets. + // Also link libstd as an rlib as well on device targets. + // Note: This is the default behavior for host targets. + Prefer_rlib *bool `android:"arch_variant"` } type binaryDecorator struct { @@ -131,9 +135,16 @@ func (binary *binaryDecorator) coverageOutputZipPath() android.OptionalPath { func (binary *binaryDecorator) autoDep(ctx BaseModuleContext) autoDep { // Binaries default to dylib dependencies for device, rlib for host. + if Bool(binary.Properties.Prefer_rlib) { + return rlibAutoDep + } if ctx.Device() { return dylibAutoDep } else { return rlibAutoDep } } + +func (binary *binaryDecorator) staticStd(ctx *depsContext) bool { + return binary.baseCompiler.staticStd(ctx) || Bool(binary.Properties.Prefer_rlib) +} |