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

Uses non-existent FreeBSD 11 syscall ABI for FreeBSD RISC-V #92466

Open
jrtc27 opened this issue Dec 31, 2021 · 3 comments
Open

Uses non-existent FreeBSD 11 syscall ABI for FreeBSD RISC-V #92466

jrtc27 opened this issue Dec 31, 2021 · 3 comments
Labels
C-bug Category: This is a bug. O-freebsd Operating system: FreeBSD O-riscv Target: RISC-V architecture

Comments

@jrtc27
Copy link

jrtc27 commented Dec 31, 2021

All FreeBSD targets are currently hard-coded to use the FreeBSD 11 syscall ABI. For most targets this is "fine", since the default kernel configs include COMPAT_FREEBSD11. However, the current RISC-V FreeBSD port post-dates FreeBSD 11 (see https://www.freebsd.org/cgi/man.cgi?query=arch), so the syscalls that were removed in FreeBSD 12 never existed for RISC-V, and so the kernel does not, and should not (as one of the primary RISC-V developers I will veto any such change), enable COMPAT_FREEBSD11. Any attempt to use them will deliver a fatal-by-default SIGSYS to the process, and given FreeBSD 11->12 was the ino64 transition, this affects basically anything you could actually want to do.

As well as multiple places hard-coding the FreeBSD ABI version, this information is not communicated to other crates. Notably FreeBSD 12 added the ext field to struct kevent, which breaks mio's kqueue.rs, as I discovered when I hacked up rustc and libc to hard-code FreeBSD 12 for RISC-V (and thus ended up with https://reviews.freebsd.org/P525 to make it work). Ideally this information would be communicated to build.rs somehow, if not available as default cfg predicates.

This was all totally glossed over when the changes were upstreamed, despite my cries within FreeBSD to engage with you all upstream and sort this mess out. I still don't have time to do that engaging myself, but at least this makes you aware of the actual problem. Maybe you have ideas for a decent way to communicate the FreeBSD version to crates so we can at least just hard-code RISC-V as minimum FreeBSD 12 in rustc and have that propagate everywhere; it's not ideal, but at least then it'd be centralised.

For what it's worth, https://reviews.freebsd.org/P522, https://reviews.freebsd.org/P523, https://reviews.freebsd.org/P524 and https://reviews.freebsd.org/P525 is the complete set of patches I hacked up to get a working rustc+cargo capable of compiling a hello world natively on a stock RISC-V GENERIC kernel, that then got picked up by others and had the FreeBSD 12 ABI parts dropped from.

@jrtc27 jrtc27 added the C-bug Category: This is a bug. label Dec 31, 2021
@jrtc27
Copy link
Author

jrtc27 commented Dec 31, 2021

(in a way this may belong filed against libc, but the need to expose the FreeBSD version probably affects rustc itself so it may well in fact belong here)

@memoryruins
Copy link
Contributor

@rustbot label: +O-freebsd, +O-riscv.

@rustbot rustbot added O-freebsd Operating system: FreeBSD O-riscv Target: RISC-V architecture labels Apr 19, 2022
@bdrewery
Copy link
Contributor

bdrewery commented Jun 9, 2022

#89058 discusses removing the compat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-freebsd Operating system: FreeBSD O-riscv Target: RISC-V architecture
Projects
None yet
Development

No branches or pull requests

4 participants