diff options
| author | Amanieu d'Antras <amanieu@gmail.com> | 2021-03-18 20:36:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-18 20:36:40 +0000 |
| commit | 72dda3aae088f39ea4face0df61436d6adb7479d (patch) | |
| tree | 3ff1c346f4f41e0d107329361c92536904533524 /library/stdarch/crates/std_detect | |
| parent | 7947cb8bac1440113786250c7810d83d2f41bb24 (diff) | |
| download | rust-72dda3aae088f39ea4face0df61436d6adb7479d.tar.gz rust-72dda3aae088f39ea4face0df61436d6adb7479d.zip | |
Fix building std_detect as a dependency of std (#1089)
Diffstat (limited to 'library/stdarch/crates/std_detect')
| -rw-r--r-- | library/stdarch/crates/std_detect/Cargo.toml | 14 | ||||
| -rw-r--r-- | library/stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs | 4 | ||||
| -rw-r--r-- | library/stdarch/crates/std_detect/src/lib.rs | 1 |
3 files changed, 15 insertions, 4 deletions
diff --git a/library/stdarch/crates/std_detect/Cargo.toml b/library/stdarch/crates/std_detect/Cargo.toml index 252e42c569f..4d0f93d8cfd 100644 --- a/library/stdarch/crates/std_detect/Cargo.toml +++ b/library/stdarch/crates/std_detect/Cargo.toml @@ -25,12 +25,22 @@ maintenance = { status = "experimental" } libc = { version = "0.2", optional = true, default-features = false } cfg-if = "0.1.10" +# When built as part of libstd +core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" } +compiler_builtins = { version = "0.1.2", optional = true } +alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" } + [dev-dependencies] auxv = "0.3.3" cupid = "0.6.0" [features] default = [ "std_detect_dlsym_getauxval", "std_detect_file_io" ] -std_detect_file_io = [] +std_detect_file_io = [ "libc" ] std_detect_dlsym_getauxval = [ "libc" ] -std_detect_env_override = [] +std_detect_env_override = [ "libc" ] +rustc-dep-of-std = [ + "core", + "compiler_builtins", + "alloc", +] diff --git a/library/stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs b/library/stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs index d556b23b1de..077fc9e4c89 100644 --- a/library/stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs +++ b/library/stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs @@ -89,7 +89,7 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> { #[cfg(not(feature = "std_detect_dlsym_getauxval"))] { - let hwcap = unsafe { libc::getauxval(AT_HWCAP) }; + let hwcap = unsafe { libc::getauxval(AT_HWCAP as libc::c_ulong) as usize }; // Targets with only AT_HWCAP: #[cfg(any(target_arch = "aarch64", target_arch = "mips", target_arch = "mips64"))] @@ -106,7 +106,7 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> { target_arch = "powerpc64" ))] { - let hwcap2 = unsafe { libc::getauxval(AT_HWCAP2) }; + let hwcap2 = unsafe { libc::getauxval(AT_HWCAP2 as libc::c_ulong) as usize }; if hwcap != 0 && hwcap2 != 0 { return Ok(AuxVec { hwcap, hwcap2 }); } diff --git a/library/stdarch/crates/std_detect/src/lib.rs b/library/stdarch/crates/std_detect/src/lib.rs index b051be5c0a5..6658c3e6bda 100644 --- a/library/stdarch/crates/std_detect/src/lib.rs +++ b/library/stdarch/crates/std_detect/src/lib.rs @@ -20,6 +20,7 @@ #![cfg_attr(feature = "std_detect_file_io", feature(vec_spare_capacity))] #![no_std] +#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))] #[cfg(feature = "std_detect_file_io")] extern crate alloc; |
