Skip to content

Add support for per-platform aliases - #173

Open
sin-ack wants to merge 1 commit into
hermeticbuild:mainfrom
sin-ack:per-platform-aliases
Open

Add support for per-platform aliases#173
sin-ack wants to merge 1 commit into
hermeticbuild:mainfrom
sin-ack:per-platform-aliases

Conversation

@sin-ack

@sin-ack sin-ack commented Jul 8, 2026

Copy link
Copy Markdown

Aliases for first-party crates were unconditionally added to the shared alias data for a workspace crate. This does not work if a first-party dependency should only be added for specific targets (e.g. a tool can make network connections using a first-party dependency but only on certain platforms, and does not use the dependency crate otherwise).

This change makes it so that we only add an alias for a first-party crate if it would also appear as a dependency for that specific target. Dependency data now has a new field called aliases_by_platform, and the generated aliases() helper emits a select expression if there are platform-specific aliases.

Aliases for first-party crates were unconditionally added to the shared
alias data for a workspace crate.  This does not work if a first-party
dependency should only be added for specific targets (e.g. a tool can
make network connections using a first-party dependency but only on
certain platforms, and does not use the dependency crate otherwise).

This change makes it so that we only add an alias for a first-party
crate if it would also appear as a dependency for that specific target.
Dependency data now has a new field called `aliases_by_platform`, and
the generated aliases() helper emits a select expression if there are
platform-specific aliases.
@sin-ack
sin-ack force-pushed the per-platform-aliases branch from 39b76fe to ef52904 Compare July 8, 2026 18:29
@dzbarsky

Copy link
Copy Markdown
Member

party crates were unconditionally added to the shared alias data for a workspace crate. This does not work if a first-party dependency should only be added for specific targets (e.g. a tool can make network connections using a first-party dependency but only on certain platforms, and does not use the dependency crate otherwise).

This change makes it so that we only add an alias for a first-party crate if it would also appear as a dependency for that specific target. Dependency data now has a new field called aliases_by_platform, and the generated aliases() helper emits a select expression if there are platform-specific aliases.

So fun fact, it used to be like this but then I convinced myself that aliases were lazy enough that it was fine to merge for simplicity (i.e. that it wouldn't actually add any inputs, only remap deps if they were selected). It sounds like that might have been an incorrect assumption, but can you show me a case where it breaks? (I saw you added a unit test, but I'd prefer an integration test for this)

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