rust-lang / rust-lang/rust

Unable to target armv6 with arm-unknown-linux-gnueabihf C toolchain

Open
#145,264 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-external-bug O-Arm S-needs-info T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

fn main() {
    println!("Hello World!");
}

I expected to see this happen: Running the program outputs Hello World!.

Instead, this happened: I get an Segmentation fault.

Meta

rustc --version --verbose on host machine:

rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7

rustc --version --verbose on target machine:

rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: arm-unknown-linux-gnueabihf
release: 1.89.0
LLVM version: 20.1.7
gdb Backtrace; cargo command; linker info; comments

gdb backtrace

Starting program: /tmp/_hw 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x004575a6 in ?? ()
(gdb) bt
#0  0x004575a6 in ?? ()
#1  0x004083f2 in _start ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) disas 0x004575a6
No function contains specified address.
(gdb) disas 0x004083f2
Dump of assembler code for function _start:
   0x004083e0 <+0>:     mov.w   r11, #0
   0x004083e4 <+4>:     mov.w   lr, #0
   0x004083e8 <+8>:
/build/gdb-rWAb4D/gdb-13.1/gdb/displaced-stepping.c:287: internal-error: copy_insn_closure_by_addr: Assertion `buffer.copy_insn_closure.get () != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0xdf18b ???
0x469edf ???
0x46a163 ???
0x5cb6df ???
0x1734ef ???
0x93f5f ???
0x940a7 ???
0x16fb0f ???
0x171163 ???
0x171763 ???
0x17213b ???
0x1098cb ???
0x10cf97 ???
0x112767 ???
0x42910b ???
0x1f3ad3 ???
0x1f4d47 ???
0x1f3363 ???
---------------------
/build/gdb-rWAb4D/gdb-13.1/gdb/displaced-stepping.c:287: internal-error: copy_insn_closure_by_addr: Assertion `buffer.copy_insn_closure.get () != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

Tested cargo command/configs

RUSTFLAGS="-C target-cpu=arm1176jz-s -C linker=arm-linux-gnueabihf-gcc-12" cargo build --target arm-unknown-linux-gnueabihf 
RUSTFLAGS="-C target-cpu=generic -C linker=arm-linux-gnueabihf-gcc-12" cargo build --target arm-unknown-linux-gnueabihf 

Target machine information

As I also tested compiling running on the target machine directly (which worked):

arm-linux-gnueabihf-g++-12 --version:

arm-linux-gnueabihf-g++-12 (Raspbian 12.2.0-14+rpi1) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Cross compiling machine information

arm-linux-gnueabihf-g++-12 --version:

arm-linux-gnueabihf-g++-12 (Ubuntu 12.3.0-17ubuntu1) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Further information

  • A rust panic-backtrace is not produced
    • I'd wager that this is because it segfaults in start()
  • Compiling and running on target machine works as expected (Also with explicit target/target-cpu/linker as with cross)
  • Same behavior with debug/release
  • Same behavior with 1.88, 1.89, nightly
  • Emitted Rust assembly (as compared with --emit=asm) seems to produce identical assembly instructions (sans addresses, identifiers, etc.)
  • Arguments to ld (as compared with strace -s99999 -fv -e trace=clone,execve) seem to be identical
  • Disassembly with arm-linux-gnueabihf-objdump -d --demangle=rust --no-show-raw-insn --no-addresses produces different output which I cannot compare correctly as I don't know of a tool that can diff the outputs while taking ordering/naming changes into account
  • More complex programs sporadically produce SIGILLs that, when debugged with gdb, seem to happen on a bt which seems to be the same instruction when compiled on the target machine - but I could not yet reproduce the SIGILL with a simple program
  • Target machine is Raspberry Pi Model B Rev 2 with architecture armhf

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The payload names no repository files or tests. Start by reproducing the reported cargo build with the arm-unknown-linux-gnueabihf target and the two target-cpu settings, then compare the resulting behavior on the Raspberry Pi with a target-native build. Done means identifying why the cross-built Hello World binary faults and documenting or validating a focused fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.