Skip to content

Commit ec14619

Browse files
Amanieujyn514
authored andcommitted
Fix building std_detect as a dependency of std (#1089)
1 parent 77e5b51 commit ec14619

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Diff for: crates/std_detect/Cargo.toml

+12-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,22 @@ maintenance = { status = "experimental" }
2525
libc = { version = "0.2", optional = true, default-features = false }
2626
cfg-if = "0.1.10"
2727

28+
# When built as part of libstd
29+
core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" }
30+
compiler_builtins = { version = "0.1.2", optional = true }
31+
alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" }
32+
2833
[dev-dependencies]
2934
auxv = "0.3.3"
3035
cupid = "0.6.0"
3136

3237
[features]
3338
default = [ "std_detect_dlsym_getauxval", "std_detect_file_io" ]
34-
std_detect_file_io = []
39+
std_detect_file_io = [ "libc" ]
3540
std_detect_dlsym_getauxval = [ "libc" ]
36-
std_detect_env_override = []
41+
std_detect_env_override = [ "libc" ]
42+
rustc-dep-of-std = [
43+
"core",
44+
"compiler_builtins",
45+
"alloc",
46+
]

Diff for: crates/std_detect/src/detect/os/linux/auxvec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
8989

9090
#[cfg(not(feature = "std_detect_dlsym_getauxval"))]
9191
{
92-
let hwcap = unsafe { libc::getauxval(AT_HWCAP) };
92+
let hwcap = unsafe { libc::getauxval(AT_HWCAP as libc::c_ulong) as usize };
9393

9494
// Targets with only AT_HWCAP:
9595
#[cfg(any(target_arch = "aarch64", target_arch = "mips", target_arch = "mips64"))]
@@ -106,7 +106,7 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
106106
target_arch = "powerpc64"
107107
))]
108108
{
109-
let hwcap2 = unsafe { libc::getauxval(AT_HWCAP2) };
109+
let hwcap2 = unsafe { libc::getauxval(AT_HWCAP2 as libc::c_ulong) as usize };
110110
if hwcap != 0 && hwcap2 != 0 {
111111
return Ok(AuxVec { hwcap, hwcap2 });
112112
}

Diff for: crates/std_detect/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![cfg_attr(feature = "std_detect_file_io", feature(vec_spare_capacity))]
2121
#![no_std]
2222

23+
#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))]
2324
#[cfg(feature = "std_detect_file_io")]
2425
extern crate alloc;
2526

0 commit comments

Comments
 (0)