-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crate for choosing between 32-bit and 64-bit arithmetic backends #824
Comments
I think it would make sense to define it first inside In the case of elliptic curve crates, shouldn't they simply rely on The only case I could think of where such functionality could be potentially useful is choosing between 32 and 64 bit software backends in |
@newpavlov Another example is the "soft" backends for the |
I am a bit hesitant to add such functionality to |
Aah, that's true. Although we may want to do that anyway eventually to do gate the use of architecture-specific ASM, which would really help boost the speed. But your point stands though... maybe it should go in a separate dependency-free crate specifically designed to be a build dependency only |
As discussed in #824, adds a crate with the intent of it providing heuristics for selecting whether 32-bit or 64-bit backends have optimal codegen for a given target, with optional overrides. The intended use of this crate is in `build-dependencies`, where it can emit a `cfg` attribute (e.g. `--cfg cpubits="64"`) if one hasn't been explicitly specified already, and all gating on 32-bit vs 64-bit backends can simply use the `cfg` attribute.
As discussed in #824, adds a crate with the intent of it providing heuristics for selecting whether 32-bit or 64-bit backends have optimal codegen for a given target, with optional overrides. The intended use of this crate is in `build-dependencies`, where it can emit a `cfg` attribute (e.g. `--cfg cpubits="64"`) if one hasn't been explicitly specified already, and all gating on 32-bit vs 64-bit backends can simply use the `cfg` attribute.
Started on a PR: #826 |
As discussed in #824, adds a crate with the intent of it providing heuristics for selecting whether 32-bit or 64-bit backends have optimal codegen for a given target, with optional overrides. The intended use of this crate is in `build-dependencies`, where it can emit a `cfg` attribute (e.g. `--cfg cpubits="64"`) if one hasn't been explicitly specified already, and all gating on 32-bit vs 64-bit backends can simply use the `cfg` attribute.
As discussed in #824, adds a crate with the intent of it providing heuristics for selecting whether 32-bit or 64-bit backends have optimal codegen for a given target, with optional overrides. The intended use of this crate is in `build-dependencies`, where it can emit a `cfg` attribute (e.g. `--cfg cpubits="64"`) if one hasn't been explicitly specified already, and all gating on 32-bit vs 64-bit backends can simply use the `cfg` attribute.
As discussed in #824, adds a crate with the intent of it providing heuristics for selecting whether 32-bit or 64-bit backends have optimal codegen for a given target, with optional overrides. The intended use of this crate is in `build-dependencies`, where it can emit a `cfg` attribute (e.g. `--cfg cpubits="64"`) if one hasn't been explicitly specified already, and all gating on 32-bit vs 64-bit backends can simply use the `cfg` attribute.
cpufeatures
)
We have several crates that naively choose between a 32-bit or 64-bit implementation based on
cfg(target_pointer_width)
.However, in many cases, like ARMv7 and
wasm32
, LLVM can generate better code from the 64-bit implementation, even though the CPU is natively 32-bits.Whatever heuristics are used, it's nice to be able to override the decision. Past experiences show crate features are a poor fit for this selection, however
cfg
attributes seem like a reasonable fit, as they leave the decision up to the toplevel[bin]
crate.The selection often needs to be cross-cutting across many crates. For example, the
crypto-bigint
and the https://github.com/rustcrypto/elliptic-curves crates built on top of it need to choose the same backend size.To make that all work, I would propose having some utility crate for making this selection. An approach being used by curve25519-dalek is to have the selection made inside of a build script which sets defaults for
cfg
attributes if they aren't already set explicitly, which makes the actualcfg
gating in the source code quite simple.I think we could probably shoehorn such functionality into
cpufeatures
and use optional cfg attributes likecpufeatures_bits="32"
orcpufeatures_bits="64"
to make the selection. Or failing that, it could be put in a separate crate which is only intended to be used viabuild-dependencies
.The text was updated successfully, but these errors were encountered: