summaryrefslogtreecommitdiff
path: root/rust/library.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2019-11-21 14:35:20 -0800
committer Ivan Lozano <ivanlozano@google.com> 2019-11-21 14:45:33 -0800
commit88f2b1ce534f75ed5914d9c63f2716ecdda351c1 (patch)
treeecb1fc8d82f589f660b0d3c9414f5f53c4b1c10e /rust/library.go
parentc6e9f92cfab07fded61b52f0645fab580e0858a2 (diff)
Change stdlib linkage for C libraries.
Rust C libraries cannot currently depend on dylibs. This prevents device libraries from attempting to link the stdlib dynamically, instead using rlibs. Bug: 144861059 Test: Simple Rust library compiles as a shared/static library. Change-Id: I38e5aae90e50ddcc5fc72d5a8d1820d92955cf48
Diffstat (limited to 'rust/library.go')
-rw-r--r--rust/library.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/rust/library.go b/rust/library.go
index 386ea4713..ba4754192 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -19,6 +19,7 @@ import (
"strings"
"android/soong/android"
+ "android/soong/rust/config"
)
func init() {
@@ -304,6 +305,15 @@ func (library *libraryDecorator) compilerProps() []interface{} {
}
func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
+
+ // TODO(b/144861059) Remove if C libraries support dylib linkage in the future.
+ if !ctx.Host() && (library.static() || library.shared()) {
+ library.setNoStdlibs()
+ for _, stdlib := range config.Stdlibs {
+ deps.Rlibs = append(deps.Rlibs, stdlib+".static")
+ }
+ }
+
deps = library.baseCompiler.compilerDeps(ctx, deps)
if ctx.toolchain().Bionic() && (library.dylib() || library.shared()) {