From 0e613dcc15804e44c665566f07ce0391a41a03d1 Mon Sep 17 00:00:00 2001 From: Robin Randhawa Date: Tue, 15 Jan 2019 12:19:39 +0000 Subject: [PATCH] aarch64-prep: Wrap x86_64 specific crate references and code with conditionals --- Cargo.toml | 4 +++- src/main.rs | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 92baeaa761..95c8a04049 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,7 @@ version = "0.1.0" [dependencies] rand = "0.3" -raw-cpuid = "2.0" redox_syscall = "0.1" + +[target.'cfg(target_arch = "x86_64")'.dependencies] +raw-cpuid = "2.0" diff --git a/src/main.rs b/src/main.rs index d50d6451e0..859e9dd052 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ #![feature(asm)] extern crate syscall; + +#[cfg(target_arch = "x86_64")] extern crate raw_cpuid; extern crate rand; @@ -11,6 +13,7 @@ use std::os::unix::io::AsRawFd; use rand::chacha::ChaChaRng; use rand::Rng; +#[cfg(target_arch = "x86_64")] use raw_cpuid::CpuId; use syscall::{Error, Result, SchemeMut, EINVAL, MODE_CHR}; @@ -88,7 +91,12 @@ impl SchemeMut for RandScheme { } fn main(){ - let has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand(); + let has_rdrand = false; + + #[cfg(target_arch = "x86_64")] + { + has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand(); + } // Daemonize if unsafe { syscall::clone(0).unwrap() } == 0 {