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

arm-unknown-linux-gnueabihf produces armv7 output not armv6 #38570

Closed
mkj opened this issue Dec 23, 2016 · 5 comments
Closed

arm-unknown-linux-gnueabihf produces armv7 output not armv6 #38570

mkj opened this issue Dec 23, 2016 · 5 comments
Labels
O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state

Comments

@mkj
Copy link

mkj commented Dec 23, 2016

I'm cross compiling on x64 Linux to a Raspberry Pi 1, Raspbian Jessie. Binaries produced by arm-unknown-linux-gnueabi target work fine, binaries from arm-unknown-linux-gnueabihf segfault in _start().

Readelf tells me that the arm-unknown-linux-gnueabihf target is actually armv7, which contradicts https://forge.rust-lang.org/platform-support.html

~/src/rusthello> readelf -A target/*/debug/rusthello 

File: target/arm-unknown-linux-gnueabi/debug/rusthello
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "ARM v6"
  Tag_CPU_arch: v6                                           <--
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_ABI_PCS_GOT_use: GOT-indirect
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_rounding: Needed
  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_enum_size: int
  Tag_CPU_unaligned_access: v6
  Tag_ABI_FP_16bit_format: IEEE 754

File: target/arm-unknown-linux-gnueabihf/debug/rusthello
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_GOT_use: GOT-indirect
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_rounding: Needed
  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_enum_size: int
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6
  Tag_ABI_FP_16bit_format: IEEE 754

File: target/armv7-unknown-linux-gnueabihf/debug/rusthello
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_GOT_use: GOT-indirect
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_rounding: Needed
  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_enum_size: int
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6
  Tag_ABI_FP_16bit_format: IEEE 754

rustc 1.14.0 (e8a012324 2016-12-16)
binary: rustc
commit-hash: e8a0123241f0d397d39cd18fcc4e5e7edde22730
commit-date: 2016-12-16
host: x86_64-unknown-linux-gnu
release: 1.14.0
LLVM version: 3.9
@sanxiyn sanxiyn added the O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state label Dec 23, 2016
@japaric
Copy link
Member

japaric commented Dec 23, 2016

I think this may be your cross toolchain's fault because all the Rust side is v6, AFAICT:

$ readelf -A $(rustc --print sysroot)/lib/rustlib/arm-unknown-linux-gnueabihf/lib/*.rlib | grep Tag_CPU_arch
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
(..)

If you are using the gcc-arm-linux-gnueabihf package that ships with Ubuntu, that would be problem because that toolchain targets ARMv7.

$ readelf -A /usr/arm-linux-gnueabihf/lib/crt1.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_rounding: Needed
  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_CPU_unaligned_access: v6

You should use the toolchain in the raspberrypi/tools repo or build your own but that targets v6.

@mkj
Copy link
Author

mkj commented Dec 23, 2016

Thank you @japaric , that is the problem. I was using the Ubuntu toolchain, the raspberrypi one works as expected.
Sorry for the noise.

@cubetastic33
Copy link

cubetastic33 commented Sep 24, 2018

@japaric

I think this may be your cross toolchain's fault because all the Rust side is v6, AFAICT:

$ readelf -A $(rustc --print sysroot)/lib/rustlib/arm-unknown-linux-gnueabihf/lib/*.rlib | grep Tag_CPU_arch
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
  Tag_CPU_arch: v6
(..)

If you are using the gcc-arm-linux-gnueabihf package that ships with Ubuntu, that would be problem because that toolchain targets ARMv7.

$ readelf -A /usr/arm-linux-gnueabihf/lib/crt1.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_rounding: Needed
  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_CPU_unaligned_access: v6

You should use the toolchain in the raspberrypi/tools repo or build your own but that targets v6.

I don't understand what to do. I do face a similar issue, I am trying to cross-compile to ARMv6 from Ubuntu. How am I supposed to do this?

@moriyas1984
Copy link

Any update?

I also need some directions to cross-compile to ARMv6 from Ubuntu.

Regards.

@moriyas1984
Copy link

Sorry, I have understood how to use it.

BurntSushi/ripgrep#676 (comment)

This comment told me how I should specify the linker in raspberrypi/tools.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
Projects
None yet
Development

No branches or pull requests

5 participants