aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java
diff options
context:
space:
mode:
authorGravatar plf <plf@google.com>2018-01-12 08:20:57 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-12 08:26:39 -0800
commit849cec256c606db47dc179c788f937d7482087ae (patch)
treed18b7131493c353c78103c1f573868216b0d817b /src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java
parent38f815c2c8a4bc4d6cf79d366d200e37fa0935f3 (diff)
C++: Only call link() in cc_binary when linkCompileOutputSeparately is true.
Also rename setLinkType() to setStaticLinkType() in CcLibraryHelper to make it clear that we are setting the specific linking type for the static library. This is an improved version of https://github.com/bazelbuild/bazel/commit/a705eaa9225ff8a03975c8cb49faa6b2899e398d which was rolled back due to a previous conflicting CL causing problems in the nightly. RELNOTES:none PiperOrigin-RevId: 181746447
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java
index b67b6e1330..103a083024 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java
@@ -838,8 +838,8 @@ public final class CcLibraryHelper {
* by the linker even if they are not otherwise used. This is useful for libraries that register
* themselves somewhere during initialization.
*
- * <p>This only sets the link type (see {@link #setLinkType}), either to a static library or to
- * an alwayslink static library (blaze uses a different file extension to signal alwayslink to
+ * <p>This only sets the link type (see {@link #setStaticLinkType}), either to a static library or
+ * to an alwayslink static library (blaze uses a different file extension to signal alwayslink to
* downstream code).
*/
public CcLibraryHelper setAlwayslink(boolean alwayslink) {
@@ -853,8 +853,10 @@ public final class CcLibraryHelper {
* Directly set the link type. This can be used instead of {@link #setAlwayslink}. Setting
* anything other than a static link causes this class to skip the link action creation.
*/
- public CcLibraryHelper setLinkType(LinkTargetType linkType) {
- this.linkType = Preconditions.checkNotNull(linkType);
+ public CcLibraryHelper setStaticLinkType(LinkTargetType linkType) {
+ Preconditions.checkNotNull(linkType);
+ Preconditions.checkState(linkType.staticness() == Staticness.STATIC);
+ this.linkType = linkType;
return this;
}