diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java index 0283eebbda4448..536f95b414daa4 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java @@ -40,6 +40,19 @@ public class BazelRulesModule extends BlazeModule { /** This is where deprecated options go to die. */ public static class GraveyardOptions extends OptionsBase { + @Option( + name = "incompatible_disable_cc_toolchain_label_from_crosstool_proto", + defaultValue = "true", + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.EAGERNESS_TO_EXIT}, + metadataTags = { + OptionMetadataTag.DEPRECATED, + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, + help = "Deprecated no-op.") + public boolean disableCcToolchainFromCrosstool; + @Option( name = "incompatible_disable_cc_configuration_make_variables", defaultValue = "true", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r10e/AndroidNdkCrosstoolsR10e.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r10e/AndroidNdkCrosstoolsR10e.java index c8bb6251d76e66..7fcaad25fb71c5 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r10e/AndroidNdkCrosstoolsR10e.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r10e/AndroidNdkCrosstoolsR10e.java @@ -15,15 +15,12 @@ package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r10e; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * Generates a CrosstoolRelease proto for the Android NDK. @@ -46,7 +43,6 @@ static CrosstoolRelease create(NdkPaths ndkPaths, StlImpl stlImpl, String hostPl .setMajorVersion("android") .setMinorVersion("") .setDefaultTargetCpu("armeabi") - .addAllDefaultToolchain(getDefaultCpuToolchains(stlImpl)) .addAllToolchain(createToolchains(ndkPaths, stlImpl, hostPlatform)) .build(); } @@ -77,36 +73,4 @@ private static ImmutableList createToolchains( return toolchains.build(); } - - private static ImmutableList getDefaultCpuToolchains(StlImpl stlImpl) { - // TODO(bazel-team): It would be better to auto-generate this somehow. - - ImmutableMap defaultCpus = ImmutableMap.builder() - // arm - .put("armeabi", "arm-linux-androideabi-4.9") - .put("armeabi-v7a", "arm-linux-androideabi-4.9-v7a") - .put("armeabi-v7a-hard", "arm-linux-androideabi-4.9-v7a-hard") - .put("armeabi-thumb", "arm-linux-androideabi-4.9-thumb") - .put("armeabi-v7a-thumb", "arm-linux-androideabi-4.9-v7a-thumb") - .put("armeabi-v7a-hard-thumb", "arm-linux-androideabi-4.9-v7a-hard-thumb") - .put("arm64-v8a", "aarch64-linux-android-4.9") - - // mips - .put("mips", "mipsel-linux-android-4.9") - .put("mips64", "mips64el-linux-android-4.9") - - // x86 - .put("x86", "x86-4.9") - .put("x86_64", "x86_64-4.9") - .build(); - - ImmutableList.Builder defaultCpuToolchains = ImmutableList.builder(); - for (Map.Entry defaultCpu : defaultCpus.entrySet()) { - defaultCpuToolchains.add(DefaultCpuToolchain.newBuilder() - .setCpu(defaultCpu.getKey()) - .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()) - .build()); - } - return defaultCpuToolchains.build(); - } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r11/AndroidNdkCrosstoolsR11.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r11/AndroidNdkCrosstoolsR11.java index b10911051c4ff0..c9643b6ad2d49c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r11/AndroidNdkCrosstoolsR11.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r11/AndroidNdkCrosstoolsR11.java @@ -15,15 +15,12 @@ package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r11; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * Generates a CrosstoolRelease proto for the Android NDK. @@ -49,7 +46,6 @@ public static CrosstoolRelease create(NdkPaths ndkPaths, StlImpl stlImpl, String .setMajorVersion("android") .setMinorVersion("") .setDefaultTargetCpu("armeabi") - .addAllDefaultToolchain(getDefaultCpuToolchains(stlImpl)) .addAllToolchain(createToolchains(ndkPaths, stlImpl, hostPlatform)) .build(); } @@ -80,36 +76,4 @@ private static ImmutableList createToolchains( return toolchains.build(); } - - private static ImmutableList getDefaultCpuToolchains(StlImpl stlImpl) { - // TODO(bazel-team): It would be better to auto-generate this somehow. - - ImmutableMap defaultCpus = ImmutableMap.builder() - // arm - .put("armeabi", "arm-linux-androideabi-4.9") - .put("armeabi-v7a", "arm-linux-androideabi-4.9-v7a") - .put("armeabi-v7a-hard", "arm-linux-androideabi-4.9-v7a-hard") - .put("armeabi-thumb", "arm-linux-androideabi-4.9-thumb") - .put("armeabi-v7a-thumb", "arm-linux-androideabi-4.9-v7a-thumb") - .put("armeabi-v7a-hard-thumb", "arm-linux-androideabi-4.9-v7a-hard-thumb") - .put("arm64-v8a", "aarch64-linux-android-4.9") - - // mips - .put("mips", "mipsel-linux-android-4.9") - .put("mips64", "mips64el-linux-android-4.9") - - // x86 - .put("x86", "x86-4.9") - .put("x86_64", "x86_64-4.9") - .build(); - - ImmutableList.Builder defaultCpuToolchains = ImmutableList.builder(); - for (Map.Entry defaultCpu : defaultCpus.entrySet()) { - defaultCpuToolchains.add(DefaultCpuToolchain.newBuilder() - .setCpu(defaultCpu.getKey()) - .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()) - .build()); - } - return defaultCpuToolchains.build(); - } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r12/AndroidNdkCrosstoolsR12.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r12/AndroidNdkCrosstoolsR12.java index 335e54ecd234b0..25ab9c9b2ec2a1 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r12/AndroidNdkCrosstoolsR12.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r12/AndroidNdkCrosstoolsR12.java @@ -15,15 +15,12 @@ package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r12; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** Generates a CrosstoolRelease proto for the Android NDK. */ final class AndroidNdkCrosstoolsR12 { @@ -46,7 +43,6 @@ static CrosstoolRelease create(NdkPaths ndkPaths, StlImpl stlImpl, String hostPl .setMajorVersion("android") .setMinorVersion("") .setDefaultTargetCpu("armeabi") - .addAllDefaultToolchain(getDefaultCpuToolchains(stlImpl)) .addAllToolchain(createToolchains(ndkPaths, stlImpl, hostPlatform)) .build(); } @@ -77,34 +73,4 @@ private static ImmutableList createToolchains( return toolchains.build(); } - - private static ImmutableList getDefaultCpuToolchains(StlImpl stlImpl) { - // TODO(bazel-team): It would be better to auto-generate this somehow. - - ImmutableMap defaultCpus = - ImmutableMap.builder() - // arm - .put("armeabi", "arm-linux-androideabi-4.9") - .put("armeabi-v7a", "arm-linux-androideabi-4.9-v7a") - .put("arm64-v8a", "aarch64-linux-android-4.9") - - // mips - .put("mips", "mipsel-linux-android-4.9") - .put("mips64", "mips64el-linux-android-4.9") - - // x86 - .put("x86", "x86-4.9") - .put("x86_64", "x86_64-4.9") - .build(); - - ImmutableList.Builder defaultCpuToolchains = ImmutableList.builder(); - for (Map.Entry defaultCpu : defaultCpus.entrySet()) { - defaultCpuToolchains.add( - DefaultCpuToolchain.newBuilder() - .setCpu(defaultCpu.getKey()) - .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()) - .build()); - } - return defaultCpuToolchains.build(); - } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r13/AndroidNdkCrosstoolsR13.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r13/AndroidNdkCrosstoolsR13.java index 0348b004ab946a..3ee5b71e144aea 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r13/AndroidNdkCrosstoolsR13.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r13/AndroidNdkCrosstoolsR13.java @@ -15,15 +15,12 @@ package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r13; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** Generates a CrosstoolRelease proto for the Android NDK. */ final class AndroidNdkCrosstoolsR13 { @@ -44,7 +41,6 @@ static CrosstoolRelease create( .setMajorVersion("android") .setMinorVersion("") .setDefaultTargetCpu("armeabi") - .addAllDefaultToolchain(getDefaultCpuToolchains(stlImpl)) .addAllToolchain(createToolchains(ndkPaths, stlImpl, hostPlatform, clangVersion)) .build(); } @@ -76,34 +72,4 @@ private static ImmutableList createToolchains( return toolchains.build(); } - - private static ImmutableList getDefaultCpuToolchains(StlImpl stlImpl) { - // TODO(bazel-team): It would be better to auto-generate this somehow. - - ImmutableMap defaultCpus = - ImmutableMap.builder() - // arm - .put("armeabi", "arm-linux-androideabi-clang3.8") - .put("armeabi-v7a", "arm-linux-androideabi-clang3.8-v7a") - .put("arm64-v8a", "aarch64-linux-android-clang3.8") - - // mips - .put("mips", "mipsel-linux-android-clang3.8") - .put("mips64", "mips64el-linux-android-clang3.8") - - // x86 - .put("x86", "x86-clang3.8") - .put("x86_64", "x86_64-clang3.8") - .build(); - - ImmutableList.Builder defaultCpuToolchains = ImmutableList.builder(); - for (Map.Entry defaultCpu : defaultCpus.entrySet()) { - defaultCpuToolchains.add( - DefaultCpuToolchain.newBuilder() - .setCpu(defaultCpu.getKey()) - .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()) - .build()); - } - return defaultCpuToolchains.build(); - } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r15/AndroidNdkCrosstoolsR15.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r15/AndroidNdkCrosstoolsR15.java index 91dd384c28c974..16a1a142085a22 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r15/AndroidNdkCrosstoolsR15.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r15/AndroidNdkCrosstoolsR15.java @@ -15,15 +15,12 @@ package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r15; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** Generates a CrosstoolRelease proto for the Android NDK. */ final class AndroidNdkCrosstoolsR15 { @@ -44,7 +41,6 @@ static CrosstoolRelease create( .setMajorVersion("android") .setMinorVersion("") .setDefaultTargetCpu("armeabi") - .addAllDefaultToolchain(getDefaultCpuToolchains(stlImpl, clangVersion)) .addAllToolchain(createToolchains(ndkPaths, stlImpl, hostPlatform, clangVersion)) .build(); } @@ -82,35 +78,4 @@ private static ImmutableList createToolchains( return toolchains.build(); } - - private static ImmutableList getDefaultCpuToolchains( - StlImpl stlImpl, String clangVersion) { - // TODO(bazel-team): It would be better to auto-generate this somehow. - - ImmutableMap defaultCpus = - ImmutableMap.builder() - // arm - .put("armeabi", "arm-linux-androideabi-clang" + clangVersion) - .put("armeabi-v7a", "arm-linux-androideabi-clang" + clangVersion + "-v7a") - .put("arm64-v8a", "aarch64-linux-android-clang" + clangVersion) - - // mips - .put("mips", "mipsel-linux-android-clang" + clangVersion) - .put("mips64", "mips64el-linux-android-clang" + clangVersion) - - // x86 - .put("x86", "x86-clang" + clangVersion) - .put("x86_64", "x86_64-clang" + clangVersion) - .build(); - - ImmutableList.Builder defaultCpuToolchains = ImmutableList.builder(); - for (Map.Entry defaultCpu : defaultCpus.entrySet()) { - defaultCpuToolchains.add( - DefaultCpuToolchain.newBuilder() - .setCpu(defaultCpu.getKey()) - .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()) - .build()); - } - return defaultCpuToolchains.build(); - } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/AndroidNdkCrosstoolsR17.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/AndroidNdkCrosstoolsR17.java index fca2b82a09f294..7df9e1aabb4a73 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/AndroidNdkCrosstoolsR17.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/AndroidNdkCrosstoolsR17.java @@ -15,15 +15,12 @@ package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r17; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** Generates a CrosstoolRelease proto for the Android NDK. */ final class AndroidNdkCrosstoolsR17 { @@ -44,7 +41,6 @@ static CrosstoolRelease create( .setMajorVersion("android") .setMinorVersion("") .setDefaultTargetCpu("armeabi") - .addAllDefaultToolchain(getDefaultCpuToolchains(stlImpl, clangVersion)) .addAllToolchain(createToolchains(ndkPaths, stlImpl, hostPlatform, clangVersion)) .build(); } @@ -80,30 +76,4 @@ private static ImmutableList createToolchains( return toolchains.build(); } - - private static ImmutableList getDefaultCpuToolchains( - StlImpl stlImpl, String clangVersion) { - // TODO(bazel-team): It would be better to auto-generate this somehow. - - ImmutableMap defaultCpus = - ImmutableMap.builder() - // arm - .put("armeabi-v7a", "arm-linux-androideabi-clang" + clangVersion + "-v7a") - .put("arm64-v8a", "aarch64-linux-android-clang" + clangVersion) - - // x86 - .put("x86", "x86-clang" + clangVersion) - .put("x86_64", "x86_64-clang" + clangVersion) - .build(); - - ImmutableList.Builder defaultCpuToolchains = ImmutableList.builder(); - for (Map.Entry defaultCpu : defaultCpus.entrySet()) { - defaultCpuToolchains.add( - DefaultCpuToolchain.newBuilder() - .setCpu(defaultCpu.getKey()) - .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()) - .build()); - } - return defaultCpuToolchains.build(); - } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r18/AndroidNdkCrosstoolsR18.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r18/AndroidNdkCrosstoolsR18.java index 7f241986e383cb..8448cb65a448e5 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r18/AndroidNdkCrosstoolsR18.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r18/AndroidNdkCrosstoolsR18.java @@ -15,15 +15,12 @@ package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r18; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** Generates a CrosstoolRelease proto for the Android NDK. */ final class AndroidNdkCrosstoolsR18 { @@ -44,7 +41,6 @@ static CrosstoolRelease create( .setMajorVersion("android") .setMinorVersion("") .setDefaultTargetCpu("armeabi") - .addAllDefaultToolchain(getDefaultCpuToolchains(stlImpl, clangVersion)) .addAllToolchain(createToolchains(ndkPaths, stlImpl, hostPlatform, clangVersion)) .build(); } @@ -79,30 +75,4 @@ private static ImmutableList createToolchains( return toolchains.build(); } - - private static ImmutableList getDefaultCpuToolchains( - StlImpl stlImpl, String clangVersion) { - // TODO(bazel-team): It would be better to auto-generate this somehow. - - ImmutableMap defaultCpus = - ImmutableMap.builder() - // arm - .put("armeabi-v7a", "arm-linux-androideabi-clang" + clangVersion + "-v7a") - .put("arm64-v8a", "aarch64-linux-android-clang" + clangVersion) - - // x86 - .put("x86", "x86-clang" + clangVersion) - .put("x86_64", "x86_64-clang" + clangVersion) - .build(); - - ImmutableList.Builder defaultCpuToolchains = ImmutableList.builder(); - for (Map.Entry defaultCpu : defaultCpus.entrySet()) { - defaultCpuToolchains.add( - DefaultCpuToolchain.newBuilder() - .setCpu(defaultCpu.getKey()) - .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()) - .build()); - } - return defaultCpuToolchains.build(); - } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CToolchainSelectionUtils.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CToolchainSelectionUtils.java index 349617966312ec..3fe7927faa54b1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CToolchainSelectionUtils.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CToolchainSelectionUtils.java @@ -201,38 +201,14 @@ private static CToolchain selectToolchainUsingCpuAndMaybeCompiler( } } } - String selectedIdentifier = null; - for (CrosstoolConfig.DefaultCpuToolchain selector : release.getDefaultToolchainList()) { - if (selector.getCpu().equals(config.getCpu())) { - selectedIdentifier = selector.getToolchainIdentifier(); - break; - } - } - - if (selectedIdentifier == null) { - StringBuilder errorMessageBuilder = new StringBuilder(); - errorMessageBuilder - .append("No toolchain found for cpu '") - .append(config.getCpu()) - .append("'. Valid toolchains are: "); - describeToolchainList(errorMessageBuilder, release.getToolchainList()); - throw new InvalidConfigurationException(errorMessageBuilder.toString()); - } - checkToolchain(selectedIdentifier); - - for (CToolchain toolchain : release.getToolchainList()) { - if (toolchain.getToolchainIdentifier().equals(selectedIdentifier)) { - return toolchain; - } - } - throw new InvalidConfigurationException( - "Inconsistent crosstool configuration; no toolchain " - + "corresponding to '" - + selectedIdentifier - + "' found for cpu '" - + config.getCpu() - + "'"); + StringBuilder errorMessageBuilder = new StringBuilder(); + errorMessageBuilder + .append("No toolchain found for cpu '") + .append(config.getCpu()) + .append("'. Valid toolchains are: "); + describeToolchainList(errorMessageBuilder, release.getToolchainList()); + throw new InvalidConfigurationException(errorMessageBuilder.toString()); } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuite.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuite.java index 3873110cd512f5..b308274257f1b5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuite.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuite.java @@ -13,7 +13,6 @@ // limitations under the License. package com.google.devtools.build.lib.rules.cpp; -import static com.google.devtools.build.lib.rules.cpp.CrosstoolConfigurationLoader.toReleaseConfiguration; import com.google.common.base.Preconditions; import com.google.devtools.build.lib.actions.Artifact; @@ -29,17 +28,10 @@ import com.google.devtools.build.lib.analysis.RunfilesProvider; import com.google.devtools.build.lib.analysis.TemplateVariableInfo; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; -import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; import com.google.devtools.build.lib.analysis.platform.ToolchainInfo; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.packages.BuildType; -import com.google.devtools.build.lib.rules.cpp.CcSkyframeSupportFunction.CcSkyframeSupportException; -import com.google.devtools.build.lib.syntax.Type; -import com.google.devtools.build.lib.util.StringUtil; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.skyframe.SkyFunction; -import com.google.devtools.build.skyframe.SkyKey; import java.util.Map; /** @@ -76,26 +68,6 @@ public ConfiguredTarget create(RuleContext ruleContext) Map toolchains = ruleContext.attributes().get("toolchains", BuildType.LABEL_DICT_UNARY); Label selectedCcToolchain = toolchains.get(key); - if (selectedCcToolchain == null && !cppConfiguration.disableCcToolchainFromCrosstool()) { - try { - CrosstoolRelease crosstoolRelease = getCrosstoolRelease(ruleContext); - if (crosstoolRelease == null) { - // Skyframe restart - return null; - } - selectedCcToolchain = - CppConfigurationLoader.selectCcToolchainLabelUsingCrosstool( - transformedCpu, - compiler, - ruleContext.getLabel(), - toolchains, - crosstoolRelease, - /* usingCrosstoolForToolchainSelectionDisabled= */ false); - } catch (InvalidConfigurationException e) { - ruleContext.throwWithRuleError(e.getMessage()); - } - } - CcToolchainProvider ccToolchainProvider; PlatformConfiguration platformConfig = Preconditions.checkNotNull(ruleContext.getFragment(PlatformConfiguration.class)); @@ -172,42 +144,12 @@ private T selectCcToolchain( String errorMessage = String.format( - "cc_toolchain_suite '%s' does not contain a toolchain for CPU '%s'", + "cc_toolchain_suite '%s' does not contain a toolchain for cpu '%s'", ruleContext.getLabel(), cpu); if (compiler != null) { - errorMessage = errorMessage + " and compiler " + compiler; + errorMessage = errorMessage + " and compiler '" + compiler + "'."; } ruleContext.throwWithRuleError(errorMessage); throw new IllegalStateException("Should not be reached"); } - - private CrosstoolRelease getCrosstoolRelease(RuleContext ruleContext) - throws InvalidConfigurationException, InterruptedException, RuleErrorException { - String protoAttribute = ruleContext.attributes().get("proto", Type.STRING); - if (StringUtil.emptyToNull(protoAttribute) != null) { - return toReleaseConfiguration( - "cc_toolchain_suite rule " + ruleContext.getLabel(), - () -> protoAttribute, - /* digestOrNull= */ null); - } - - SkyKey ccSupportKey = - CcSkyframeSupportValue.key( - /* fdoZipPath= */ null, ruleContext.getLabel().getPackageIdentifier()); - - SkyFunction.Environment skyframeEnv = ruleContext.getAnalysisEnvironment().getSkyframeEnv(); - CcSkyframeSupportValue ccSkyframeSupportValue; - try { - ccSkyframeSupportValue = - (CcSkyframeSupportValue) - skyframeEnv.getValueOrThrow(ccSupportKey, CcSkyframeSupportException.class); - } catch (CcSkyframeSupportException e) { - ruleContext.throwWithRuleError(e.getMessage()); - throw new IllegalStateException("Should not be reached"); - } - if (skyframeEnv.valuesMissing()) { - return null; - } - return ccSkyframeSupportValue.getCrosstoolRelease(); - } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index 8c7a8b342e8eb6..fc0bfa2cd22ec5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java @@ -680,9 +680,6 @@ public boolean disableLinkingModeFlags() { return cppOptions.disableLinkingModeFlags; } - public boolean disableCcToolchainFromCrosstool() { - return cppOptions.disableCcToolchainFromCrosstool; - } /** * cc_toolchain_suite allows to override CROSSTOOL by using proto attribute. This attribute value * is stored here so cc_toolchain can access it in the analysis. Don't use this for anything, it diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java index 7c1aab25e18ef0..9a5504422293db 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java @@ -161,7 +161,6 @@ protected CppConfigurationParameters createParameters( cppOptions, crosstoolTopLabel, (Rule) crosstoolTop, - crosstoolRelease, transformedCpu, key); @@ -268,7 +267,6 @@ private Label selectCcToolchainLabel( CppOptions cppOptions, Label crosstoolTopLabel, Rule crosstoolTop, - CrosstoolRelease crosstoolRelease, String transformedCpu, String key) throws InvalidConfigurationException { @@ -277,16 +275,6 @@ private Label selectCcToolchainLabel( NonconfigurableAttributeMapper.of(crosstoolTop) .get("toolchains", BuildType.LABEL_DICT_UNARY); Label ccToolchainLabel = toolchains.get(key); - if (ccToolchainLabel == null) { - ccToolchainLabel = - selectCcToolchainLabelUsingCrosstool( - transformedCpu, - compiler, - crosstoolTopLabel, - toolchains, - crosstoolRelease, - cppOptions.disableCcToolchainFromCrosstool); - } if (ccToolchainLabel == null) { throw new InvalidConfigurationException( getMissingCcToolchainErrorMessage(crosstoolTopLabel, transformedCpu, compiler)); @@ -298,49 +286,14 @@ static String getMissingCcToolchainErrorMessage( Label crosstoolTopLabel, String transformedCpu, String compiler) { String errorMessage = String.format( - "cc_toolchain_suite '%s' does not contain a toolchain for CPU '%s'", + "cc_toolchain_suite '%s' does not contain a toolchain for cpu '%s'", crosstoolTopLabel, transformedCpu); if (compiler != null) { - errorMessage = errorMessage + " and compiler " + compiler; + errorMessage = errorMessage + " and compiler '" + compiler + "'."; } return errorMessage; } - static Label selectCcToolchainLabelUsingCrosstool( - String cpu, - String compiler, - Label crosstoolTopLabel, - Map toolchains, - CrosstoolRelease crosstoolRelease, - boolean usingCrosstoolForToolchainSelectionDisabled) - throws InvalidConfigurationException { - // If the cc_toolchain_suite does not contain entry for --cpu|--compiler (or only --cpu if - // --compiler is not present) we select the toolchain by looping through all the toolchains - // in the CROSSTOOL file and selecting the one that matches --cpu (and --compiler, if - // present). Then we use the toolchain.target_cpu|toolchain.compiler key to get the - // cc_toolchain label. - CToolchain toolchain = - CToolchainSelectionUtils.selectCToolchain( - /* identifierAttribute= */ null, - /* cpuAttribute= */ null, - /* compilerAttribute= */ null, - cpu, - compiler, - crosstoolRelease); - if (usingCrosstoolForToolchainSelectionDisabled) { - throw new InvalidConfigurationException( - getMissingCcToolchainErrorMessage(crosstoolTopLabel, cpu, compiler) - + String.format( - ", you may want to add an entry for '%s|%s' into toolchains and " - + "toolchain_identifier '%s' into the corresponding cc_toolchain rule " - + "(see --incompatible_disable_cc_toolchain_label_from_crosstool_proto).", - toolchain.getTargetCpu(), - toolchain.getCompiler(), - toolchain.getToolchainIdentifier())); - } - return toolchains.get(toolchain.getTargetCpu() + "|" + toolchain.getCompiler()); - } - @Nullable public static Label getSysrootLabel(CToolchain toolchain, Label libcTopLabel) throws InvalidConfigurationException { diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index 939709bf193ecd..9a839bb1cc816c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -744,19 +744,6 @@ public Label getFdoPrefetchHintsLabel() { + "the responsibility of the C++ toolchain to append this flag.") public boolean disableEmittingStaticLibgcc; - @Option( - name = "incompatible_disable_cc_toolchain_label_from_crosstool_proto", - defaultValue = "true", - documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, - effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.EAGERNESS_TO_EXIT}, - metadataTags = { - OptionMetadataTag.EXPERIMENTAL, - OptionMetadataTag.INCOMPATIBLE_CHANGE, - OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES - }, - help = "If true, Bazel will not use the CROSSTOOL file to select the cc_toolchain label.") - public boolean disableCcToolchainFromCrosstool; - @Option( name = "experimental_enable_cc_toolchain_config_info", defaultValue = "false", diff --git a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java index 54c04f4bee7a28..e10aaae9f06d03 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java @@ -131,7 +131,7 @@ public void testInvalidCpu() throws Exception { create("--cpu=bogus"); fail(); } catch (InvalidConfigurationException e) { - assertThat(e).hasMessageThat().startsWith("No toolchain found for cpu 'bogus'"); + assertThat(e).hasMessageThat().contains("does not contain a toolchain for cpu 'bogus'"); } } diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstoolsTest.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstoolsTest.java index 5c9d1f5a400352..7e723c08d80ba0 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstoolsTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstoolsTest.java @@ -30,13 +30,10 @@ import com.google.devtools.build.lib.util.ResourceFileLoader; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.ToolPath; import java.io.IOException; import java.util.Collection; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -249,22 +246,6 @@ public void testAllToolchainsHaveRuntimesFilegroup() { } } - @Test - public void testDefaultToolchainsExist() { - - for (CrosstoolRelease crosstool : crosstoolReleases) { - - Set toolchainNames = new HashSet<>(); - for (CToolchain toolchain : crosstool.getToolchainList()) { - toolchainNames.add(toolchain.getToolchainIdentifier()); - } - - for (DefaultCpuToolchain defaultCpuToolchain : crosstool.getDefaultToolchainList()) { - assertThat(toolchainNames).contains(defaultCpuToolchain.getToolchainIdentifier()); - } - } - } - /** * Tests that each (cpu, compiler, glibc) triple in each crosstool is unique in that crosstool. */ diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java index df67ee6712ce40..9cfc91dca2407c 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java @@ -121,7 +121,7 @@ public void testAndroidSplitTransitionWithInvalidCpu() throws Exception { assertThrows(AssertionError.class, () -> getConfiguredTarget("//test/skylark:test")); assertThat(noToolchainError) .hasMessageThat() - .contains("No toolchain found for cpu 'doesnotexist'"); + .contains("does not contain a toolchain for cpu 'doesnotexist'"); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationHelper.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationHelper.java index ada901e6ebb00c..ca775228d020a3 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationHelper.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationHelper.java @@ -20,7 +20,6 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig; -import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.ToolPath; import com.google.protobuf.TextFormat; import java.io.IOException; @@ -83,11 +82,7 @@ public static CrosstoolConfig.CrosstoolRelease simpleCompleteToolchainProto() { CrosstoolConfig.CrosstoolRelease.newBuilder() .setMajorVersion("12") .setMinorVersion("0") - .setDefaultTargetCpu(defaultCpu()) - .addDefaultToolchain( - DefaultCpuToolchain.newBuilder() - .setCpu(defaultCpu()) - .setToolchainIdentifier(defaultCpu() + "-toolchain")); + .setDefaultTargetCpu(defaultCpu()); CrosstoolConfig.CToolchain.Builder toolchainBuilder = newIncompleteToolchain(); toolchainBuilder .setToolchainIdentifier(defaultCpu() + "-toolchain") diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java index 7c417c1154f015..66a8e141fa669f 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java @@ -694,17 +694,8 @@ public void testToolchainSelection() throws Exception { fail("Expected an error that no toolchain matched."); } catch (InvalidConfigurationException e) { String message = - "No toolchain found for --cpu='banana_cpu' --compiler='nonexistent-compiler'. " - + "Valid toolchains are: [\n" - + " toolchain-identifier-A: --cpu='banana_cpu' --compiler='compiler-A',\n" - + " toolchain-identifier-C: --cpu='banana_cpu' --compiler='compiler-C',\n" - + " toolchain-identifier-A-avocado_cpu: --cpu='avocado_cpu' " - + "--compiler='compiler-A',\n" - + " toolchain-identifier-B-avocado_cpu: --cpu='avocado_cpu' " - + "--compiler='compiler-B',\n" - + " toolchain-identifier-B: --cpu='banana_cpu' --compiler='compiler-B',\n" - + "]"; - assertThat(e).hasMessage(message); + "does not contain a toolchain for cpu 'banana_cpu' and compiler 'nonexistent-compiler'"; + assertThat(e).hasMessageThat().contains(message); } }