Skip to content
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
8 changes: 5 additions & 3 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ fn print_cpu_debug_info() {
let features = SimdPolicy::detect();

// x86/x86_64
print_feature("avx512", features.has_avx512());
print_feature("avx2", features.has_avx2());
print_feature("pclmul", features.has_pclmul());
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we now list the arches here, in hardware.rs and in the tests. could uucore expose the features the target can report instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean export FEATURE_DETECTORS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I know. Working on it now

@ChihweiLHBird ChihweiLHBird Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of regressions appreared when I applied this, some due to previous defects but were hidden and will be triggered by this change...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just restored the PR to be the original simple shape. I think we can do those hardware changes step by step in follow up PRs.

print_feature("avx512", features.has_avx512());
print_feature("avx2", features.has_avx2());
print_feature("pclmul", features.has_pclmul());
}

// ARM aarch64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not gate on little-endian here too, like uucore does?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we should drop little endian gate. So is the decision to drop it in uucore or nor?

if cfg!(target_arch = "aarch64") {
Expand Down
27 changes: 27 additions & 0 deletions tests/by-util/test_cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3065,6 +3065,7 @@ mod debug_flag {
use super::*;

#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn test_debug_flag() {
// Test with default CRC algorithm - should output CPU feature detection
new_ucmd!()
Expand Down Expand Up @@ -3121,6 +3122,7 @@ mod debug_flag {
}

#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn test_debug_with_algorithms() {
// Test with SHA256 - CPU detection should be same regardless of algorithm
new_ucmd!()
Expand Down Expand Up @@ -3168,6 +3170,31 @@ mod debug_flag {
.stderr_contains("avx2")
.stderr_contains("pclmul");
}

#[test]
#[cfg(target_arch = "aarch64")]
fn test_debug_flag_aarch64() {
new_ucmd!()
.arg("--debug")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture("crc_single_file.expected")
.stderr_str_check(|stderr| {
stderr == "using vmull hardware support\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accepting both strings makes the check pretty thin, can't we at least assert there is a single line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stderr == "some string" already asserted it's a single line.

|| stderr == "vmull support not detected\n"
});
}

#[test]
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test will never run on our CI targets, no? not sure it buys much

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

riscv64 CI runs this, which was the original purpose of this PR, to fix it for riscv64.

- { os: ubuntu-latest , target: riscv64gc-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross , skip-tests: true }

fn test_debug_flag_no_hardware_features() {
new_ucmd!()
.arg("--debug")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture("crc_single_file.expected")
.no_stderr();
}
}

#[test]
Expand Down
Loading