summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
authorIvan Lozano <ivanlozano@google.com>2020-10-02 10:03:23 -0400
committerIvan Lozano <ivanlozano@google.com>2020-10-02 12:31:23 -0400
commitbf63d00c5487d18d69e1040a94400546f0750476 (patch)
tree8785122fb3c3b81f91499da801b4887c6506ddd2 /rust/compiler.go
parent45dda43df0b32122d833d43166f2fa2f9a170889 (diff)
rust: Add static binary support
Adds the "static_executable" property to rust_binary modules which allows for building fully static executables. This only impacts bionic targets. Bug: 169434439 Test: rust_binary module with static_executable true builds, runs on device. Change-Id: I83c19fddd070859b7e56d248237cfd73e1768519
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index 102f9dc8d..8d2f09c2b 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -240,11 +240,18 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
return deps
}
-func bionicDeps(deps Deps) Deps {
- deps.SharedLibs = append(deps.SharedLibs, "liblog")
- deps.SharedLibs = append(deps.SharedLibs, "libc")
- deps.SharedLibs = append(deps.SharedLibs, "libm")
- deps.SharedLibs = append(deps.SharedLibs, "libdl")
+func bionicDeps(deps Deps, static bool) Deps {
+ bionicLibs := []string{}
+ bionicLibs = append(bionicLibs, "liblog")
+ bionicLibs = append(bionicLibs, "libc")
+ bionicLibs = append(bionicLibs, "libm")
+ bionicLibs = append(bionicLibs, "libdl")
+
+ if static {
+ deps.StaticLibs = append(deps.StaticLibs, bionicLibs...)
+ } else {
+ deps.SharedLibs = append(deps.SharedLibs, bionicLibs...)
+ }
//TODO(b/141331117) libstd requires libgcc on Android
deps.StaticLibs = append(deps.StaticLibs, "libgcc")