rust: Add an option to disable LTO for Rust
This adds an option to disable LTO when building a Rust module. This is mostly intended to speedu p local prototyping, and LTO should not normally be disabled for production builds. Bug: 339628497 Test: m blueprint_tests && m rust Change-Id: I21d5d4513a259a56f101ce8906e2bef7404e4efb
This commit is contained in:
@@ -63,6 +63,35 @@ func TestCfgsToFlags(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLtoFlag(t *testing.T) {
|
||||
ctx := testRust(t, `
|
||||
rust_library_host {
|
||||
name: "libfoo",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "foo",
|
||||
lto: {
|
||||
thin: false,
|
||||
}
|
||||
}
|
||||
|
||||
rust_library_host {
|
||||
name: "libfoo_lto",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "foo",
|
||||
}
|
||||
`)
|
||||
|
||||
libfoo := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_dylib").Rule("rustc")
|
||||
libfooLto := ctx.ModuleForTests("libfoo_lto", "linux_glibc_x86_64_dylib").Rule("rustc")
|
||||
|
||||
if strings.Contains(libfoo.Args["rustcFlags"], "-C lto=thin") {
|
||||
t.Fatalf("libfoo expected to disable lto -- rustcFlags: %#v", libfoo.Args["rustcFlags"])
|
||||
}
|
||||
if !strings.Contains(libfooLto.Args["rustcFlags"], "-C lto=thin") {
|
||||
t.Fatalf("libfoo expected to enable lto by default -- rustcFlags: %#v", libfooLto.Args["rustcFlags"])
|
||||
}
|
||||
}
|
||||
|
||||
// Test that we reject multiple source files.
|
||||
func TestEnforceSingleSourceFile(t *testing.T) {
|
||||
|
||||
|
Reference in New Issue
Block a user