Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
paxswill opened this issue May 14, 2021 · 1 comment · Fixed by #85395
Closed

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

paxswill opened this issue May 14, 2021 · 1 comment · Fixed by #85395
Labels
C-bug Category: This is a bug. O-musl Target: The musl libc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@paxswill
Copy link

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.

@paxswill paxswill added the C-bug Category: This is a bug. label May 14, 2021
@jonas-schievink jonas-schievink added the O-musl Target: The musl libc label May 14, 2021
@petrochenkov petrochenkov added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label May 15, 2021
@petrochenkov
Copy link
Contributor

This is a rustbuild issue, in -C link-self-contained=yes mode (which is on by default for some musl targets until rust-lang/compiler-team#422 is implemented) rustc will link whatever crt objects are found in lib/rustlib/<target>/lib/self-contained, and rustbuild is responsible for putting the crt object files there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-musl Target: The musl libc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants