Loading rust/binary_test.go +17 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,23 @@ func TestBinaryFlags(t *testing.T) { } } // Test that the bootstrap property sets the appropriate linker func TestBootstrap(t *testing.T) { ctx := testRust(t, ` rust_binary { name: "foo", srcs: ["foo.rs"], bootstrap: true, }`) foo := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Rule("rustc") flag := "-Wl,-dynamic-linker,/system/bin/bootstrap/linker64" if !strings.Contains(foo.Args["linkFlags"], flag) { t.Errorf("missing link flag to use bootstrap linker, expecting %#v, linkFlags: %#v", flag, foo.Args["linkFlags"]) } } func TestStaticBinaryFlags(t *testing.T) { ctx := testRust(t, ` rust_binary { Loading rust/builder.go +9 −0 Original line number Diff line number Diff line Loading @@ -220,6 +220,15 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl linkFlags = append(linkFlags, flags.GlobalLinkFlags...) linkFlags = append(linkFlags, flags.LinkFlags...) // Check if this module needs to use the bootstrap linker if ctx.RustModule().Bootstrap() && !ctx.RustModule().InRecovery() && !ctx.RustModule().InRamdisk() && !ctx.RustModule().InVendorRamdisk() { dynamicLinker := "-Wl,-dynamic-linker,/system/bin/bootstrap/linker" if ctx.toolchain().Is64Bit() { dynamicLinker += "64" } linkFlags = append(linkFlags, dynamicLinker) } libFlags := makeLibFlags(deps) // Collect dependencies Loading rust/rust.go +5 −1 Original line number Diff line number Diff line Loading @@ -85,6 +85,10 @@ type BaseProperties struct { VendorRamdiskVariantNeeded bool `blueprint:"mutated"` ExtraVariants []string `blueprint:"mutated"` // Allows this module to use non-APEX version of libraries. Useful // for building binaries that are started before APEXes are activated. Bootstrap *bool // Used by vendor snapshot to record dependencies from snapshot modules. SnapshotSharedLibs []string `blueprint:"mutated"` SnapshotStaticLibs []string `blueprint:"mutated"` Loading Loading @@ -288,7 +292,7 @@ func (mod *Module) UseVndk() bool { } func (mod *Module) Bootstrap() bool { return false return Bool(mod.Properties.Bootstrap) } func (mod *Module) MustUseVendorVariant() bool { Loading Loading
rust/binary_test.go +17 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,23 @@ func TestBinaryFlags(t *testing.T) { } } // Test that the bootstrap property sets the appropriate linker func TestBootstrap(t *testing.T) { ctx := testRust(t, ` rust_binary { name: "foo", srcs: ["foo.rs"], bootstrap: true, }`) foo := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Rule("rustc") flag := "-Wl,-dynamic-linker,/system/bin/bootstrap/linker64" if !strings.Contains(foo.Args["linkFlags"], flag) { t.Errorf("missing link flag to use bootstrap linker, expecting %#v, linkFlags: %#v", flag, foo.Args["linkFlags"]) } } func TestStaticBinaryFlags(t *testing.T) { ctx := testRust(t, ` rust_binary { Loading
rust/builder.go +9 −0 Original line number Diff line number Diff line Loading @@ -220,6 +220,15 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl linkFlags = append(linkFlags, flags.GlobalLinkFlags...) linkFlags = append(linkFlags, flags.LinkFlags...) // Check if this module needs to use the bootstrap linker if ctx.RustModule().Bootstrap() && !ctx.RustModule().InRecovery() && !ctx.RustModule().InRamdisk() && !ctx.RustModule().InVendorRamdisk() { dynamicLinker := "-Wl,-dynamic-linker,/system/bin/bootstrap/linker" if ctx.toolchain().Is64Bit() { dynamicLinker += "64" } linkFlags = append(linkFlags, dynamicLinker) } libFlags := makeLibFlags(deps) // Collect dependencies Loading
rust/rust.go +5 −1 Original line number Diff line number Diff line Loading @@ -85,6 +85,10 @@ type BaseProperties struct { VendorRamdiskVariantNeeded bool `blueprint:"mutated"` ExtraVariants []string `blueprint:"mutated"` // Allows this module to use non-APEX version of libraries. Useful // for building binaries that are started before APEXes are activated. Bootstrap *bool // Used by vendor snapshot to record dependencies from snapshot modules. SnapshotSharedLibs []string `blueprint:"mutated"` SnapshotStaticLibs []string `blueprint:"mutated"` Loading Loading @@ -288,7 +292,7 @@ func (mod *Module) UseVndk() bool { } func (mod *Module) Bootstrap() bool { return false return Bool(mod.Properties.Bootstrap) } func (mod *Module) MustUseVendorVariant() bool { Loading