diff options
author | Googler <noreply@google.com> | 2016-06-29 12:55:07 +0000 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2016-06-29 15:40:12 +0000 |
commit | 13fbc2d289fc7249d81556f3ece53301d506fb82 (patch) | |
tree | 47f25a0fb3a3ad81f9ee5be5e796cdb829b9a1d2 /src/main/java/com/google/devtools/build/lib/rules/cpp | |
parent | 3d5fa99455a501acda68f917aae3d01861b5caf0 (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/cpp')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java | 13 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/IncludeScannable.java | 6 |
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. */ |