Loading rust/builder.go +2 −2 Original line number Diff line number Diff line Loading @@ -108,8 +108,8 @@ func transformSrctoCrate(ctx android.ModuleContext, main android.Path, deps Path } // TODO once we have static libraries in the host prebuilt .bp, this // should be unconditionally added. if !ctx.Host() { // If we're on a device build, do not use an implicit sysroot if !(ctx.Host() && ctx.TargetPrimary()) { // If we're not targeting the host primary arch, do not use an implicit sysroot rustcFlags = append(rustcFlags, "--sysroot=/dev/null") } // Collect linker flags Loading rust/compiler.go +6 −3 Original line number Diff line number Diff line Loading @@ -183,8 +183,8 @@ 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 host, use the compiler's stdlibs if ctx.Host() { // If we're building for the primary host target, use the compiler's stdlibs if ctx.Host() && ctx.TargetPrimary() { stdlib = stdlib + "_" + ctx.toolchain().RustTriple() } Loading @@ -192,9 +192,12 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps { // static linking is the default, if one of our static // dependencies uses a dynamic library, we need to dynamically // link the stdlib as well. if (len(deps.Dylibs) > 0) || (!ctx.Host()) { if (len(deps.Dylibs) > 0) || ctx.Device() { // Dynamically linked stdlib deps.Dylibs = append(deps.Dylibs, stdlib) } else if ctx.Host() && !ctx.TargetPrimary() { // Otherwise use the static in-tree stdlib for host secondary arch deps.Rlibs = append(deps.Rlibs, stdlib+".static") } } } Loading rust/config/arm_device.go +1 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ func init() { } type toolchainArm struct { toolchain64Bit toolchain32Bit toolchainRustFlags string } Loading rust/library.go +1 −1 Original line number Diff line number Diff line Loading @@ -281,7 +281,7 @@ func (library *libraryDecorator) BuildOnlyShared() { } func NewRustLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) { module := newModule(hod, android.MultilibFirst) module := newModule(hod, android.MultilibBoth) library := &libraryDecorator{ MutatedProperties: LibraryMutatedProperties{ Loading rust/rust_test.go +14 −1 Original line number Diff line number Diff line Loading @@ -248,3 +248,16 @@ func TestNoStdlibs(t *testing.T) { t.Errorf("no_stdlibs did not suppress dependency on libstd") } } // Test that libraries provide both 32-bit and 64-bit variants. func TestMultilib(t *testing.T) { ctx := testRust(t, ` rust_library_rlib { name: "libfoo", srcs: ["foo.rs"], crate_name: "foo", }`) _ = ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib") _ = ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_rlib") } Loading
rust/builder.go +2 −2 Original line number Diff line number Diff line Loading @@ -108,8 +108,8 @@ func transformSrctoCrate(ctx android.ModuleContext, main android.Path, deps Path } // TODO once we have static libraries in the host prebuilt .bp, this // should be unconditionally added. if !ctx.Host() { // If we're on a device build, do not use an implicit sysroot if !(ctx.Host() && ctx.TargetPrimary()) { // If we're not targeting the host primary arch, do not use an implicit sysroot rustcFlags = append(rustcFlags, "--sysroot=/dev/null") } // Collect linker flags Loading
rust/compiler.go +6 −3 Original line number Diff line number Diff line Loading @@ -183,8 +183,8 @@ 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 host, use the compiler's stdlibs if ctx.Host() { // If we're building for the primary host target, use the compiler's stdlibs if ctx.Host() && ctx.TargetPrimary() { stdlib = stdlib + "_" + ctx.toolchain().RustTriple() } Loading @@ -192,9 +192,12 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps { // static linking is the default, if one of our static // dependencies uses a dynamic library, we need to dynamically // link the stdlib as well. if (len(deps.Dylibs) > 0) || (!ctx.Host()) { if (len(deps.Dylibs) > 0) || ctx.Device() { // Dynamically linked stdlib deps.Dylibs = append(deps.Dylibs, stdlib) } else if ctx.Host() && !ctx.TargetPrimary() { // Otherwise use the static in-tree stdlib for host secondary arch deps.Rlibs = append(deps.Rlibs, stdlib+".static") } } } Loading
rust/config/arm_device.go +1 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ func init() { } type toolchainArm struct { toolchain64Bit toolchain32Bit toolchainRustFlags string } Loading
rust/library.go +1 −1 Original line number Diff line number Diff line Loading @@ -281,7 +281,7 @@ func (library *libraryDecorator) BuildOnlyShared() { } func NewRustLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) { module := newModule(hod, android.MultilibFirst) module := newModule(hod, android.MultilibBoth) library := &libraryDecorator{ MutatedProperties: LibraryMutatedProperties{ Loading
rust/rust_test.go +14 −1 Original line number Diff line number Diff line Loading @@ -248,3 +248,16 @@ func TestNoStdlibs(t *testing.T) { t.Errorf("no_stdlibs did not suppress dependency on libstd") } } // Test that libraries provide both 32-bit and 64-bit variants. func TestMultilib(t *testing.T) { ctx := testRust(t, ` rust_library_rlib { name: "libfoo", srcs: ["foo.rs"], crate_name: "foo", }`) _ = ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib") _ = ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_rlib") }