Skip to content

std_detect: Remove /proc/cpuinfo-based detection #1747

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

Merged
merged 1 commit into from
Apr 20, 2025

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Mar 18, 2025

Status: All blockers have been resolved. Blocked on #1746, rust-lang/libc#4338, and stdarch PR that uses the fix in libc (#1778).


Assuming #1746, rust-lang/libc#4338, and stdarch PR that uses the fix in libc (#1778) will be merged, the only targets that might use this implementation are:

Looking at only the builtin target, included there are:

$ rustc --print target-list | grep -E 'linux-uclibc|linux-none'
armv5te-unknown-linux-uclibceabi
armv7-unknown-linux-uclibceabi
armv7-unknown-linux-uclibceabihf
mips-unknown-linux-uclibc
mipsel-unknown-linux-uclibc
x86_64-unknown-linux-none

These are all tier 3 targets, and only arm actually uses cpuinfo-based detection. x86_64 does not use auxv/cpuinfo, and mips does not implement cpuinfo-based detection (#355). And, arm's feature detection API is currently unstable.

Also even if we consider future possible targets, file-related libc APIs should not be available for *-linux-none, so cpuinfo-based detection is effectively only for *-linux-uclibc* targets (except when writing syscalls in inline assembly). And the version of *-linux-uclibc* targets where getauxval is not available has been broken since 1.78 (and probably no one other than me was aware of it)...

So I think it is okay to remove this implementation, which will effectively no longer be used once the above PRs are merged.

(The other parts of std_detect_file_io (/proc/self/auxv) will be similarly effectively unused, but they are used in the tests for the auxv-based detection, so I'm leaving it for now.)

Another advantage of doing this is that Linux (getauxval/prctl(PR_GET_AUXV)), FreeBSD(elf_aux_info), and OpenBSD(elf_aux_info) all support auxv-based detection and HWCAP* values are the same (although there is the case that it exists on only one side), so we can merge code for them like this.

Closes #231
Closes #355

@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2025

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@taiki-e taiki-e changed the title [Draft] std_detect: Remove /proc/cpuinfo-based detection std_detect: Remove /proc/cpuinfo-based detection Apr 17, 2025
@taiki-e taiki-e marked this pull request as ready for review April 17, 2025 12:22
@taiki-e
Copy link
Member Author

taiki-e commented Apr 17, 2025

All blockers have been resolved.

@Amanieu Amanieu added this pull request to the merge queue Apr 20, 2025
Merged via the queue into rust-lang:master with commit 3eca39f Apr 20, 2025
60 checks passed
@taiki-e taiki-e deleted the rm-proc-cpuinfo branch April 20, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add /proc/cpuinfo support for mips64 add more /proc/cpuinfo tests
3 participants