aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/packages
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-11-30 13:03:50 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-11-30 13:05:59 -0800
commit8c5e290dfab3cab378a9ca107ecdd6267403cd4b (patch)
treefa353656eed2053e167ab18d8c89e27085616000 /src/test/java/com/google/devtools/build/lib/packages
parent5ddd804fac00ea075fbbafaa5aff9c0ecf56bc42 (diff)
Suppress ThinLTO indexing for linkstatic tests
ThinLTO and static linking of test suites is a bad combination since it results in a combinatorial explosion of the ThinLTO backends - each object file needs a separate LTO backend action per target. If you are static linking O(N) objects, and have O(M) targets, with ThinLTO you will get O(N*M) LTO backend jobs. This is because the whole program optimization step is per-target, and may make different decisions affecting the object files. With dynamic linking it isn't a problem, since the ThinLTO optimization happens at the .so level, which are shared across tests. And for statically-linked cc_binary it hasn't been an issue since typically only a single target is built at a time, unlike tests. In general it isn't incredibly useful to run tests with ThinLTO, although most projects are in the habit of running their tests with the same options that they use to optimize their main binary (and most blueprints seem to be set up to share options between them). With ThinLTO since it is doing whole-program optimization, you are getting different whole-program optimizations for the main binary and each test binary, so it isn't the case that this will optimize the tests in the same exact way as the main binary anyway. Therefore, when creating LTO backends for statically-linked *_test targets, skip the LTO indexing stage, and create (or use if already created) shared dummy LTO backend actions for each library. These LTO backends are fed an empty index, so they don't do any whole program optimization and are safe to share. Enable this under a new feature so that we can enable it by default via blazerc but provide a facility to disable if needed. RELNOTES: None PiperOrigin-RevId: 177495858
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/packages')
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java
index 96fb665de9..326539f231 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java
@@ -355,6 +355,9 @@ public abstract class MockCcSupport {
+ " }"
+ "}";
+ public static final String THIN_LTO_LINKSTATIC_TESTS_USE_SHARED_NONLTO_BACKENDS_CONFIGURATION =
+ "" + "feature { name: 'thin_lto_linkstatic_tests_use_shared_nonlto_backends'}";
+
public static final String AUTO_FDO_CONFIGURATION =
""
+ "feature {"