Skip to content

add headers support to node toolchain - #2

Open
nguyend2017 wants to merge 1 commit into
base-add-node-cc-headers-r-11722390from
nguyend2017/add-node-cc-headers-r-11722390
Open

nguyend2017 wants to merge 1 commit into
base-add-node-cc-headers-r-11722390from
nguyend2017/add-node-cc-headers-r-11722390

Conversation

@nguyend2017

@nguyend2017 nguyend2017 commented Feb 19, 2026 •

Copy link
Copy Markdown

Note

Medium Risk
Touches toolchain/provider plumbing and repository-generated BUILD content, which can affect toolchain resolution and consumers’ C++ deps; changes are additive but could break custom toolchains if headers isn’t provided.

Overview
The node_toolchain rule now accepts a headers cc_library label and propagates its providers through NodeInfo, and the generated toolchain repositories wire this to a new :headers target.

Adds current_node_cc_headers (a toolchain-resolving wrapper that forwards CcInfo/DefaultInfo) so consumers can depend on @rules_nodejs//nodejs:current_node_cc_headers without knowing which Node toolchain is selected, plus an e2e smoke cc_binary that includes node.h (disabled on Windows where release artifacts don’t ship headers). Documentation is updated to include the new attribute.

Written by Cursor Bugbot for commit de9e080. This will update automatically on new commits. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread nodejs/toolchain.bzl
"CcInfo": ctx.attr.headers[CcInfo],
"DefaultInfo": ctx.attr.headers[DefaultInfo],
},
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing headers crashes custom toolchain definitions

High Severity

The headers attribute is optional (not mandatory, no default), but _node_toolchain_impl unconditionally accesses ctx.attr.headers[CcInfo] and ctx.attr.headers[DefaultInfo]. When a user defines a custom node_toolchain without specifying headers, ctx.attr.headers is None, causing a crash. This breaks backwards compatibility for all existing custom toolchain definitions. The rule's own doc example on line 164 shows a toolchain without headers.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

1 participant