Build fails on ARM64/aarch64: u8: From<i8> not satisfied in nal.rs #843

Open
opened 2026-01-29 16:54:57 +00:00 by claunia · 0 comments
Owner

Originally created by @x15sr71 on GitHub (Oct 21, 2025).

Compilation error on aarch64 Linux: u8: From<i8> not satisfied in ccx_rust

Environment

  • OS: Ubuntu 25.04 (Plucky Puffin)
  • Architecture: aarch64 (ARM64)
  • Rust Version: 1.54.0
  • Cargo Version: 1.54.0
  • libc6-dev: 2.41-6ubuntu1.2
  • GCC: 14.2.0

Description

I'm hitting a compilation failure when trying to build CCExtractor on my ARM64 Ubuntu machine:

error[E0277]: the trait bound `u8: From<i8>` is not satisfied
  --> src/avc/nal.rs:599:20
    |
599 |     let mut buf = [c_char::from(0i8); 64];
    |                    ^^^^^^^^^^^^^^^^^ the trait `From<i8>` is not implemented for `u8`

Root Cause

After some digging, I found that c_char behaves differently depending on your CPU architecture:

Architecture c_char type Build Status
x86_64 (Linux) i8 (signed) Compiles
aarch64 (Linux) u8 (unsigned) Fails

The Rust docs mention this - c_char matches whatever C's char type is on that platform, and the C standard leaves it up to each implementation to decide if char is signed or unsigned.

So on x86_64, c_char::from(0i8) works fine because c_char is i8. But on ARM64, c_char is u8, and Rust doesn't let you convert i8 to u8 automatically (makes sense - negative numbers would be a problem).

Steps to Reproduce

  1. Grab an ARM64 machine running Ubuntu (VM, container, whatever works)
  2. Install the usual build tools:
    sudo apt-get update
    sudo apt-get install build-essential pkg-config rustc cargo
    
  3. Clone and try to build:
    git clone https://github.com/CCExtractor/ccextractor.git
    cd ccextractor/linux
    ./build
    
  4. Watch it fail at src/rust/src/avc/nal.rs:599

Build Logs

Image

Full error output (click to expand)

Expected Behavior

Should build cleanly on both x86_64 and ARM64.

Actual Behavior

Builds fine on x86_64, crashes on ARM64 with the trait bound error above.

Comparison Testing

Machine OS Arch Rust GCC Result
VM Ubuntu 25.04 "Plucky" aarch64 1.54.0 14.2.0 Fails
Laptop Ubuntu 24.04.2 LTS "Noble" x86_64 1.90.0 13.3.0 Builds

Proposed Solution

The fix is pretty straightforward. In src/rust/src/avc/nal.rs at line 599, change:

let mut buf = [c_char::from(0i8); 64];

to:

let mut buf = [0 as c_char; 64];

I tested this on both my ARM64 VM and x86_64 laptop - builds successfully on both now.

Why this works:

  • Zero is zero whether you're dealing with signed or unsigned chars
  • The as cast handles both i8 and u8 without issues
  • We're still initializing the buffer to null bytes, just in a more portable way

Additional Context

This isn't unique to CCExtractor - it's a common gotcha when writing Rust FFI code. Different architectures treat char differently:

  • ARM/AArch64: unsigned char
  • x86/x86_64: signed char
  • PowerPC: unsigned char

This will affect anyone trying to build on ARM64 Linux, not just Ubuntu 25.04.

Impact

  • Severity: High - completely blocks builds on ARM64
  • Affected platforms: All ARM64/AArch64 Linux distros

Will be submitting a PR shortly with the above fix!

Originally created by @x15sr71 on GitHub (Oct 21, 2025). # Compilation error on aarch64 Linux: `u8: From<i8>` not satisfied in ccx_rust ## Environment - **OS:** Ubuntu 25.04 (Plucky Puffin) - **Architecture:** aarch64 (ARM64) - **Rust Version:** 1.54.0 - **Cargo Version:** 1.54.0 - **libc6-dev:** 2.41-6ubuntu1.2 - **GCC:** 14.2.0 ## Description I'm hitting a compilation failure when trying to build CCExtractor on my ARM64 Ubuntu machine: ``` error[E0277]: the trait bound `u8: From<i8>` is not satisfied --> src/avc/nal.rs:599:20 | 599 | let mut buf = [c_char::from(0i8); 64]; | ^^^^^^^^^^^^^^^^^ the trait `From<i8>` is not implemented for `u8` ``` ## Root Cause After some digging, I found that `c_char` behaves differently depending on your CPU architecture: | Architecture | `c_char` type | Build Status | |-------------------|---------------|--------------| | x86_64 (Linux) | `i8` (signed) | ✅ Compiles | | aarch64 (Linux) | `u8` (unsigned)| ❌ Fails | The [Rust docs](https://doc.rust-lang.org/stable/std/os/raw/type.c_char.html) mention this - `c_char` matches whatever C's `char` type is on that platform, and the C standard leaves it up to each implementation to decide if `char` is signed or unsigned. So on x86_64, `c_char::from(0i8)` works fine because `c_char` is `i8`. But on ARM64, `c_char` is `u8`, and Rust doesn't let you convert `i8` to `u8` automatically (makes sense - negative numbers would be a problem). ## Steps to Reproduce 1. Grab an ARM64 machine running Ubuntu (VM, container, whatever works) 2. Install the usual build tools: ```bash sudo apt-get update sudo apt-get install build-essential pkg-config rustc cargo ``` 3. Clone and try to build: ```bash git clone https://github.com/CCExtractor/ccextractor.git cd ccextractor/linux ./build ``` 4. Watch it fail at `src/rust/src/avc/nal.rs:599` ## Build Logs <details> ![Image](https://github.com/user-attachments/assets/df572dad-a3aa-4dfd-af06-c7f2ad34ad4d) <summary>Full error output (click to expand)</summary> </details> ## Expected Behavior Should build cleanly on both x86_64 and ARM64. ## Actual Behavior Builds fine on x86_64, crashes on ARM64 with the trait bound error above. ## Comparison Testing | Machine | OS | Arch | Rust | GCC | Result | |---------|----------------------------|---------|-------|-------|---------| | VM | Ubuntu 25.04 "Plucky" | aarch64 | 1.54.0| 14.2.0| ❌ Fails | | Laptop | Ubuntu 24.04.2 LTS "Noble" | x86_64 | 1.90.0| 13.3.0| ✅ Builds| ## Proposed Solution The fix is pretty straightforward. In `src/rust/src/avc/nal.rs` at line 599, change: ```rust let mut buf = [c_char::from(0i8); 64]; ``` to: ```rust let mut buf = [0 as c_char; 64]; ``` I tested this on both my ARM64 VM and x86_64 laptop - builds successfully on both now. Why this works: - Zero is zero whether you're dealing with signed or unsigned chars - The `as` cast handles both `i8` and `u8` without issues - We're still initializing the buffer to null bytes, just in a more portable way ## Related Issues & References - **Rust documentation on `c_char`:** https://doc.rust-lang.org/stable/std/os/raw/type.c_char.html - **C Standard (ISO/IEC 9899):** Section 6.2.5 - Plain `char` signedness is implementation-defined ## Additional Context This isn't unique to CCExtractor - it's a common gotcha when writing Rust FFI code. Different architectures treat `char` differently: - ARM/AArch64: unsigned char - x86/x86_64: signed char - PowerPC: unsigned char This will affect anyone trying to build on ARM64 Linux, not just Ubuntu 25.04. ## Impact - **Severity:** High - completely blocks builds on ARM64 - **Affected platforms:** All ARM64/AArch64 Linux distros --- Will be submitting a PR shortly with the above fix!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#843