aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-06-29 12:55:07 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-06-29 15:40:12 +0000
commit13fbc2d289fc7249d81556f3ece53301d506fb82 (patch)
tree47f25a0fb3a3ad81f9ee5be5e796cdb829b9a1d2 /src/main/java/com/google/devtools/build/lib/rules
parent3d5fa99455a501acda68f917aae3d01861b5caf0 (diff)
Fix/work around bad interaction between interface deps and LIPO. Previously looking at the declared include srcs of all transitive deps was sufficient as these contained all headers possibly relevant even with LIPO optimizations. With interface deps, we cut off dependencies (and thus headers) that aren't directly includable. To still make those available to LIPO, we need to also supply the declared include sources coming from lipo scannables.
-- MOS_MIGRATED_REVID=126183112
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/IncludeScannable.java6
2 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
index 5d273fe816..a9083eeb25 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
@@ -738,7 +738,7 @@ public class CppCompileAction extends AbstractAction
// Avoid immutable sets here to limit memory churn.
Set<PathFragment> declaredIncludeDirs = Sets.newHashSet(context.getDeclaredIncludeDirs());
Set<PathFragment> warnIncludeDirs = Sets.newHashSet(context.getDeclaredIncludeWarnDirs());
- Set<Artifact> declaredIncludeSrcs = Sets.newHashSet(context.getDeclaredIncludeSrcs());
+ Set<Artifact> declaredIncludeSrcs = Sets.newHashSet(getDeclaredIncludeSrcs());
for (Artifact input : inputsForValidation) {
if (context.getTransitiveCompilationPrerequisites().contains(input)
|| allowedIncludes.contains(input)) {
@@ -1028,7 +1028,7 @@ public class CppCompileAction extends AbstractAction
private Map<PathFragment, Artifact> getAllowedDerivedInputsMap() {
Map<PathFragment, Artifact> allowedDerivedInputMap = new HashMap<>();
addToMap(allowedDerivedInputMap, mandatoryInputs);
- addToMap(allowedDerivedInputMap, context.getDeclaredIncludeSrcs());
+ addToMap(allowedDerivedInputMap, getDeclaredIncludeSrcs());
addToMap(allowedDerivedInputMap, context.getTransitiveCompilationPrerequisites());
Artifact artifact = getSourceFile();
if (!artifact.isSourceArtifact()) {
@@ -1072,7 +1072,16 @@ public class CppCompileAction extends AbstractAction
* Return explicit header files (i.e., header files explicitly listed). The
* return value may contain duplicate elements.
*/
+ @Override
public NestedSet<Artifact> getDeclaredIncludeSrcs() {
+ if (lipoScannables != null && lipoScannables.iterator().hasNext()) {
+ NestedSetBuilder<Artifact> srcs = NestedSetBuilder.stableOrder();
+ srcs.addTransitive(context.getDeclaredIncludeSrcs());
+ for (IncludeScannable lipoScannable : lipoScannables) {
+ srcs.addTransitive(lipoScannable.getDeclaredIncludeSrcs());
+ }
+ return srcs.build();
+ }
return context.getDeclaredIncludeSrcs();
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/IncludeScannable.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/IncludeScannable.java
index 267a75063e..2c625901ea 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/IncludeScannable.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/IncludeScannable.java
@@ -15,6 +15,7 @@
package com.google.devtools.build.lib.rules.cpp;
import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Collection;
@@ -89,6 +90,11 @@ public interface IncludeScannable {
Collection<Artifact> getIncludeScannerSources();
/**
+ * Returns explicit header files (i.e., header files explicitly listed) of transitive deps.
+ */
+ NestedSet<Artifact> getDeclaredIncludeSrcs();
+
+ /**
* Returns additional scannables that need also be scanned when scanning this
* scannable. May be empty but not null. This is not evaluated recursively.
*/