-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Allow customizing CPU features #241
Comments
This isn't true? We are only using Lines 1017 to 1022 in 402ddac
I think we should just go with solution 1: parse |
Good idea! In this way Rust land and C land uses the same CPU features, looks better. |
After some investigation I'm now worrying about one case:
TL;DR, what will happen is that, for some crates that tries to invoke ccache internally (like rust-rocksdb), when user changes RUSTFLAGS, rebuild will not happen due to ccache not invalidated. As an alternative, we could parse the |
For example, currently for x86_64 targets we set
-mcpu=pentium4
. However it is usually not an ideal one because of lacking modern instructions like CRC32, SSE4.2, AVX, AVX2. AVX2 is shipped in 2013 so that it is actually not that "modern" and should have a broad adoption.On the other hand, some users might indeed want the compiled binary to be as much as portable, so setting these cpu features by default might not be a good choice.
My idea is to allow users specifying CPU features when calling zigbuild, like
--target-cpu-features=...
. When this is specified, we no longer provide default CPU features.I came up two ways how these CPU features could be passed from
cargo-zigbuild zigbuild
tocargo-zigbuild zig cc/c++
. Not sure whether there are better ways.Solution 1:
Users specify the target CPU feature via an environment variable, so that in
cargo-zigbuild zig cc/c++
command we receives it transparently.Solution 2:
Users specify the target CPU feature via
cargo-zigbuild zigbuild --target-cpu-features
. The CPU features are then passed to the cache file with a hashed suffix (likezigcxx-x86_64-unknown-linux-gnu.2.17-<some_hash>.sh
). In this way, multiple concurrent zigbuilds will not cause conflicts with each other, and we can keep the file untouched when the cpu features are unchanged (for compatible with #239). Pass by file could be possibly better, as it is more reproduciable than environment variables.The text was updated successfully, but these errors were encountered: