Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f01658b authored by Yi Kong's avatar Yi Kong
Browse files

Do not set --lto-O0 for optimize_for_size targets

--lto-O0 produces smaller binaries compared to --lto-O2 under -O2.
However under -Oz (the default for optimize_for_size), --lto-O2 actually
produces smaller binaries.

                     --lto-O0       --lto-O2
StatsD               2796856        2673728
libLLVM_android.so   15552712       14595544

Test: m
Change-Id: I33151cfd6abc273c4836418a6d8e0b935db02af4
parent 43c36cad
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -110,7 +110,7 @@ func (lto *lto) flags(ctx ModuleContext, flags Flags) Flags {
		var ltoLdFlags []string
		var ltoLdFlags []string


		// Do not perform costly LTO optimizations for Eng builds.
		// Do not perform costly LTO optimizations for Eng builds.
		if Bool(lto.Properties.Lto_O0) || ctx.optimizeForSize() || ctx.Config().Eng() {
		if Bool(lto.Properties.Lto_O0) || ctx.Config().Eng() {
			ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
			ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
		}
		}