Skip to content

musl crt[begin,end] are being built for ARMv7 for arm targets #85310

Closed
@paxswill

Description

@paxswill

I am unable to build working binaries for arm-unknown-linux-musleabihf targets with an external linker with 1.52.1, but I am able to with 1.51.0. Specifically, what should be ARMv6 binaries are ARMv7, and those binaries will exit after eventually executing an illegal instruction.

cargo-bisect-rustc narrowed the problem down to 130b2ab, and the only thing that looked like it could affect this was #82534. readelf confirms the problem:

$ readelf -A /opt/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-musleabihf/lib/self-contained/crtbegin.o
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_VFP_args: VFP registers
  Tag_ABI_optimization_goals: Aggressive Speed
  Tag_CPU_unaligned_access: v6

Reproduction

It can be reproduced with the example binary from cargo when using an external linker. For example:

# .cargo/config.toml
[target.arm-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-gcc"

I used this bisection script:

#!/bin/sh
cargo build --target arm-unknown-linux-musleabihf
readelf \
        -A ${CARGO_TARGET_DIR}/arm-unknown-linux-musleabihf/debug/${1} \
        | grep -q -e 'ARM v7'

And a slightly different usage of the bisection command (the start date was just what I picked at the time):

cargo bisect-rustc arm-unknown-linux-musleabihf --script ./bisect-script.sh --start 2020-10-01 --regress success --preserve -- example

Meta

rustc --version --verbose:

rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: x86_64-unknown-freebsd
release: 1.52.1
LLVM version: 12.0.0

I seem the same issue on x86_64 Linux releases though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-muslTarget: The musl libcT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions