Skip to content
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

Emulate cpuid using C/Rust library? #1053

Closed
playXE opened this issue Jun 25, 2020 · 1 comment · Fixed by #1070
Closed

Emulate cpuid using C/Rust library? #1053

playXE opened this issue Jun 25, 2020 · 1 comment · Fixed by #1070

Comments

@playXE
Copy link

playXE commented Jun 25, 2020

I believe it's possible to link output binary with some C/Rust dylib that will have function that provides cpuid implementation, this way it will be possible to compile crates that use cpuid.

@bjorn3
Copy link
Member

bjorn3 commented Jun 25, 2020

https://github.com/bjorn3/rustc_codegen_cranelift/blob/a3cd293148e0678074cbbec06e5d3e9159a14ea0/patches/0016-Disable-cpuid-intrinsic.patch pretends that __cpuid is not available by returning false from has_cpuid. You are supposed to check this before calling __cpuid, as there are other cases where __cpuid is not available, like running in an sgx enclave or no sse support on the cpu.

Making __cpuid call a function implemented in C would be possible. This would however break almost all SIMD using crates, as many SIMD intrinsics are not yet implemented. Because has_cpuid returns false, most is_x86_feature_detected calls return false, which in many cases causes those crates to fallback to a SIMD free version, or use a version that only uses SIMD intrinsics already implemented in cg_clif.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants