From cb7c44806651ad9d9e4d257fc1c04d61115119f3 Mon Sep 17 00:00:00 2001 From: Trevor Radcliffe Date: Fri, 10 Feb 2023 20:29:20 +0000 Subject: [PATCH] Add test that LTO isn't propagated to runtime_libs Bug: 261733821 Test: It is a test Change-Id: I2cda89dc53d6eaa51c756f552d990169a280b053 --- cc/lto_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cc/lto_test.go b/cc/lto_test.go index cee5aa3bc..4220f3255 100644 --- a/cc/lto_test.go +++ b/cc/lto_test.go @@ -209,3 +209,33 @@ func TestLtoDisabledButEnabledForArch(t *testing.T) { android.AssertStringDoesNotContain(t, "got flag for LTO in variant that doesn't expect it", libFooWithoutLto.Args["ldFlags"], "-flto=thin") } + +func TestLtoDoesNotPropagateToRuntimeLibs(t *testing.T) { + t.Parallel() + bp := ` + cc_library { + name: "runtime_libbar", + srcs: ["bar.c"], + } + + cc_library { + name: "libfoo", + srcs: ["foo.c"], + runtime_libs: ["runtime_libbar"], + lto: { + thin: true, + }, + }` + + result := android.GroupFixturePreparers( + prepareForCcTest, + ).RunTestWithBp(t, bp) + + libFoo := result.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld") + libBar := result.ModuleForTests("runtime_libbar", "android_arm_armv7-a-neon_shared").Rule("ld") + + android.AssertStringDoesContain(t, "missing flag for LTO in LTO enabled library", + libFoo.Args["ldFlags"], "-flto=thin") + android.AssertStringDoesNotContain(t, "got flag for LTO in runtime_lib", + libBar.Args["ldFlags"], "-flto=thin") +}