-
Notifications
You must be signed in to change notification settings - Fork 970
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
no-std support in wgpu-core #6926
base: trunk
Are you sure you want to change the base?
Conversation
@brodycj Thanks for looking into this! no_std support is something we've been talking about, so it's great to have someone take a shot. I've tweaked the PR title. Simply marking the PR as "draft" will make GitHub prevent us from accidentally merging it, and we won't bother with a formal review until it's out of draft. We can save the flashing lights and sirens for something else. :) |
…pport-in-wgpu-core
…NG IMPORTS for no-std SHOULD TRIGGER CI BUILD FAILURE
wgpu-core/src/lib.rs
Outdated
#[cfg(any(feature = "std", test))] | ||
pub(crate) use super::std::sync::*; | ||
pub(crate) use core::sync::*; | ||
// XXX TBD ??? - UPDATE FOR std vs test ??? | ||
// XXX TBD NAMING - ??? | ||
// XXX TODO UNCOMMENT - XXX XXX THIS COMMENTED-OUT IMPORT SHOULD TRIGGER CI BUILD FAILURE | ||
// #[cfg(not(any(feature = "std", test)))] | ||
// pub(crate) use crate::OnceCell as OnceLock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not happy that the existing CI did not fail for the missing import I injected for no-std build. I think we need to add cargo build --no-default-feaures
or at least add cargo test --no-default-features
to detect this kind of missing import issue. I would like to propose a solution for this.
P.S. The following build & test steps WILL catch this missing import (I am trying these with custom CXXFLAGS on my mac, cannot tell for sure for all cases if custom CXXFLAGS is needed or not on my mac):
cargo build --no-default-features -p wgpu-core
cargo check --no-default-features -p wgpu-core
cargo test --no-default-features -p wgpu-core
cargo clippy --no-default-features -p wgpu-core
The following build & test steps WILL NOT catch this missing import (I am trying these with custom CXXFLAGS on my mac as well):
cargo build --no-default-features
cargo check --no-default-features
cargo test --no-default-features
(this DOES show a single test failure inback::msl::writer::test_stack_size
but does NOT seem to catch the missing import here)cargo clippy --no-default-features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is expected. --no-default-features
will only apply to the root crate (at least as far as I'm aware) and not any member crates. There is a CI check no_std
task which was setup in the no_std
for wgpu-types
PR. That task is the one that should be expanded to include wgpu-core
, etc.
wgpu-core/src/lib.rs
Outdated
#[cfg(any(feature = "std", test))] | ||
pub(crate) use std::error; | ||
// XXX TODO UNCOMMENT - XXX XXX THIS COMMENTED-OUT IMPORT SHOULD TRIGGER CI BUILD FAILURE | ||
// XXX TBD THIS IMPORT (IF UNCOMMENTED) IS EXPECTED TO BREAK MSRV - XXX TODO CI SHOULD DETECT THIS | ||
// #[cfg(not(any(feature = "std", test)))] | ||
// pub(crate) use core::error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE: I think we need to update the MSRV build test to test with no features, no default features as well, otherwise MSRV build test would not catch expected issue with using core::error
. (I don't think the now-stablized error_in_core
feature is supported by the current MSRV.)
CI should have failed with the missing import for no-std build - see https://github.com/gfx-rs/wgpu/pull/6926/files#r1919365322 (I will propose a solution for this)
@wgpu @ wgpu maintainers my apologies for so much noise from notifications on this PR - I may raise a PR on my own fork to keep this under better control.
P.S. Moving forward, I am thinking to just add no-std build check / clippy check sub-step for wgpu-core like was done for wgpu-types, which I have now done for this PR. It may be ideal to add cargo test for wgpu-core with no-std as well.
CI failure for missing import for no-std now shows up for commit a1edb9c - expected CI failure shows up for multiple platforms, for example: https://github.com/gfx-rs/wgpu/actions/runs/12821635378/job/35753212859?pr=6926
Extra P.S. Thanks to Fitzgerald for pointing out my mistake with the random user - oops with apologies
I would actually downvote changing the notification settings, just my personal opinion - IMHO - I would personally rather see all notifications that are normally expected, should be able to mute or unsubsribe myself if needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just pung a random user lol - don't worry about it, we can always change notification settings
…L & DETECT MISSING IMPORTS for no-std
…pport-in-wgpu-core
…SISING IMPORT for no-std
.github/workflows/ci.yml
Outdated
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-types --no-default-features | ||
|
||
# Check with all features except "std". | ||
# check wgpu-core with no features | ||
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-core --no-default-features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dang this is not failing the way I expected: https://github.com/gfx-rs/wgpu/actions/runs/12820839400/job/35751074262?pr=6926
The following command I copy-pasted from the build log reproduces on my macBook (I needed to do rustup target add x86_64-unknown-none
first):
cargo clippy --target x86_64-unknown-none -p wgpu-core --no-default-features
I would like to fix this, if possible.
P.S. I / we may need to update naga
for no-std before this failure can be resolved - skipping for now, adding another, similar temporary sub-step to (hopefully) detect missing import(s) for no-std
…FAILING DUE TO ISSUES WITH DEPENDENCIES NOT WORKING WITH no-std
… MISSING IMPORT for no-std
…ING IMPORT for no-std
… XXX THIS SHOULD RESOLVE EXPECTED CI BUILD ISSUE
STATUS: INITIAL DRAFT with blocking TODO items multiple XXX todo items; documentation TODO;
CI failures are expected at this pointMAJOR BLOCKING ITEMS:
naga
,wgpu-hal
review & hopefully merge preparation PRs listed belowConnections
wgpu-types
: Addno_std
support towgpu-types
#6892hashbrown
#6925 (partial) - only includes updates proposed forwgpu-core
at this pointDescription
no-std support in
wgpu-core
(per title), with help from new "std" featureNOTE that this is based on recent preparation PRs listed above, hopefully they will be reviewed & merged soon. I would like to rebase this once the preparation PRs are hopefully approved & merged.
/cc @bushrat011899 - many thanks for your recent contributions
Testing
- XXX TODO KNOWN BUILD FAILURE NOT DETECTED BY CI TESTING (NEED TO FIX THIS)cargo build --no-default-features -p wgpu-core
cargo build --all-features -p wgpu-core
cargo build --all-features -p wgpu
- XXX TODO KNOWN FAILURE NOT DETECTED BY CI TESTING (NEED TO FIX THIS)cargo test --no-default-features -p wgpu-core
cargo test --all-features -p wgpu-core
cargo test --all-features -p wgpu
cargo xtask test
(I had to set CXXFLAGS in my environment on macOS, looks like a known issue with bindgen - XXX I would like to investigate & resolve this)Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.check for & resolve any CI failures (if possible)