From 7df8c4c54fe26af6967e9e4de6eaff50851d3238 Mon Sep 17 00:00:00 2001 From: jingwen Date: Fri, 9 Feb 2018 15:37:21 -0800 Subject: Automated rollback of commit 873f343fefbb08048e7e75c482843b9e68954de6. *** Reason for rollback *** Breaking targets in 2018.02.08 and 2018.02.09 nightly TGPs There were some merge conflicts in this rollback CL. See unknown commit for the unresolved version. I kept the YOURS sections, and ran fiximports.py to remove unused imports. See b/73157879 *** Original change description *** C++: Remove last instatiation of CppModel outside CcLibraryHelper. This is the second try for this CL. The first one caused Blaze to crash when building Exoblaze as shown in b/72936965. In this CL I fix the condition of when to generate non-PIC compilation actions for WrapCcHelper. RELNOTES:none PiperOrigin-RevId: 185203398 --- .../com/google/devtools/build/lib/rules/cpp/CppModel.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java index 34c625b5b9..ff84f58e1b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java @@ -185,6 +185,7 @@ public final class CppModel { private final CoptsFilter coptsFilter; private boolean fake; private boolean maySaveTemps; + private boolean onlySingleOutput; private CcCompilationOutputs compilationOutputs; // link model @@ -274,6 +275,17 @@ public final class CppModel { return this; } + /** + * If set, the CppModel only creates a single .o output that can be linked into a dynamic library, + * i.e., it never generates both PIC and non-PIC outputs. Otherwise it creates outputs that can be + * linked into both static binaries and dynamic libraries (if both require PIC or both require + * non-PIC, then it still only creates a single output). Defaults to false. + */ + public CppModel setOnlySingleOutput(boolean onlySingleOutput) { + this.onlySingleOutput = onlySingleOutput; + return this; + } + /** * Whether to create actions for temps. This defaults to false. */ @@ -466,7 +478,7 @@ public final class CppModel { // Either you're only making a dynamic library (onlySingleOutput) or pic should be used // in all cases. - if (usePicForBinaries) { + if (onlySingleOutput || usePicForBinaries) { if (picFeatureEnabled) { return false; } -- cgit v1.2.3