Skip to content

Make std usage optional for wgpu-core. #7279

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 2 commits into from
Mar 6, 2025
Merged

Conversation

kpreid
Copy link
Collaborator

@kpreid kpreid commented Mar 6, 2025

Connections
Part of implementing #6826. Followup to #7189.

Description
Adds a std feature, enabled by default, to wgpu-core. When that feature is disabled, the following functionality is not available:

  • Send + Sync for resources.
  • trace feature.
  • observe_locks feature.
  • Snatch lock recursive locking assertion.

Also, RawString stops tracking the OS definition and is always *const u8. This is a bad idea and will break wgpu’s code on platforms where c_char = i8, but I don’t know what should be done instead; I’m not familiar with the reasons for bundle_ffi’s design. Please advise.

Testing
wgpu-core’s dependencies (notably naga) still require std, so this can’t be fully tested yet, but the test suite still passes, and building wgpu-core with the feature disabled succeeds.

Squash or Rebase?
Rebase

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@kpreid kpreid requested a review from a team as a code owner March 6, 2025 03:56
…ional.

Now, when `cfg(not(debug_assertions))`, there is no `SNATCH_LOCK_TRACE`
thread local, and `LockTrace` has no data fields.
@kpreid kpreid force-pushed the core-no-std branch 2 times, most recently from 6481f48 to 1b3d714 Compare March 6, 2025 15:40
@kpreid kpreid requested a review from ErichDonGubler March 6, 2025 15:43
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice splitting commits - one take-or-leave nit then g2g. Definitely going to need more CI once no-std is fully fleshed out.

Adds a `std` feature, enabled by default, to `wgpu-core`. When that
feature is disabled, the following functionality is not available:

* `Send + Sync` for resources.
* `trace` feature.
* `observe_locks` feature.
* Snatch lock recursive locking assertion.
@kpreid
Copy link
Collaborator Author

kpreid commented Mar 6, 2025

Definitely going to need more CI once no-std is fully fleshed out.

I agree (and the mutually exclusive distinction between “no-std” and “web” needs to change), but it’ll be easier to do then than now.

@kpreid kpreid requested a review from cwfitzgerald March 6, 2025 18:48
@cwfitzgerald cwfitzgerald merged commit 16d41cf into gfx-rs:trunk Mar 6, 2025
34 checks passed
@kpreid kpreid deleted the core-no-std branch March 14, 2025 17:31
@kpreid kpreid mentioned this pull request Mar 14, 2025
6 tasks
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