diff options
Diffstat (limited to 'rust/binary.go')
| -rw-r--r-- | rust/binary.go | 15 | 
1 files changed, 15 insertions, 0 deletions
diff --git a/rust/binary.go b/rust/binary.go index 279c6f50f..52f840e7a 100644 --- a/rust/binary.go +++ b/rust/binary.go @@ -71,6 +71,15 @@ func (binary *binaryDecorator) preferDynamic() bool {  func (binary *binaryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {  	flags = binary.baseCompiler.compilerFlags(ctx, flags) + +	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") +	} +  	if binary.preferDynamic() {  		flags.RustFlags = append(flags.RustFlags, "-C prefer-dynamic")  	} @@ -86,6 +95,12 @@ func (binary *binaryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {  		}  	} +	if ctx.toolchain().Bionic() { +		deps = binary.baseCompiler.bionicDeps(ctx, deps) +		deps.CrtBegin = "crtbegin_dynamic" +		deps.CrtEnd = "crtend_android" +	} +  	return deps  }  |