summaryrefslogtreecommitdiff
path: root/rust/binary.go
diff options
context:
space:
mode:
Diffstat (limited to 'rust/binary.go')
-rw-r--r--rust/binary.go19
1 files changed, 7 insertions, 12 deletions
diff --git a/rust/binary.go b/rust/binary.go
index 2de92c17f..cba29a023 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -72,14 +72,11 @@ func NewRustBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator
func (binary *binaryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
flags = binary.baseCompiler.compilerFlags(ctx, flags)
- if ctx.Os().Linux() {
- flags.LinkFlags = append(flags.LinkFlags, "-Wl,--gc-sections")
- }
-
if ctx.toolchain().Bionic() {
// no-undefined-version breaks dylib compilation since __rust_*alloc* functions aren't defined,
// but we can apply this to binaries.
flags.LinkFlags = append(flags.LinkFlags,
+ "-Wl,--gc-sections",
"-Wl,-z,nocopyreloc",
"-Wl,--no-undefined-version")
@@ -133,13 +130,16 @@ func (binary *binaryDecorator) preferRlib() bool {
func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) buildOutput {
fileName := binary.getStem(ctx) + ctx.toolchain().ExecutableSuffix()
- srcPath, _ := srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs)
outputFile := android.PathForModuleOut(ctx, fileName)
ret := buildOutput{outputFile: outputFile}
+ crateRootPath := crateRootPath(ctx, binary)
+
+ // Ensure link dirs are not duplicated
+ deps.linkDirs = android.FirstUniqueStrings(deps.linkDirs)
flags.RustFlags = append(flags.RustFlags, deps.depFlags...)
flags.LinkFlags = append(flags.LinkFlags, deps.depLinkFlags...)
- flags.LinkFlags = append(flags.LinkFlags, deps.linkObjects.Strings()...)
+ flags.LinkFlags = append(flags.LinkFlags, deps.linkObjects...)
if binary.stripper.NeedsStrip(ctx) {
strippedOutputFile := outputFile
@@ -150,7 +150,7 @@ func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps Path
}
binary.baseCompiler.unstrippedOutputFile = outputFile
- ret.kytheFile = TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile).kytheFile
+ ret.kytheFile = TransformSrcToBinary(ctx, crateRootPath, deps, flags, outputFile).kytheFile
return ret
}
@@ -158,9 +158,6 @@ func (binary *binaryDecorator) autoDep(ctx android.BottomUpMutatorContext) autoD
// Binaries default to dylib dependencies for device, rlib for host.
if binary.preferRlib() {
return rlibAutoDep
- } else if mod, ok := ctx.Module().(*Module); ok && mod.InVendor() {
- // Vendor Rust binaries should prefer rlibs.
- return rlibAutoDep
} else if ctx.Device() {
return dylibAutoDep
} else {
@@ -171,8 +168,6 @@ func (binary *binaryDecorator) autoDep(ctx android.BottomUpMutatorContext) autoD
func (binary *binaryDecorator) stdLinkage(ctx *depsContext) RustLinkage {
if binary.preferRlib() {
return RlibLinkage
- } else if ctx.RustModule().InVendor() {
- return RlibLinkage
}
return binary.baseCompiler.stdLinkage(ctx)
}