Skip to content

Fix type of default_copts#1428

Merged
oreflow merged 1 commit intobazelbuild:mainfrom
hvadehra:patch-1
Dec 8, 2025
Merged

Fix type of default_copts#1428
oreflow merged 1 commit intobazelbuild:mainfrom
hvadehra:patch-1

Conversation

@hvadehra
Copy link
Member

@hvadehra hvadehra commented Dec 8, 2025

With the cc rules removed from Bazel, the copts attribute is no longer a part of the build language proto

With the cc rules removed from Bazel, the `copts` attribute is no longer a part of the build language proto
@hvadehra hvadehra requested a review from a team as a code owner December 8, 2025 09:47
@hvadehra hvadehra requested review from AnnaSvalova and removed request for a team December 8, 2025 09:47
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hvadehra, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a compatibility issue arising from recent changes in Bazel, specifically the removal of cc rules. It updates the type assignment for default_copts in the build table generation logic to buildpb.Attribute_STRING_LIST, ensuring that the build system correctly interprets and processes build configurations in line with the updated Bazel build language proto.

Highlights

  • Type Correction for default_copts: The type definition for default_copts has been explicitly set to buildpb.Attribute_STRING_LIST. Previously, it dynamically referenced the copts attribute's type, which is no longer valid due to the removal of cc rules from Bazel and its corresponding absence in the build language proto.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes the type for default_copts since the copts attribute has been removed from the build language proto. Your change prevents a potential issue where the type would resolve to an incorrect zero value.

I've added a specific suggestion to apply this same pattern to other default attributes within the changed hunk to improve robustness. Additionally, you might want to consider applying a similar change for extra_srcs (line 80) and pytype_deps (line 81) which follow the same pattern of referencing another attribute's type and are outside the current diff.

Comment on lines 72 to 75
types["default_visibility"] = types["visibility"]
types["default_copts"] = types["copts"]
types["default_copts"] = buildpb.Attribute_STRING_LIST
types["default_deprecation"] = types["deprecation"]
types["default_testonly"] = types["testonly"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While fixing default_copts is correct, several other default attributes here are defined by referencing other attributes (e.g., default_visibility references visibility). This creates a dependency on the referenced attributes existing in the proto, which as you've seen with copts, can be brittle. To make the code more robust against future changes, it's better to use the explicit types for all these default attributes.

Suggested change
types["default_visibility"] = types["visibility"]
types["default_copts"] = types["copts"]
types["default_copts"] = buildpb.Attribute_STRING_LIST
types["default_deprecation"] = types["deprecation"]
types["default_testonly"] = types["testonly"]
types["default_visibility"] = buildpb.Attribute_STRING_LIST
types["default_copts"] = buildpb.Attribute_STRING_LIST
types["default_deprecation"] = buildpb.Attribute_STRING
types["default_testonly"] = buildpb.Attribute_BOOLEAN

@oreflow oreflow merged commit 4ad76a2 into bazelbuild:main Dec 8, 2025
2 checks passed
@hvadehra hvadehra deleted the patch-1 branch December 8, 2025 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants