Program: 110528
Project: 110528
Buggy source:
@Override public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException, ActionConflictException {
  Artifact staticLibrary=ruleContext.getPrerequisiteArtifact("String_Node_Str",Mode.TARGET);
  Artifact sharedLibrary=ruleContext.getPrerequisiteArtifact("String_Node_Str",Mode.TARGET);
  Artifact interfaceLibrary=ruleContext.getPrerequisiteArtifact("String_Node_Str",Mode.TARGET);
  boolean systemProvided=ruleContext.attributes().get("String_Node_Str",Type.BOOLEAN);
  if (systemProvided && sharedLibrary != null) {
    ruleContext.ruleError("String_Node_Str");
  }
  if (!systemProvided && sharedLibrary == null && interfaceLibrary != null) {
    ruleContext.ruleError("String_Node_Str");
  }
  CcToolchainProvider ccToolchain=CppHelper.getToolchainUsingDefaultCcToolchainAttribute(ruleContext);
  FeatureConfiguration featureConfiguration=CcCommon.configureFeaturesOrReportRuleError(ruleContext,ccToolchain);
  FdoSupportProvider fdoSupport=CppHelper.getFdoSupportUsingDefaultCcToolchainAttribute(ruleContext);
  final CcCommon common=new CcCommon(ruleContext);
  CompilationInfo compilationInfo=new CcCompilationHelper(ruleContext,semantics,featureConfiguration,ccToolchain,fdoSupport).addPublicHeaders(common.getHeaders()).setHeadersCheckingMode(HeadersCheckingMode.STRICT).compile();
  boolean alwayslink=ruleContext.attributes().get("String_Node_Str",Type.BOOLEAN);
  ArtifactCategory staticLibraryCategory=alwayslink ? ArtifactCategory.ALWAYSLINK_STATIC_LIBRARY : ArtifactCategory.STATIC_LIBRARY;
  PathFragment labelName=PathFragment.create(ruleContext.getLabel().getName());
  String libraryIdentifier=ruleContext.getPackageDirectory().getRelative(labelName.replaceName("String_Node_Str" + labelName.getBaseName())).getPathString();
  CcLinkingHelper linkingHelper=new CcLinkingHelper(ruleContext,semantics,featureConfiguration,ccToolchain,fdoSupport,ruleContext.getConfiguration());
  if (staticLibrary != null) {
    if (CppFileTypes.PIC_ARCHIVE.matches(staticLibrary.getPath())) {
      linkingHelper.addPicStaticLibraries(ImmutableList.of(LinkerInputs.opaqueLibraryToLink(staticLibrary,staticLibraryCategory,libraryIdentifier,alwayslink)));
    }
 else {
      linkingHelper.addStaticLibraries(ImmutableList.of(LinkerInputs.opaqueLibraryToLink(staticLibrary,staticLibraryCategory,libraryIdentifier,alwayslink)));
    }
  }
  boolean targetWindows=featureConfiguration.isEnabled(CppRuleClasses.TARGETS_WINDOWS);
  Iterable<LibraryToLink> dynamicLibraryForLinkingList=null;
  Iterable<LibraryToLink> dynamicLibrariesForRuntimeList=null;
  if (sharedLibrary != null) {
    if (targetWindows) {
      dynamicLibrariesForRuntimeList=ImmutableList.of(LinkerInputs.opaqueLibraryToLink(sharedLibrary,ArtifactCategory.DYNAMIC_LIBRARY,libraryIdentifier));
    }
 else {
      dynamicLibrariesForRuntimeList=ImmutableList.of(LinkerInputs.solibLibraryToLink(common.getDynamicLibrarySymlink(sharedLibrary,true),sharedLibrary,libraryIdentifier));
    }
    linkingHelper.addDynamicLibrariesForRuntime(dynamicLibrariesForRuntimeList);
  }
  if (interfaceLibrary != null) {
    if (targetWindows) {
      dynamicLibraryForLinkingList=ImmutableList.of(LinkerInputs.opaqueLibraryToLink(interfaceLibrary,ArtifactCategory.INTERFACE_LIBRARY,libraryIdentifier));
    }
 else {
      dynamicLibraryForLinkingList=ImmutableList.of(LinkerInputs.solibLibraryToLink(common.getDynamicLibrarySymlink(interfaceLibrary,true),interfaceLibrary,libraryIdentifier));
    }
  }
 else {
    if (!targetWindows) {
      dynamicLibraryForLinkingList=dynamicLibrariesForRuntimeList;
    }
 else     if (staticLibrary == null) {
      ruleContext.ruleError("String_Node_Str" + "String_Node_Str");
    }
  }
  if (dynamicLibraryForLinkingList != null) {
    linkingHelper.addDynamicLibrariesForLinking(dynamicLibraryForLinkingList);
  }
  LinkingInfo linkingInfo=linkingHelper.link(compilationInfo.getCcCompilationOutputs(),compilationInfo.getCcCompilationContext());
  return new RuleConfiguredTargetBuilder(ruleContext).addProviders(compilationInfo.getProviders()).addProviders(linkingInfo.getProviders()).addSkylarkTransitiveInfo(CcSkylarkApiProvider.NAME,new CcSkylarkApiProvider()).addOutputGroups(CcCommon.mergeOutputGroups(ImmutableList.of(compilationInfo.getOutputGroups(),linkingInfo.getOutputGroups()))).addProvider(RunfilesProvider.class,RunfilesProvider.simple(Runfiles.EMPTY)).build();
}

Fixed version (ground truth):
@Override public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException, ActionConflictException {
  Artifact staticLibrary=ruleContext.getPrerequisiteArtifact("String_Node_Str",Mode.TARGET);
  Artifact sharedLibrary=ruleContext.getPrerequisiteArtifact("String_Node_Str",Mode.TARGET);
  Artifact interfaceLibrary=ruleContext.getPrerequisiteArtifact("String_Node_Str",Mode.TARGET);
  boolean systemProvided=ruleContext.attributes().get("String_Node_Str",Type.BOOLEAN);
  if (systemProvided && sharedLibrary != null) {
    ruleContext.ruleError("String_Node_Str");
  }
  if (!systemProvided && sharedLibrary == null && interfaceLibrary != null) {
    ruleContext.ruleError("String_Node_Str");
  }
  CcToolchainProvider ccToolchain=CppHelper.getToolchainUsingDefaultCcToolchainAttribute(ruleContext);
  FeatureConfiguration featureConfiguration=CcCommon.configureFeaturesOrReportRuleError(ruleContext,ccToolchain);
  FdoSupportProvider fdoSupport=CppHelper.getFdoSupportUsingDefaultCcToolchainAttribute(ruleContext);
  final CcCommon common=new CcCommon(ruleContext);
  CompilationInfo compilationInfo=new CcCompilationHelper(ruleContext,semantics,featureConfiguration,ccToolchain,fdoSupport).addPublicHeaders(common.getHeaders()).setHeadersCheckingMode(HeadersCheckingMode.STRICT).compile();
  boolean alwayslink=ruleContext.attributes().get("String_Node_Str",Type.BOOLEAN);
  ArtifactCategory staticLibraryCategory=alwayslink ? ArtifactCategory.ALWAYSLINK_STATIC_LIBRARY : ArtifactCategory.STATIC_LIBRARY;
  PathFragment labelName=PathFragment.create(ruleContext.getLabel().getName());
  String libraryIdentifier=ruleContext.getPackageDirectory().getRelative(labelName.replaceName("String_Node_Str" + labelName.getBaseName())).getPathString();
  CcLinkingHelper linkingHelper=new CcLinkingHelper(ruleContext,semantics,featureConfiguration,ccToolchain,fdoSupport,ruleContext.getConfiguration());
  if (staticLibrary != null) {
    if (CppFileTypes.PIC_ARCHIVE.matches(staticLibrary.getPath())) {
      linkingHelper.addPicStaticLibraries(ImmutableList.of(LinkerInputs.opaqueLibraryToLink(staticLibrary,staticLibraryCategory,libraryIdentifier,alwayslink)));
    }
 else {
      linkingHelper.addStaticLibraries(ImmutableList.of(LinkerInputs.opaqueLibraryToLink(staticLibrary,staticLibraryCategory,libraryIdentifier,alwayslink)));
    }
  }
  boolean targetWindows=featureConfiguration.isEnabled(CppRuleClasses.TARGETS_WINDOWS);
  Iterable<LibraryToLink> dynamicLibraryForLinkingList=null;
  Iterable<LibraryToLink> dynamicLibrariesForRuntimeList=null;
  if (sharedLibrary != null) {
    if (targetWindows) {
      dynamicLibrariesForRuntimeList=ImmutableList.of(LinkerInputs.opaqueLibraryToLink(sharedLibrary,ArtifactCategory.DYNAMIC_LIBRARY,libraryIdentifier));
    }
 else {
      dynamicLibrariesForRuntimeList=ImmutableList.of(LinkerInputs.solibLibraryToLink(common.getDynamicLibrarySymlink(sharedLibrary,true),sharedLibrary,libraryIdentifier));
    }
    linkingHelper.addDynamicLibrariesForRuntime(dynamicLibrariesForRuntimeList);
  }
  if (interfaceLibrary != null) {
    if (targetWindows) {
      dynamicLibraryForLinkingList=ImmutableList.of(LinkerInputs.opaqueLibraryToLink(interfaceLibrary,ArtifactCategory.INTERFACE_LIBRARY,libraryIdentifier));
    }
 else {
      dynamicLibraryForLinkingList=ImmutableList.of(LinkerInputs.solibLibraryToLink(common.getDynamicLibrarySymlink(interfaceLibrary,true),interfaceLibrary,libraryIdentifier));
    }
  }
 else {
    if (!targetWindows) {
      dynamicLibraryForLinkingList=dynamicLibrariesForRuntimeList;
    }
 else     if (sharedLibrary != null) {
      ruleContext.ruleError("String_Node_Str" + "String_Node_Str");
    }
  }
  if (dynamicLibraryForLinkingList != null) {
    linkingHelper.addDynamicLibrariesForLinking(dynamicLibraryForLinkingList);
  }
  LinkingInfo linkingInfo=linkingHelper.link(compilationInfo.getCcCompilationOutputs(),compilationInfo.getCcCompilationContext());
  return new RuleConfiguredTargetBuilder(ruleContext).addProviders(compilationInfo.getProviders()).addProviders(linkingInfo.getProviders()).addSkylarkTransitiveInfo(CcSkylarkApiProvider.NAME,new CcSkylarkApiProvider()).addOutputGroups(CcCommon.mergeOutputGroups(ImmutableList.of(compilationInfo.getOutputGroups(),linkingInfo.getOutputGroups()))).addProvider(RunfilesProvider.class,RunfilesProvider.simple(Runfiles.EMPTY)).build();
}