Skip to content

Fix compilation error caused by custom backend errors on backend override - #876

Merged
newpavlov merged 10 commits into
masterfrom
move_custom_errors
Nov 16, 2026
Merged

newpavlov merged 10 commits into
masterfrom
move_custom_errors

Conversation

@newpavlov

Copy link
Copy Markdown
Member

This fixes potential compilation errors when backend defining a custom error is overridden using getrandom_backend.

Additionally ensures that all custom errors use unique error codes.

@ryanhossain9797

ryanhossain9797 commented Nov 6, 2026 •

Copy link
Copy Markdown

Small question: moving the win7 check above the unsupported / extern_impl overrides means that on a -win7-windows- target, --cfg getrandom_backend="unsupported" (or extern_impl) would now pick windows_legacy instead right? Is that the desired behavior?

@newpavlov

Copy link
Copy Markdown
Member Author

Good catch! I will move it below other getrandom_backend entries later.

@newpavlov newpavlov changed the title Move definition of custom backend errors to the errors module Move definition of custom backend errors to the error module Nov 7, 2026
@newpavlov newpavlov changed the title Move definition of custom backend errors to the error module Fix compilation error caused by custom backend errors on backend override Nov 7, 2026
@patrick-immometrica

Copy link
Copy Markdown
Contributor

This breaks two targets that build fine on master:

cargo +nightly check -Zbuild-std=core,alloc --target wasm64-unknown-unknown --features wasm_js
cargo +nightly check -Zbuild-std=core,alloc --target x86_64-unknown-motor

Both fail with E0599. WEB_CRYPTO is still gated on target_arch = "wasm32" although wasm_js is used on wasm64 since #848, and the RDRAND consts miss all(target_arch = "x86_64", target_os = "motor"). On master these errors just lose their description ("Unknown Error: ...").

@josephlr josephlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We also need to move the errors in src/backends/efi_rng.rs

Otherwise, looks good to me! Nice cleanup.

Comment thread src/error.rs Resolved
stable-x86_64-gnu,
stable-i686-gnu,
stable-i686-msvc,
stable-x86_64-msvc,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This drops our 32-bit Windows support, and we have special handling for 32-bit Windows in

#[cfg_attr(
target_arch = "x86",
link(
name = "bcryptprimitives",
kind = "raw-dylib",
import_name_type = "undecorated"
)
)]

Do we want to find some way to keep these working somehow? We can also figure out how to add them back in a follow-up PR if that's easier.

@newpavlov newpavlov Nov 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Personally, I don't care about 32 bit Windows targets, so I would be fine with not testing them in CI.

Ideally, the CI failures should be fixed in a separate PR (either by removing the targets like I did here, or by fixing them properly), but I just wanted for CI to pass.

@patrick-immometrica

Copy link
Copy Markdown
Contributor

Thanks, both now build at 767f5b7 (wasm64-unknown-unknown with wasm_js and x86_64-unknown-motor). Re the efi_rng.rs errors: they currently use codes 10 and 11, the same as IOS_RANDOM_GEN and VXWORKS_RAND_SECURE, so moving them into error.rs would also need new codes.

@newpavlov
newpavlov merged commit 967752d into master Nov 16, 2026
82 checks passed
@newpavlov
newpavlov deleted the move_custom_errors branch November 16, 2026 10:56
@newpavlov newpavlov mentioned this pull request Nov 17, 2026
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.

4 participants