Skip to content

Commit 92ad2d0

Browse files
committed
WIP: debug
1 parent 27fcba1 commit 92ad2d0

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

library/std_detect/src/detect/os/linux/auxvec.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
118118
{
119119
// If calling getauxval fails, try to read the auxiliary vector from
120120
// its file:
121-
auxv_from_file("/proc/self/auxv")
121+
auxv_from_file("/proc/self/auxv").map_err(|_| ())
122122
}
123123
#[cfg(not(feature = "std_detect_file_io"))]
124124
{
@@ -153,10 +153,13 @@ fn getauxval(key: usize) -> Result<usize, ()> {
153153
Ok(unsafe { ffi_getauxval(key as libc::c_ulong) as usize })
154154
}
155155

156+
#[cfg(feature = "std_detect_file_io")]
157+
use alloc::string::String;
158+
156159
/// Tries to read the auxiliary vector from the `file`. If this fails, this
157160
/// function returns `Err`.
158161
#[cfg(feature = "std_detect_file_io")]
159-
pub(super) fn auxv_from_file(file: &str) -> Result<AuxVec, ()> {
162+
pub(super) fn auxv_from_file(file: &str) -> Result<AuxVec, String> {
160163
let file = super::read_file(file)?;
161164

162165
// See <https://github.com/torvalds/linux/blob/v5.15/include/uapi/linux/auxvec.h>.
@@ -175,7 +178,7 @@ pub(super) fn auxv_from_file(file: &str) -> Result<AuxVec, ()> {
175178
/// Tries to interpret the `buffer` as an auxiliary vector. If that fails, this
176179
/// function returns `Err`.
177180
#[cfg(feature = "std_detect_file_io")]
178-
fn auxv_from_buf(buf: &[usize]) -> Result<AuxVec, ()> {
181+
fn auxv_from_buf(buf: &[usize]) -> Result<AuxVec, String> {
179182
// Targets with only AT_HWCAP:
180183
#[cfg(any(
181184
target_arch = "riscv32",
@@ -220,7 +223,7 @@ fn auxv_from_buf(buf: &[usize]) -> Result<AuxVec, ()> {
220223
}
221224
// Suppress unused variable
222225
let _ = buf;
223-
Err(())
226+
Err(String::from("hwcap not found"))
224227
}
225228

226229
#[cfg(test)]

library/std_detect/src/detect/os/linux/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
//! Run-time feature detection on Linux
22
//!
33
#[cfg(feature = "std_detect_file_io")]
4+
use alloc::format;
5+
#[cfg(feature = "std_detect_file_io")]
6+
use alloc::string::String;
7+
#[cfg(feature = "std_detect_file_io")]
48
use alloc::vec::Vec;
59

610
mod auxvec;
711

812
#[cfg(feature = "std_detect_file_io")]
9-
fn read_file(path: &str) -> Result<Vec<u8>, ()> {
10-
let mut path = Vec::from(path.as_bytes());
13+
fn read_file(orig_path: &str) -> Result<Vec<u8>, String> {
14+
let mut path = Vec::from(orig_path.as_bytes());
1115
path.push(0);
1216

1317
unsafe {
1418
let file = libc::open(path.as_ptr() as *const libc::c_char, libc::O_RDONLY);
1519
if file == -1 {
16-
return Err(());
20+
return Err(format!("Cannot open file at {orig_path}: {}", *libc::__errno_location()));
1721
}
1822

1923
let mut data = Vec::new();
@@ -23,7 +27,7 @@ fn read_file(path: &str) -> Result<Vec<u8>, ()> {
2327
match libc::read(file, spare.as_mut_ptr() as *mut _, spare.len()) {
2428
-1 => {
2529
libc::close(file);
26-
return Err(());
30+
return Err(format!("Error while reading from file at {orig_path}"));
2731
}
2832
0 => break,
2933
n => data.set_len(data.len() + n as usize),

src/ci/docker/host-x86_64/armhf-gnu/Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ RUN sh /scripts/sccache.sh
8383
COPY static/gitconfig /etc/gitconfig
8484

8585
ENV RUST_CONFIGURE_ARGS --qemu-armhf-rootfs=/tmp/rootfs
86-
ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target arm-unknown-linux-gnueabihf
86+
ENV SCRIPT \
87+
ls -lha /checkout && \
88+
ls -lha /checkout/library && \
89+
ls -lha /checkout/library/std_detect && \
90+
ls -lha /checkout/library/std_detect/src && \
91+
ls -lha /checkout/library/std_detect/src/detect && \
92+
ls -lha /checkout/library/std_detect/src/detect/test_data && \
93+
ls -lha /checkout/library/std_detect/src/detect/test_data/linux-rpi3.auxv && \
94+
(python3 ../x.py --stage 2 test --host='' --target arm-unknown-linux-gnueabihf || exit 0) && \
95+
ls -lha /checkout && \
96+
ls -lha /checkout/library && \
97+
ls -lha /checkout/library/std_detect && \
98+
ls -lha /checkout/library/std_detect/src && \
99+
ls -lha /checkout/library/std_detect/src/detect && \
100+
ls -lha /checkout/library/std_detect/src/detect/test_data && \
101+
ls -lha /checkout/library/std_detect/src/detect/test_data/linux-rpi3.auxv && \
102+
exit 1
87103

88104
ENV NO_CHANGE_USER=1

0 commit comments

Comments
 (0)