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

sha1: Apple M1 build failures #28

Closed
tarcieri opened this issue Jan 25, 2021 · 9 comments · Fixed by #38
Closed

sha1: Apple M1 build failures #28

tarcieri opened this issue Jan 25, 2021 · 9 comments · Fixed by #38

Comments

@tarcieri
Copy link
Member

tarcieri commented Jan 25, 2021

As discovered on #27, the aarch64 assembly for the sha1 and sha2 (edit: SHA-256 support added in #35) crates does not compile on macOS/M1:

Compiling sha2-asm v0.5.4
The following warnings were emitted during compilation:

warning: src/sha256_aarch64.S:64:2: error: ADR/ADRP relocations must be GOT relative
warning:  adrp x2, .K
warning:  ^
warning: src/sha256_aarch64.S:64:2: error: unknown AArch64 fixup kind!
warning:  adrp x2, .K
warning:  ^
warning: src/sha256_aarch64.S:65:2: error: unknown AArch64 fixup kind!
warning:  add x2, x2, :lo12:.K
warning:  ^

error: failed to run custom build command for `sha2-asm v0.5.4`
@tarcieri
Copy link
Member Author

tarcieri commented Jan 25, 2021

I wonder if we could cross-compile to aarch64 on a (x86) macOS CI instance to test this...

@lonnylot
Copy link

lonnylot commented Mar 3, 2021

I'm currently trying to install fil-ocl-core and this seems to be throwing an error.

Any update on this or any way I could help make progress?

@tarcieri
Copy link
Member Author

tarcieri commented Mar 3, 2021

@lonnylot for now the asm is incompatible with macOS/M4. If fil-ocl-core is enabling it, they should probably gate it on e.g. Linux/ARM64 targets

@tarcieri
Copy link
Member Author

tarcieri commented Mar 5, 2021

Note that overall I think the best way forward here on the M1 is to use stdarch to leverage the ARMv8 Cryptography Extensions, although unfortunately due to a recent regression the necessary intrinsics are no longer exposed

@Byron
Copy link

Byron commented Apr 3, 2021

The related issue is now this one and a PR is in the making to clean it up. I am hoping that this will provide the required intrinsics to eventually get fast SHA1 on M1's.

@tarcieri
Copy link
Member Author

tarcieri commented Apr 3, 2021

FWIW, here is the assembly generated by a Rust wrapper for the ARMv8 Cryptography Extensions:

https://godbolt.org/z/P8oje3EfK

See also my comment here:

#5 (comment)

@tarcieri
Copy link
Member Author

I opened a tracking issue for stdarch-based intrinsic implementations of hash functions here, which is probably the best way to tackle this particular problem: RustCrypto/hashes#257

@dignifiedquire
Copy link
Member

Given that the intrinsic solution is still a little out there, could we add a second aarch64 implementation for M1 here?

@tarcieri
Copy link
Member Author

Yeah, that's why I provided the assembly output above, unless someone knows of something better for this purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants