Skip to content

Optimise rust-based formulas by setting target-cpuΒ #15530

@Tokarak

Description

@Tokarak

Verification

Provide a detailed description of the proposed feature

Rust has optional support for building with certain cpu features enabled. For example, arm-based macs, I would imagine, use only apple-m1 or apple-m2 cpus. rustc --print cfg | grep target_feature | wc -l gives me 28 features, while the generic target only has neon.

Specific features can also be specified β€” this can be useful if it's feasible to take the common features of a set of cpus.

If a better union set of cpu features can be found than generic, that can be an improvement to the ecosystem.

What is the motivation for the feature?

This can increase peformance (sometimes marginally, other times significantly) for binaries built in Rust.

How will the feature be relevant to at least 90% of Homebrew users?

Mac users on official hardware should use only a small set of cpus. This means there is a high potential for improvement.

I'm worried about alienating the small number of hackingtosh and opencore-patcher users. Perphaps if the OS requires specific features, then those can be used. Otherwise, if a Hackingtosh can be built on any hardware, then it would seem that the only way to avoid alienation is to stick to the generic targets, or provide multiple builds (though I'm not looking to inflate the CI minutes).

This is particularly true for silicon based macs. AFAIK, there are no arm-based hackingtoshes, and there are only two, very similar cpu types. This could mean that it's completely safe to add these features cargo_args on silicon builds and distributions.

What alternatives to the feature have been considered?

  • Builds for each official cpu target, with generic target as backup
  • Lowest-common-denominator builds for official hardware. Generic backup may or may not be needed.
  • Add this only where it is convenient (eg for arm-based targets)
  • Add this to local build only (very achievable, but building wastes more power than unspecialised binaries ever will β€” alone, this is almost redundant)
  • Don't fix what ain't broken

Metadata

Metadata

Assignees

Labels

outdatedPR was locked due to age

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions