summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index ef7fb8cfc..664578d82 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -129,8 +129,9 @@ type baseCompiler struct {
location installLocation
coverageOutputZipFile android.OptionalPath
- unstrippedOutputFile android.Path
distFile android.OptionalPath
+ // Stripped output file. If Valid(), this file will be installed instead of outputFile.
+ strippedOutputFile android.OptionalPath
}
func (compiler *baseCompiler) Disabled() bool {
@@ -145,6 +146,10 @@ func (compiler *baseCompiler) coverageOutputZipPath() android.OptionalPath {
panic("baseCompiler does not implement coverageOutputZipPath()")
}
+func (compiler *baseCompiler) static() bool {
+ return false
+}
+
var _ compiler = (*baseCompiler)(nil)
func (compiler *baseCompiler) inData() bool {
@@ -211,12 +216,20 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
if !Bool(compiler.Properties.No_stdlibs) {
for _, stdlib := range config.Stdlibs {
- // If we're building for the primary host target, use the compiler's stdlibs
- if ctx.Host() && ctx.TargetPrimary() {
+ // If we're building for the primary arch of the build host, use the compiler's stdlibs
+ if ctx.Target().Os == android.BuildOs && ctx.TargetPrimary() {
stdlib = stdlib + "_" + ctx.toolchain().RustTriple()
}
- deps.Rustlibs = append(deps.Rustlibs, stdlib)
+ // For devices, we always link stdlibs in as dylibs except for ffi static libraries.
+ // (rustc does not support linking libstd as a dylib for ffi static libraries)
+ if ctx.Host() {
+ deps.Rustlibs = append(deps.Rustlibs, stdlib)
+ } else if ctx.RustModule().compiler.static() {
+ deps.Rlibs = append(deps.Rlibs, stdlib)
+ } else {
+ deps.Dylibs = append(deps.Dylibs, stdlib)
+ }
}
}
return deps
@@ -257,8 +270,12 @@ func (compiler *baseCompiler) nativeCoverage() bool {
return false
}
-func (compiler *baseCompiler) install(ctx ModuleContext, file android.Path) {
- compiler.path = ctx.InstallFile(compiler.installDir(ctx), file.Base(), file)
+func (compiler *baseCompiler) install(ctx ModuleContext) {
+ path := ctx.RustModule().outputFile
+ if compiler.strippedOutputFile.Valid() {
+ path = compiler.strippedOutputFile
+ }
+ compiler.path = ctx.InstallFile(compiler.installDir(ctx), path.Path().Base(), path.Path())
}
func (compiler *baseCompiler) getStem(ctx ModuleContext) string {