Add test for LTO edge case
This test confirms the behavior when LTO is disabled generally but then enabled for a specific target. Bug: 261733821 Test: Unit test Change-Id: I415cd0146f2b83d85654239550d129f87e9001bc
This commit is contained in:
@@ -15,10 +15,11 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -177,3 +178,35 @@ func TestThinLtoOnlyOnStaticDep(t *testing.T) {
|
|||||||
t.Errorf("'baz' expected to have flags %q, but got %q", w, libFooCFlags)
|
t.Errorf("'baz' expected to have flags %q, but got %q", w, libFooCFlags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLtoDisabledButEnabledForArch(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
bp := `
|
||||||
|
cc_library {
|
||||||
|
name: "libfoo",
|
||||||
|
srcs: ["foo.c"],
|
||||||
|
host_supported:true,
|
||||||
|
lto: {
|
||||||
|
never: true,
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
android: {
|
||||||
|
lto: {
|
||||||
|
never: false,
|
||||||
|
thin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}`
|
||||||
|
result := android.GroupFixturePreparers(
|
||||||
|
prepareForCcTest,
|
||||||
|
).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
|
libFooWithLto := result.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Rule("ld")
|
||||||
|
libFooWithoutLto := result.ModuleForTests("libfoo", "linux_glibc_x86_64_shared").Rule("ld")
|
||||||
|
|
||||||
|
android.AssertStringDoesContain(t, "missing flag for LTO in variant that expects it",
|
||||||
|
libFooWithLto.Args["ldFlags"], "-flto=thin")
|
||||||
|
android.AssertStringDoesNotContain(t, "got flag for LTO in variant that doesn't expect it",
|
||||||
|
libFooWithoutLto.Args["ldFlags"], "-flto=thin")
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user