From 2d01fe28dffd610ce38aea6fe70d3cc00dc9cf3a Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Mon, 21 Sep 2020 01:18:32 +0800 Subject: [PATCH] Introduce LTO property for -fwhole-program-vtables cflag -fwhole-program-vtables cflag requires LTO to be enabled. Some projects add this flag unconditionally, breaking builds that turn off LTO. Make this an LTO property so that build system will handle adding the flag when LTO is on. Test: build Bug: 169004486 Change-Id: Ifce12c09e1d6b8c2807314c3bb982b076efcaaa4 --- cc/lto.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cc/lto.go b/cc/lto.go index 9868cdfb9..e03433731 100644 --- a/cc/lto.go +++ b/cc/lto.go @@ -52,6 +52,9 @@ type LTOProperties struct { // Use clang lld instead of gnu ld. Use_clang_lld *bool + + // Use -fwhole-program-vtables cflag. + Whole_program_vtables *bool } type lto struct { @@ -97,6 +100,10 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags { flags.Local.CFlags = append(flags.Local.CFlags, ltoFlag) flags.Local.LdFlags = append(flags.Local.LdFlags, ltoFlag) + if Bool(lto.Properties.Whole_program_vtables) { + flags.Local.CFlags = append(flags.Local.CFlags, "-fwhole-program-vtables") + } + if ctx.Config().IsEnvTrue("USE_THINLTO_CACHE") && Bool(lto.Properties.Lto.Thin) && lto.useClangLld(ctx) { // Set appropriate ThinLTO cache policy cacheDirFormat := "-Wl,--thinlto-cache-dir="