diff options
author | 2020-12-08 14:43:00 -0500 | |
---|---|---|
committer | 2020-12-09 09:55:12 -0500 | |
commit | ea08613dd35bf8ae9f41e61e6c80a8fe255ce155 (patch) | |
tree | 5abd2eea941cf451a44a9926aa4d7f92848d9201 /rust/library.go | |
parent | 110d13bef3bd302a22facf16677a9ee893a0486c (diff) |
Move prefer_rlib from binary to base compiler.
Moves the prefer_rlib property out from being exclusively a binary
property to one thats part of the base compiler properties. This
provides a little more control over the libstd linkage in our libraries.
Specifically, this enables a usecase where rust_ffi_shared needs to link
against libstd statically rather than dynamically.
Bug: 175121262
Test: New Soong tests pass.
Change-Id: If68014c684a75ba70e9d7dacbb01c7d360dc25a1
Diffstat (limited to 'rust/library.go')
-rw-r--r-- | rust/library.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/rust/library.go b/rust/library.go index 971588d8a..9d731e68f 100644 --- a/rust/library.go +++ b/rust/library.go @@ -159,14 +159,6 @@ func (library *libraryDecorator) static() bool { return library.MutatedProperties.VariantIsStatic } -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 { return library.MutatedProperties.VariantIsSource } @@ -228,7 +220,9 @@ func (library *libraryDecorator) setSource() { } func (library *libraryDecorator) autoDep(ctx BaseModuleContext) autoDep { - if library.rlib() || library.static() { + if library.preferRlib() { + return rlibAutoDep + } else if library.rlib() || library.static() { return rlibAutoDep } else if library.dylib() || library.shared() { return dylibAutoDep @@ -237,6 +231,15 @@ func (library *libraryDecorator) autoDep(ctx BaseModuleContext) autoDep { } } +func (library *libraryDecorator) stdLinkage(ctx *depsContext) RustLinkage { + if library.static() || library.MutatedProperties.VariantIsStaticStd { + return RlibLinkage + } else if library.baseCompiler.preferRlib() { + return RlibLinkage + } + return DefaultLinkage +} + var _ compiler = (*libraryDecorator)(nil) var _ libraryInterface = (*libraryDecorator)(nil) var _ exportedFlagsProducer = (*libraryDecorator)(nil) |