使用最新的rust 1.39.0-nightly版本
TARGET=x86_64-unknown-linux-gnu RUSTFLAGS="-C target-cpu=native" cargo test --target x86_64-unknown-linux-gnu -- --nocapture
当在我的Ubuntu16.04虚拟机内运行时,compare_with_cupid() (对应的库为https://github.com/shepmaster/cupid/ )某些test失败的原因是: 其实两者都是调用__cpuid_count
来获取底层CPU信息,不同之处在于:stdarch/crates/std_detect/src/detect/os/x86.rs
中的detect_features()
函数根据不同的信息,对相应的feature位进行了人为判断enable。调整主要依据见(/// [wiki_cpuid]: https://en.wikipedia.org/wiki/CPUID /// [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf /// [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf)
虚拟机内运行不通过的指令集有:fma、bmi1、bmi2、xsaveopt、xsavec、xsaves、adx。
2. __cpuid_count返回的eax,ebx,ecx,edx含义
参考资料: [1] https://github.com/shepmaster/cupid/ [2] https://en.wikipedia.org/wiki/CPUID [3] https://doc.rust-lang.org/1.27.2/core/arch/x86_64/fn.__cpuid_count.html [4] http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf [5] http://support.amd.com/TechDocs/24594.pdf