-
Notifications
You must be signed in to change notification settings - Fork 222
rustix: on Linux, support a build without linux-raw-sys #1478
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
rustix: on Linux, support a build without linux-raw-sys #1478
Conversation
CC: @sunfishcode @rusty-snake for opinions before going further down this route. |
bc65825
to
c9a317f
Compare
c88eab0
to
89237ca
Compare
Rustix support was added to Mesa3D recently, but it only works with the linux-raw-sys backend. On Linux, even the libc backend, there is a dependency on linux-raw-sys for certain ABI definitions. When updating rustix in Android to support this, I realized only the libc backend is supported in Android. This is because Android as a platform wants to discourage raw syscalls, and to be able to globally update libc. Features like fdtrack would not work with the linux-raw-sys backend: https://android.googlesource.com/platform/bionic/+/HEAD/docs/fdtrack.md Given Android wants to incentize use of libc only, this MR introduces the concept of "linux-raw-dep". This means that linux-raw-sys is present as a dependency for the user. This will be on by default even for the libc backend, but will be turned off for Android (this is reflected in the build.rs script). This will also help others who don't need all the features rustix offers on Linux, so they have one less dependency to maintain. They may append "--cfg=rustix_no_linux_raw" to Rust flags skip building the linux raw backend. Mesa3D will use this. Tested via: cargo build --target arm-linux-androideabi --features=use-libc,net,std,alloc,event,fs,mm,param,pipe,use-libc-auxv,libc_errno and on Linux with the proper RUSTFLAGS set. The Github workflows have been modified to only use the current subset of features using in AOSP: https://android.googlesource.com/platform/external/rust/android-crates-io/+/refs/heads/main/crates/rustix/Android.bp That is the source of truth for an Android integration and the CI only needs to test that. Additional features may be added as needed in the future.
89237ca
to
7e36061
Compare
I don't think we care about the freebsd-15 runner? It passes on freebsd-14, and the other changes were merged with checks not passing on freebsd-16: https://github.com/bytecodealliance/rustix/pull/1460/checks Either way, changes are ready for review. Thank you! |
Android doesn't only have a bionic toolchain, but musl toolchain for components built on the build workstation.
9e64205
to
99dbe40
Compare
Ping??? |
I appologize for being slow here. Thanks for putting this together! I think this makes sense. And the FreeBSD CI failure is likely unrelated. |
This is because Android prefers it -- the project likes to make changes to bionic that have a global effect, and using raw-syscalls potentially complicates that. This is a backport of: bytecodealliance/rustix#1478 In addition, nothing in Mesa3D needs the added functionality provided by raw syscalls. Test: meson setup gfxstream-build -Dvulkan-drivers="gfxstream" -Dgallium-drivers="" -Dvirtgpu_kumquat=true -Dopengl=false -Drust_std=2021 still compiles. Reviewed-by: @LingMan Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36116>
Rustix support was added to Mesa3D recently, but it only works
with the linux-raw-sys backend. On Linux, even the libc
backend, there is a dependency on linux-raw-sys for certain ABI
definitions.
When updating rustix in Android to support this, I realized only
the libc backend is supported in Android. This is because
Android as a platform wants to discourage raw syscalls, and to
be able to globally update libc.
Features like fdtrack would not work with the linux-raw-sys backend:
https://android.googlesource.com/platform/bionic/+/HEAD/docs/fdtrack.md
Given Android wants to incentize use of libc only, this MR introduces
the concept of "linux-raw-dep". This means that linux-raw-sys is
present as a dependency for the user. This will be on by default
even for the libc backend, but will be turned off for Android (this
is reflected in the build.rs script).
This will also help others who don't need all the features rustix
offers on Linux, so they have one less dependency to maintain. They
may append "--cfg=rustix_no_linux_raw" to Rust flags skip building
the linux raw backend. Mesa3D will use this.
Tested via:
cargo build --target arm-linux-androideabi --features=use-libc,net,std,alloc,event,fs,mm,param,pipe,use-libc-auxv,libc_errno
and on Linux with the proper RUSTFLAGS set. The Github workflows have
been modified to only use the current subset of features using in AOSP:
https://android.googlesource.com/platform/external/rust/android-crates-io/+/refs/heads/main/crates/rustix/Android.bp
That is the source of truth for an Android integration and the CI only
8000needs to test that. Additional features may be added as needed in the
future.