Loading rust/binary.go +13 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,11 @@ type BinaryCompilerProperties struct { Static_executable *bool `android:"arch_variant"` } type binaryInterface interface { binary() bool staticallyLinked() bool } type binaryDecorator struct { *baseCompiler stripper Stripper Loading Loading @@ -155,3 +160,11 @@ func (binary *binaryDecorator) stdLinkage(ctx *depsContext) RustLinkage { } return binary.baseCompiler.stdLinkage(ctx) } func (binary *binaryDecorator) binary() bool { return true } func (binary *binaryDecorator) staticallyLinked() bool { return Bool(binary.Properties.Static_executable) } rust/rust.go +9 −6 Original line number Diff line number Diff line Loading @@ -261,10 +261,8 @@ func (mod *Module) Rlib() bool { } func (mod *Module) Binary() bool { if mod.compiler != nil { if _, ok := mod.compiler.(*binaryDecorator); ok { return true } if binary, ok := mod.compiler.(binaryInterface); ok { return binary.binary() } return false } Loading @@ -273,7 +271,7 @@ func (mod *Module) StaticExecutable() bool { if !mod.Binary() { return false } return Bool(mod.compiler.(*binaryDecorator).Properties.Static_executable) return mod.StaticallyLinked() } func (mod *Module) Object() bool { Loading Loading @@ -1123,7 +1121,12 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { if cc.IsWholeStaticLib(depTag) { // rustc will bundle static libraries when they're passed with "-lstatic=<lib>". This will fail // if the library is not prefixed by "lib". if libName, ok := libNameFromFilePath(linkObject.Path()); ok { if mod.Binary() { // Binaries may sometimes need to link whole static libraries that don't start with 'lib'. // Since binaries don't need to 'rebundle' these like libraries and only use these for the // final linkage, pass the args directly to the linker to handle these cases. depPaths.depLinkFlags = append(depPaths.depLinkFlags, []string{"-Wl,--whole-archive", linkObject.Path().String(), "-Wl,--no-whole-archive"}...) } else if libName, ok := libNameFromFilePath(linkObject.Path()); ok { depPaths.depFlags = append(depPaths.depFlags, "-lstatic="+libName) } else { ctx.ModuleErrorf("'%q' cannot be listed as a whole_static_library in Rust modules unless the output is prefixed by 'lib'", depName, ctx.ModuleName()) Loading rust/sanitize.go +2 −2 Original line number Diff line number Diff line Loading @@ -311,8 +311,8 @@ func (mod *Module) SetSanitizeDep(b bool) { func (mod *Module) StaticallyLinked() bool { if lib, ok := mod.compiler.(libraryInterface); ok { return lib.rlib() || lib.static() } else if binary, ok := mod.compiler.(*binaryDecorator); ok { return Bool(binary.Properties.Static_executable) } else if binary, ok := mod.compiler.(binaryInterface); ok { return binary.staticallyLinked() } return false } Loading Loading
rust/binary.go +13 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,11 @@ type BinaryCompilerProperties struct { Static_executable *bool `android:"arch_variant"` } type binaryInterface interface { binary() bool staticallyLinked() bool } type binaryDecorator struct { *baseCompiler stripper Stripper Loading Loading @@ -155,3 +160,11 @@ func (binary *binaryDecorator) stdLinkage(ctx *depsContext) RustLinkage { } return binary.baseCompiler.stdLinkage(ctx) } func (binary *binaryDecorator) binary() bool { return true } func (binary *binaryDecorator) staticallyLinked() bool { return Bool(binary.Properties.Static_executable) }
rust/rust.go +9 −6 Original line number Diff line number Diff line Loading @@ -261,10 +261,8 @@ func (mod *Module) Rlib() bool { } func (mod *Module) Binary() bool { if mod.compiler != nil { if _, ok := mod.compiler.(*binaryDecorator); ok { return true } if binary, ok := mod.compiler.(binaryInterface); ok { return binary.binary() } return false } Loading @@ -273,7 +271,7 @@ func (mod *Module) StaticExecutable() bool { if !mod.Binary() { return false } return Bool(mod.compiler.(*binaryDecorator).Properties.Static_executable) return mod.StaticallyLinked() } func (mod *Module) Object() bool { Loading Loading @@ -1123,7 +1121,12 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { if cc.IsWholeStaticLib(depTag) { // rustc will bundle static libraries when they're passed with "-lstatic=<lib>". This will fail // if the library is not prefixed by "lib". if libName, ok := libNameFromFilePath(linkObject.Path()); ok { if mod.Binary() { // Binaries may sometimes need to link whole static libraries that don't start with 'lib'. // Since binaries don't need to 'rebundle' these like libraries and only use these for the // final linkage, pass the args directly to the linker to handle these cases. depPaths.depLinkFlags = append(depPaths.depLinkFlags, []string{"-Wl,--whole-archive", linkObject.Path().String(), "-Wl,--no-whole-archive"}...) } else if libName, ok := libNameFromFilePath(linkObject.Path()); ok { depPaths.depFlags = append(depPaths.depFlags, "-lstatic="+libName) } else { ctx.ModuleErrorf("'%q' cannot be listed as a whole_static_library in Rust modules unless the output is prefixed by 'lib'", depName, ctx.ModuleName()) Loading
rust/sanitize.go +2 −2 Original line number Diff line number Diff line Loading @@ -311,8 +311,8 @@ func (mod *Module) SetSanitizeDep(b bool) { func (mod *Module) StaticallyLinked() bool { if lib, ok := mod.compiler.(libraryInterface); ok { return lib.rlib() || lib.static() } else if binary, ok := mod.compiler.(*binaryDecorator); ok { return Bool(binary.Properties.Static_executable) } else if binary, ok := mod.compiler.(binaryInterface); ok { return binary.staticallyLinked() } return false } Loading