Remove implicit .a and .so outputs from Bazel.

Change CcLibrary to work both with and without declared outputs.

This fixed #61 - header-only libraries now compile on MacOS.

--
MOS_MIGRATED_REVID=99007746
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java
index dc98ac0..cb4778d 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java
@@ -56,7 +56,6 @@
 import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
 import com.google.devtools.build.lib.packages.TriState;
 import com.google.devtools.build.lib.packages.Type;
-import com.google.devtools.build.lib.rules.cpp.CcLibrary;
 import com.google.devtools.build.lib.rules.cpp.CppConfiguration;
 import com.google.devtools.build.lib.rules.cpp.CppFileTypes;
 import com.google.devtools.build.lib.rules.cpp.CppRuleClasses;
@@ -767,25 +766,7 @@
   public static final class CcLibraryRule implements RuleDefinition {
     @Override
     public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
-      SafeImplicitOutputsFunction implicitOutputsFunction = new SafeImplicitOutputsFunction() {
-        @Override
-        public Iterable<String> getImplicitOutputs(AttributeMap rule) {
-          boolean alwaysLink = rule.get("alwayslink", Type.BOOLEAN);
-          boolean linkstatic = rule.get("linkstatic", Type.BOOLEAN);
-          SafeImplicitOutputsFunction staticLib = fromTemplates(
-              alwaysLink
-                  ? "%{dirname}lib%{basename}.lo"
-                  : "%{dirname}lib%{basename}.a");
-          SafeImplicitOutputsFunction allLibs =
-              linkstatic || !CcLibrary.appearsToHaveObjectFiles(rule)
-              ? staticLib
-              : fromFunctions(staticLib, CC_LIBRARY_DYNAMIC_LIB);
-          return allLibs.getImplicitOutputs(rule);
-        }
-      };
-
       return builder
-          .setImplicitOutputsFunction(implicitOutputsFunction)
           // TODO: Google cc_library overrides documentation for:
           // deps, data, linkopts, defines, srcs; override here too?
 
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java
index 62d3dd7..7b7cc07 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java
@@ -31,6 +31,7 @@
 import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
 import com.google.devtools.build.lib.collect.nestedset.Order;
 import com.google.devtools.build.lib.packages.AttributeMap;
+import com.google.devtools.build.lib.packages.ImplicitOutputsFunction;
 import com.google.devtools.build.lib.packages.RawAttributeMapper;
 import com.google.devtools.build.lib.packages.Type;
 import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;
@@ -132,8 +133,11 @@
         .enableInterfaceSharedObjects()
         .enableCompileProviders()
         // Generate .a and .so outputs even without object files to fulfill the rule class contract
-        // wrt. implicit output files.
-        .setGenerateLinkActionsIfEmpty(true)
+        // wrt. implicit output files, if the contract says so. Behavior here differs between Bazel
+        // and Blaze.
+        .setGenerateLinkActionsIfEmpty(
+            ruleContext.getRule().getRuleClassObject().getImplicitOutputsFunction()
+                != ImplicitOutputsFunction.NONE)
         .setNeverLink(neverLink)
         .setHeadersCheckingMode(common.determineHeadersCheckingMode())
         .addCopts(common.getCopts())
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index f35d2bb..240dc97 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -1,16 +1,11 @@
 package(default_visibility = ["//visibility:public"])
 
-# TODO(bazel-team): The MacOS tools give an error if there is no object file on
-# the command line to libtool, so we use an empty .cc file here. We should find
-# a better way to handle this case.
 cc_library(
     name = "malloc",
-    srcs = ["empty.cc"],
 )
 
 cc_library(
     name = "stl",
-    srcs = ["empty.cc"],
 )
 
 filegroup(
diff --git a/tools/cpp/empty.cc b/tools/cpp/empty.cc
deleted file mode 100644
index 7309f1c..0000000
--- a/tools/cpp/empty.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2014 Google Inc. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-//
-// Workaround for the problem that MacOS tools give an error if there is no
-// object file on the command line.
-//