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

Add thumbv7neon-* targets. #745

Merged
merged 1 commit into from
Jun 8, 2022
Merged

Add thumbv7neon-* targets. #745

merged 1 commit into from
Jun 8, 2022

Conversation

Alexhuszagh
Copy link
Contributor

@Alexhuszagh Alexhuszagh commented Jun 2, 2022

Add the thumbv7neon-linux-androideabi and thumbv7neon-unknown-linux-gnueabihf targets.

Closes #254.

@Alexhuszagh Alexhuszagh requested a review from a team as a code owner June 2, 2022 19:52
@Alexhuszagh
Copy link
Contributor Author

bors try --target thumbv7neon-unknown-linux-gnueabihf

bors bot added a commit that referenced this pull request Jun 2, 2022
@Alexhuszagh
Copy link
Contributor Author

Alexhuszagh commented Jun 2, 2022

That they correctly use Thumb-2 mode and have ARMv7 architecture with NEON support can be checked by the following: $a relocations mean ARM-mode relocations, $t relocations mean THUMB-mode relocations. Running this over a compiled binary shows there are effectively no ARM-mode relocations, but plenty of THUMB-mode ones.

$ objdump --syms /path/to/binary | grep '$a'
...
000028b4 l       .plt   00000000              $a
...
$ objdump --syms /path/to/binary | grep '$t'
...
00002ac0 l       .plt   00000000              $t
...
$ readelf -A /path/to/binary
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: VFPv4
  Tag_Advanced_SIMD_arch: NEONv1 with Fused-MAC
  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

Which is our expected output: HF (as detected by VFP registers), 7-a architecture, Thumb-2, and NEONv1 SIMD instructions. The binaries also run in qemu. I'll try to work on thumv7neon-linux-androideabi later.

Not sure if we have to specify AR_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar, since the Android image failed if this wasn't defined. However, this works perfectly fine with a C++-compiled crate.

@Alexhuszagh
Copy link
Contributor Author

Alexhuszagh commented Jun 2, 2022

OK I'm pretty certain the failing runner is due to the older Qemu version: we need Cortex-A12 or higher to support these thumbv7neon features I believe, and Qemu 5.10 only supports up to Cortex-A9. See the features of ARM processors. I might be able to get the Android version to work by updating the Qemu version. Nevermind. Still fails.

UPDATE: Turns out this is a docker issue. Adding DOCKER_OPTS=--privileged" fixes this with docker or podman, as does DOCKER_OPTS="--security-opt seccomp=unconfined". I'll see if there's a way to whitelist on personality`, as described here.

Adding the following seccomp profile should work:

{
  "names": [
    "personality"
  ],
  "action": "SCMP_ACT_ALLOW"
}

But then we need to provide this properly, which means we might need a data directory or something so we can write the seccomp profile and then use it when passing to the container.

@bors
Copy link
Contributor

bors bot commented Jun 2, 2022

try

Build succeeded:

@Alexhuszagh Alexhuszagh marked this pull request as draft June 2, 2022 20:49
@Alexhuszagh Alexhuszagh marked this pull request as ready for review June 3, 2022 01:01
@Alexhuszagh Alexhuszagh changed the title Add thumbv7neon-unknown-linux-gnueabihf target. Add thumbv7neon-* targets. Jun 3, 2022
@Alexhuszagh
Copy link
Contributor Author

bors try --target thumbv7neon-linux-androideabi --target thumbv7neon-unknown-linux-gnueabihf --target thumbv7neon-unknown-linux-musleabihf

bors bot added a commit that referenced this pull request Jun 3, 2022
…-unknown-linux-gnueabihf --target thumbv7neon-unknown-linux-musleabihf
@Alexhuszagh
Copy link
Contributor Author

bors cancel
bors try --target thumbv7neon-linux-androideabi --target thumbv7neon-unknown-linux-gnueabihf

@bors
Copy link
Contributor

bors bot commented Jun 3, 2022

try

Already running a review

@Alexhuszagh
Copy link
Contributor Author

Alexhuszagh commented Jun 3, 2022

Update: Forgot that thumbv7neon-unknown-linux-musleabihf is tier 3, and therefore needs to have Rust compiled for it..

@Alexhuszagh Alexhuszagh added enhancement A-android Area: android targets A-arm Area: ARM targets labels Jun 3, 2022
@Alexhuszagh
Copy link
Contributor Author

bors try --target thumbv7neon-linux-androideabi --target thumbv7neon-unknown-linux-gnueabihf

@bors
Copy link
Contributor

bors bot commented Jun 3, 2022

try

Already running a review

@bors
Copy link
Contributor

bors bot commented Jun 3, 2022

try

Build succeeded:

@Alexhuszagh Alexhuszagh force-pushed the neonv7 branch 2 times, most recently from 781c3d9 to 10304dc Compare June 8, 2022 16:04
Add the `thumbv7neon-linux-androideabi` and `thumbv7neon-unknown-linux-gnueabihf` targets.

Closes cross-rs#254.
@otavio
Copy link
Contributor

otavio commented Jun 8, 2022

Anything still pending for this?

@Alexhuszagh
Copy link
Contributor Author

@otavio Don't believe so, if the changes look good we should be able to merge. I've checked the readelf architecture output and it looks good.

@otavio
Copy link
Contributor

otavio commented Jun 8, 2022

bors r+

bors bot added a commit that referenced this pull request Jun 8, 2022
745: Add `thumbv7neon-*` targets. r=otavio a=Alexhuszagh

Add the `thumbv7neon-linux-androideabi` and `thumbv7neon-unknown-linux-gnueabihf` targets.
    
Closes #254.

746: Limit permissions for Android images. r=otavio,emilgardis a=Alexhuszagh

Remove the use of the `--privileged` flag for Android images and instead use an seccomp permissions. The provided profile is derived from the docker documentation, with slight modifications to allow `clone` and `clone3`.

The documentation is [docker seccomp](https://docs.docker.com/engine/security/seccomp/#significant-syscalls-blocked-by-the-default-profile), which details the syscalls blocked by docker. The same is true for podman. We merely modified these settings to allow `personality` syscall, which then allows us to use our Android images.

Co-authored-by: Alex Huszagh <[email protected]>
@Alexhuszagh
Copy link
Contributor Author

bors r-

This is going to conflict with #746, going to have to rebase it slightly. I'll merge this with bors r=Otavio when the other is merged and this is rebased.

@bors
Copy link
Contributor

bors bot commented Jun 8, 2022

Canceled.

@Alexhuszagh
Copy link
Contributor Author

EDIT: I may be wrong. My mistake, I think I undid those issues. I guess the seccomp isn't going to conflict.

bors r=Otavio

@bors bors bot merged commit ee2fc1b into cross-rs:main Jun 8, 2022
@bors
Copy link
Contributor

bors bot commented Jun 8, 2022

Build succeeded:

@Emilgardis Emilgardis added this to the v0.2.2 milestone Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-android Area: android targets A-arm Area: ARM targets enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new thumbv7neon_linux_androideabi and thumbv7neon-unknown-linux-gnueabihf targets
3 participants