Repository navigation
Build for wasm32-unknown-unknown - #1505
Open
vlad-salone wants to merge 1 commit into
Open
vlad-salone wants to merge 1 commit into
vlad-salone wants to merge 1 commit into
Conversation
The target has no C library, so the libc crate defines neither ptrdiff_t, intptr_t, uintptr_t and off_t nor the errno constants there, and the build stops on 34 errors, all of them these names. Define the three pointer-sized types in a c_types module, as libc defines them on every target it supports, and take off_t and the errno values from libc wherever there is a C library. Without one, off_t is i64 and the errno values are Linux's: nothing on such a target can call the C API, so Rav1dError only needs them distinct. No other target changes: the types are the same and the errno values still come from libc. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rav1ddoesn't build forwasm32-unknown-unknowntoday. With assembly off, every one of the 34 errors is alibcname: the target has no C library, so thelibccrate defines neitherptrdiff_t,intptr_t,uintptr_tandoff_tnor theerrnoconstants there.# main at d3d1cd6: 34 errors. this branch: builds cargo build --target wasm32-unknown-unknown --no-default-features --features bitdepth_8,bitdepth_16This PR keeps the C names and changes where they come from:
src/c_types.rsdefinesptrdiff_t,intptr_tanduintptr_tasisize,isizeandusize, which is howlibcdefines them on every target it supports. The 13 files that imported them fromlibcimport them from there.off_tand theerrnovalues still come fromlibcwherever there is a C library. Onall(target_family = "wasm", target_os = "unknown"),off_tisi64and theerrnovalues are Linux's. Nothing on that target can call the C API, soRav1dErroronly needs them distinct.No other target changes: the types are identical, and the
errnovalues still come fromlibc.With the Rust API from #1439, this is enough to decode in the browser. I checked the nine AVIF fixtures of sqzer (8 and 10 bit, 4:2:0, 4:4:4, monochrome, and an alpha item) through
Decoder::send_dataandget_picturein Node 24: the planes hash the same as from the native build of the same commit.cargo fmt --check,cargo clippy -- -D warningsand the unit tests pass on stable, and clippy passes for the wasm32 target too.Not included: a CI job. A
cargo checkforwasm32-unknown-unknownwith assembly off would keep this from regressing and take about ten seconds. Do you want it in this PR, in a follow-up, or not at all?