-
-
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
Respect target-cpu in RUSTFLAGS #243
Conversation
Signed-off-by: Wish <[email protected]>
Signed-off-by: Wish <[email protected]>
Oh, looks like the newly introduced dependency rustflags required rustc 1.74. Ref dtolnay/rustflags#5 As a tool, a high rustc version requirement might be fine, as users can just install latest rustc and then install this tool. |
Signed-off-by: Wish <[email protected]>
Signed-off-by: Wish <[email protected]>
Signed-off-by: Wish <[email protected]>
CI is now passed, except for zig-master branch :) |
Not a big issue, I'll cut a new release from main before merging this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM, just a minor nit.
Partially resolve #241
in zigbuild command, target-cpu in the RUSTFLAGS (or local Cargo config files) is parsed and appended to the compiler wrapper.
For example,
RUSTFLAGS="-Ctarget-cpu=x86-64-v3"
will cause compiler wrapper to becargo-zigbuild zig cc -- -g -mcpu=x86_64_v3 ...
-Ctarget-features is currently not respected in this PR. However it is parsed well.
Add a test using https://github.com/breezewish/x86-instruction-set-analyzer to check whether desired instruction set presents in the compiled binary. This helps us make sure that RUSTFLAGS are correctly passed.
Note: As we check instruction sets for the entire binary, it is possible that the instruction set (for example AVX2) comes from the Rust part, not the C++ part. I tested manually that, when
RUSTFLAGS="-C target_cpu=x86-64-v4"
is set, the Rust part will not produce AVX2 instructions fortests/target-cpu
. If we discovered AVX2 instruction, it must comes from the C++ part.Here is the instruction check result with
RUSTFLAGS="-C target_cpu=x86-64-v4"
without using this PR: