Skip to content

bevy_platform depends on getrandom but doesn't need to #21336

@kpreid

Description

@kpreid

What problem does this solve or what need does it fill?

Newly in Bevy 0.17, bevy_platform depends on getrandom 0.3, solely for the purpose of enabling the wasm_js feature. This means that all dependents of bevy_platform compiling for the web must do the RUSTFLAGS=--cfg thing, even if they are not using getrandom anywhere else at all — such as if they using bevy_ecs but not bevy_math.

It would be nice if users of bevy_ecs alone did not have to deal with rustflags configuration, since it composes poorly — for example, RUSTFLAGS=-Dwarnings, such as one might do in CI, will overwrite the configuration.

(Also, from a build performance perspective, it's an unnecessary dependency on getrandom.)

What solution would you like?

One of:

  • Remove this dependency on getrandom entirely — obligate application developers to have a dep and a rustflags config instead of just a dep. This would be a breaking change, so it can't happen for 0.17.
  • Move the dependency on getrandom somewhere more root-ward in the dependency graph of bevy, such as bevy_math. This might manage to not be a breaking change, at least for users of bevy as a whole, but I don’t know if the overall dependency graph is such that this is possible.

What alternative(s) have you considered?

Do nothing; continue to obligate all users of bevy_ecs to depend on getrandom and do the configuration.

Additional context

I regret not having noticed this issue — or at least, not having thought to check whether it would be possible to fix as opposed to necessary to live with — sooner so as to report it in the release candidate period.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MathFundamental domain-agnostic mathematical operationsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions