From 303b687622bd16e5dec72ad4f503047ae91f45ba Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 13 Jul 2016 20:10:42 +0000 Subject: Add host/target feature support for ThinLTO ThinLTO isn't fully supported for host builds, in order to handle this add support for enabling either a 'host' or 'target' feature in the configuration. The thin_lto feature will require the new 'target' configuration. Companion crosstool change: unknown commit. -- MOS_MIGRATED_REVID=127350506 --- .../google/devtools/build/lib/rules/cpp/CcCommon.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules') diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java index a4cecb798e..684ac7a062 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java @@ -501,6 +501,14 @@ public final class CcCommon { withBaselineCoverage); } + private static String getHostOrNonHostFeature(RuleContext ruleContext) { + if (ruleContext.getConfiguration().isHostConfiguration()) { + return "host"; + } else { + return "nonhost"; + } + } + /** * Creates the feature configuration for a given rule. * @@ -530,9 +538,12 @@ public final class CcCommon { } Set unsupportedFeatures = unsupportedFeaturesBuilder.build(); ImmutableSet.Builder requestedFeatures = ImmutableSet.builder(); - for (String feature : Iterables.concat( - ImmutableSet.of(toolchain.getCompilationMode().toString()), DEFAULT_FEATURES, - ruleContext.getFeatures())) { + for (String feature : + Iterables.concat( + ImmutableSet.of(toolchain.getCompilationMode().toString()), + ImmutableSet.of(getHostOrNonHostFeature(ruleContext)), + DEFAULT_FEATURES, + ruleContext.getFeatures())) { if (!unsupportedFeatures.contains(feature)) { requestedFeatures.add(feature); } -- cgit v1.2.3