8000 rustix: on Linux, support a build without linux-raw-sys by gurchetansingh · Pull Request #1478 · bytecodealliance/rustix · GitHub
[go: up one dir, main page]

Skip to content

Conversation

gurchetansingh
Copy link
Contributor
@gurchetansingh gurchetansingh commented Jun 20, 2025

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.

8000

@gurchetansingh
Copy link
Contributor Author
gurchetansingh commented Jun 20, 2025

CC: @sunfishcode @rusty-snake for opinions before going further down this route.

@gurchetansingh gurchetansingh force-pushed the rustix-linux-libc-only branch 2 times, most recently from bc65825 to c9a317f Compare June 23, 2025 19:33
@gurchetansingh gurchetansingh changed the title [RFC][wip] rustix: on Linux, support a build without linux-raw-sys rustix: on Linux, support a build without linux-raw-sys Jun 23, 2025
@gurchetansingh gurchetansingh force-pushed the rustix-linux-libc-only branch 8 times, most recently from c88eab0 to 89237ca Compare June 23, 2025 21:48
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.
8000
@gurchetansingh gurchetansingh force-pushed the rustix-linux-libc-only branch from 89237ca to 7e36061 Compare June 23, 2025 22:14
@gurchetansingh
Copy link
Contributor Author

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.
@gurchetansingh gurchetansingh force-pushed the rustix-linux-libc-only branch from 9e64205 to 99dbe40 Compare June 30, 2025 18:56
@gurchetansingh
Copy link
Contributor Author

Ping???

@sunfishcode
Copy link
Member

I appologize for being slow here. Thanks for putting this together! I think this makes sense. And the FreeBSD CI failure is likely unrelated.

@sunfishcode sunfishcode merged commit fda7cbe into bytecodealliance:main Jul 12, 2025
50 of 51 checks passed
temeraire-cx pushed a commit to chaotic-cx/mesa-mirror that referenced this pull request Jul 14, 2025
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>
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.

3 participants
0