Skip to content

test: add big-endian architecture Miri validation#150

Merged
membphis merged 1 commit into
mainfrom
test/big-endian-miri-validation
Jun 2, 2026
Merged

test: add big-endian architecture Miri validation#150
membphis merged 1 commit into
mainfrom
test/big-endian-miri-validation

Conversation

@membphis
Copy link
Copy Markdown
Collaborator

@membphis membphis commented Jun 2, 2026

Summary

Add powerpc64-unknown-linux-gnu (big-endian) target to the Miri test matrix, aligning with serde_json's QA practices for endianness validation.

Changes

  • CI: Add powerpc64 Miri FFI tests (ffi_smoke, ffi_cursor, ffi_strings, ffi_ops_interleave) using scalar scanner only (AVX2 is x86_64-only)
  • Tests: Fix c_char signedness for cross-platform compatibility — char is unsigned on PowerPC, signed on x86. Changed as *const i8 to as *const c_char in 6 test files
  • Docs: Add ENDIAN NOTE to src/scan/avx2.rs documenting that the AVX2 scanner is x86_64-only and relies on ISA-fixed bit semantics rather than memory byte order

Why the c_char fix matters

The big-endian Miri test immediately caught a latent ABI mismatch: test files were casting byte pointers to *const i8, but FFI functions expect *const c_char. On PowerPC (and ARM in some configurations), c_char is u8, not i8. This would have broken FFI calls on those platforms.

This demonstrates exactly why big-endian testing is valuable — it surfaces cross-platform assumptions that don't manifest on x86_64.

Verification

  • All powerpc64 Miri tests pass locally
  • All x86_64 tests pass (cargo test --release)
  • Clippy clean (make lint)

Closes #148

Summary by CodeRabbit

  • Tests

    • Continuous integration now validates FFI functionality and library compatibility across additional processor architectures, including big-endian systems (PowerPC64), beyond existing x86 testing
    • Updated FFI pointer types consistently throughout test suites for improved type correctness and cross-platform compatibility
  • Documentation

    • Added documentation clarifying endianness behavior and assumptions in performance-optimized code components

Add powerpc64-unknown-linux-gnu (big-endian) target to the Miri test
matrix, aligning with serde_json's QA practices.

Changes:
- CI: add powerpc64 Miri FFI tests (ffi_smoke, ffi_cursor, ffi_strings,
  ffi_ops_interleave) using scalar scanner only
- Tests: fix c_char signedness for cross-platform compatibility
  (char is unsigned on PowerPC, signed on x86)
- Docs: add ENDIAN NOTE to src/scan/avx2.rs documenting that the AVX2
  scanner is x86_64-only and relies on ISA-fixed bit semantics

The c_char fix demonstrates the value of big-endian testing: it caught
a latent ABI mismatch that would have broken FFI calls on platforms
where char defaults to unsigned.

Closes #148
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d14c2822-1153-486b-a0cb-7342ebf30dfa

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad9d98 and 816cc2f.

📒 Files selected for processing (8)
  • .github/workflows/ci.yml
  • src/scan/avx2.rs
  • tests/ffi_cursor.rs
  • tests/ffi_numbers.rs
  • tests/ffi_strings.rs
  • tests/ffi_typeof.rs
  • tests/ffi_wide_object.rs
  • tests/third_party_fixtures.rs

📝 Walkthrough

Walkthrough

This PR implements big-endian (PowerPC64) architecture validation in the Miri CI test matrix and improves FFI type safety across the test suite by using c_char instead of raw i8 for pointer casts in all FFI function calls.

Changes

Big-Endian Testing Infrastructure and FFI Type Correctness

Layer / File(s) Summary
CI infrastructure for big-endian Miri testing
.github/workflows/ci.yml
CI sanitizers job adds powerpc64-unknown-linux-gnu target to nightly Rust setup and introduces a new Miri FFI test step that validates the scalar scanner against big-endian architecture using the same FFI test suite (ffi_smoke, ffi_cursor, ffi_strings, ffi_ops_interleave).
AVX2 endianness assumptions documentation
src/scan/avx2.rs
Module-level comments document that the AVX2 scanner is x86_64-only (little-endian), explain how _mm256_movemask_epi8 bit-to-lane mapping is fixed by ISA rather than memory byte order, and note that big-endian CI coverage runs only the scalar scanner.
FFI test imports: add c_char type
tests/ffi_cursor.rs, tests/ffi_numbers.rs, tests/ffi_typeof.rs, tests/ffi_strings.rs, tests/ffi_wide_object.rs, tests/third_party_fixtures.rs
All test files update std::os::raw imports to include c_char, providing the correct FFI character type for subsequent pointer casts.
Cursor and string getter FFI type updates
tests/ffi_cursor.rs
qjson_open, cursor field/string/numeric getters, and container operation calls are updated to cast key and path pointers as *const c_char instead of *const i8 across nine test functions.
Number getter FFI type updates
tests/ffi_numbers.rs
All calls to qjson_get_i64, qjson_get_u64, qjson_get_f64, qjson_get_bool, qjson_open, and qjson_cursor_get_u64 are updated to cast key/path pointers as *const c_char across 12 test functions.
String getter FFI type updates
tests/ffi_strings.rs
Three qjson_get_str call sites are updated to cast path.as_ptr() as *const c_char instead of *const i8.
Type inspection FFI type updates
tests/ffi_typeof.rs
Fourteen test functions update qjson_typeof, qjson_is_null, qjson_len, qjson_get_f64, and qjson_get_bool calls to cast name/path pointers as *const c_char.
Wide object sampling FFI type updates
tests/ffi_wide_object.rs
Forward, reverse, and unknown-key sampling loops in qjson_get_i64 calls are updated to cast key pointers as *const c_char.
Third-party fixtures FFI type updates
tests/third_party_fixtures.rs
FFI wrapper functions (get_str, get_i64, get_bool, is_null, len) and menu/matrix/invalid-path fixture tests are updated to cast path/key/empty pointers as *const c_char in all qjson API calls.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding big-endian architecture Miri validation to the test matrix.
Linked Issues check ✅ Passed All functional requirements from issue #148 are met: powerpc64 target added to CI, scalar scanner tests enabled, AVX2 documented, and c_char casting fixed for cross-platform compatibility.
Out of Scope Changes check ✅ Passed All changes align directly with requirements from issue #148: CI configuration, test type casting fixes for FFI ABI compatibility, and documentation of endianness assumptions.
E2e Test Quality Review ✅ Passed PR adds CI infrastructure and type fixes to existing tests, not new E2E tests. The custom check for E2E test quality is not applicable to this infrastructure/compatibility-focused work.
Security Check ✅ Passed PR adds big-endian Miri validation to JSON parser library with proper c_char type safety, endian documentation, and CI workflow updates; no violations of 7 security categories found.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/big-endian-miri-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@membphis membphis merged commit 4d4ea4f into main Jun 2, 2026
16 checks passed
@membphis membphis deleted the test/big-endian-miri-validation branch June 2, 2026 02:08
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.

test: add big-endian architecture Miri validation

1 participant