Skip to content

run miri for a big-endian target#3312

Open
Skgland wants to merge 10 commits into
mthom:masterfrom
Skgland:big-endian-miri
Open

run miri for a big-endian target#3312
Skgland wants to merge 10 commits into
mthom:masterfrom
Skgland:big-endian-miri

Conversation

@Skgland
Copy link
Copy Markdown
Contributor

@Skgland Skgland commented Apr 25, 2026

Currently I expect CI to fail, after #3311 this should pass.

Add a new crypto feature so that crypto dependencies can be disabled so that this works without having to setup native libraries and toolchain for the big-endian target.

> cargo +nightly miri test --lib --target s390x-unknown-linux-gnu --no-default-features --features=repl,hostname

<!-- SNIP --> 

failures:

---- arena::tests::heap_put_literal_tests stdout ----

thread 'arena::tests::heap_put_literal_tests' (1003) panicked at src/arena.rs:734:17:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect


failures:
    arena::tests::heap_put_literal_tests

test result: FAILED. 29 passed; 1 failed; 42 ignored; 0 measured; 0 filtered out; finished in 81.65s

error: test failed, to rerun pass `--lib`
> git merge eac7ff680ce7a9f95bc88daaa7c0339f2bf494b8
> cargo +nightly miri test --lib --target s390x-unknown-linux-gnu --no-default-features --features=repl,hostname

<!-- SNIP --> 

test result: ok. 30 passed; 0 failed; 42 ignored; 0 measured; 0 filtered out; finished in 81.74s

Skgland added 5 commits April 22, 2026 22:16
it is identical to HeapCellValueTag
by wrapping BranchNumber in an Arc.
PermVarAllocation::Done had size 208 and is now down to 32.
A Box rather than an Arc would be smaller, but it looks like BranchNumber/BranchDesignator are clones a bunch so I expect it to be beneficial to reduce allocations both of the Box itself as well as its content.
rather than passing an address as usize pass the ArenaHeader pointer
similarly don't return a u8 ptr but use a ArenaHeader pointer instead

Don't convert the pointer to a ConsPtr by going through native endian
bytes in between.
We are exploiting the fact that the 3 least significant bytes are zero
for pointer to types of alignment 8 and we expect these to line up with
the f, m, and tag field at the end of the ConsPtr struct, but using
native endiannes for this would only work on big endian systems.
the old logic would be incorrect if the payload has higher alignment than the ArenaHeader i.e. when there is padding between the ArenaHeader and the Payload
@Skgland
Copy link
Copy Markdown
Contributor Author

Skgland commented Apr 25, 2026

Marking as draft while I fiddle with CI

@Skgland Skgland marked this pull request as draft April 25, 2026 19:48
@triska
Copy link
Copy Markdown
Contributor

triska commented Apr 25, 2026

Why is it necessary to disable so much functionality for this? Would it not be much preferable if this functionality were tested on big-endian targets too, especially due to its criticality?

@Skgland Skgland force-pushed the big-endian-miri branch 7 times, most recently from 8ac45c7 to 777c004 Compare April 25, 2026 20:38
@Skgland
Copy link
Copy Markdown
Contributor Author

Skgland commented Apr 25, 2026

I got cross-compilation with the crypto-full and ffi features working.

Not working is

  • features http and tls, fail at cross-compiling openssl
  • running tests outside of miri
    • tried using qemu-system-s390x with qemu-user-binfmt but couldn't get it working

@Skgland Skgland force-pushed the big-endian-miri branch 3 times, most recently from 71f1de3 to 7dbd441 Compare April 25, 2026 21:30
@Skgland
Copy link
Copy Markdown
Contributor Author

Skgland commented Apr 25, 2026

I give up on getting openssl cross-compilation and running test via qemu working.
Maybe someone else can figure that out.

As such I consider this ready.

@Skgland Skgland marked this pull request as ready for review April 25, 2026 22:10
@Skgland
Copy link
Copy Markdown
Contributor Author

Skgland commented Apr 25, 2026

As such I consider this ready.

Well, with the caveat that it requires #3311 to actually pass CI.

@triska
Copy link
Copy Markdown
Contributor

triska commented Apr 26, 2026

None of the hash functions or signing and key exchange functionality requires OpenSSL, is it really necessary to make so much optional? I would hope this compiles on many more platforms, at least that was a key motivation for me to implement much of the cryptographic functionality so that it does not require OpenSSL.

@Skgland
Copy link
Copy Markdown
Contributor Author

Skgland commented Apr 26, 2026

None of the hash functions or signing and key exchange functionality requires OpenSSL, is it really necessary to make so much optional? I would hope this compiles on many more platforms, at least that was a key motivation for me to implement much of the cryptographic functionality so that it does not require OpenSSL.

Initially I hadn't cross-compilation working yet so I had to gate the crypto functions depending on ring.
I didn't have a better name for the feature gate than just crypto and then it felt odd to have crypto function that would work without that feature, so all got gated.

Given that I got cross-compilation of ring working the first commit adding the crypto feature isn't strictly necessary anymore so I could drop that commit.

Having a way to build without non-rust dependencies might still be nice.

@triska
Copy link
Copy Markdown
Contributor

triska commented Apr 27, 2026

Having a way to build without non-rust dependencies might still be nice.

Yes indeed, and much of the cryptographic functionality is entirely Rust-based. For instance, the Ed25519 and Curve25519 functionality for signing and key exchange, and crypto_curve_scalar_mult, use the excellent crrl crate which to the best of my knowledge is entirely Rust-based. It would be great to have this functionality on all targets, I see no reason to make its compilation optional if it compiles successfully.

@Skgland
Copy link
Copy Markdown
Contributor Author

Skgland commented Apr 27, 2026

Marking this as draft until I get around to dropping commit 9648607 from this PR.

I intend to open a separate PR for making ring optional.
Currently considering ring-crypto or crypto-ring for the feature name as I don't think crypto as a feature name fits if it doesn't disable/enable all crypto functions.
@triska do you maybe have an idea/suggestions for what to name the feature?

@Skgland Skgland marked this pull request as draft April 27, 2026 11:37
@triska
Copy link
Copy Markdown
Contributor

triska commented Apr 27, 2026

an idea/suggestions for what to name the feature?

It sounds like what could be useful also more generally is to compile Scryer exclusively with those parts that are implemented natively in Rust, so maybe rust-only, would that make sense and be useful for supporting as many platforms as possible?

@Skgland Skgland marked this pull request as ready for review April 27, 2026 19:33
@Skgland
Copy link
Copy Markdown
Contributor Author

Skgland commented May 8, 2026

merged #3311 into this, to get the fix this is adding testing for, so that CI is green

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.

2 participants