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

Fix building std_detect as a dependency of std #1089

Merged
merged 1 commit into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions crates/std_detect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
4 changes: 2 additions & 2 deletions crates/std_detect/src/detect/os/linux/auxvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand All @@ -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 });
}
Expand Down
1 change: 1 addition & 0 deletions crates/std_detect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down