briansmith / ring

Safe, fast, small crypto using Rust
Other
3.68k stars 693 forks source link

Improve conditional compilation around PerlAsm #1937

Open nspin opened 6 months ago

nspin commented 6 months ago

build.rs determines whether the target platform is supported by PerlAsm using both target_arch and target_os. Instances of conditional compilation in both src/ and crypto/ were using just target_arch to determine whether PerlAsm symbols are present, resulting in link-time build failures for certain targets, including, for example, aarch64-unknown-none.

This commit fixes those instances of conditional compilation to align with the build script.

I've made the most conservative possible modifications to these cfg conditions, so some of them may contain redundancy. In particular, those that were any(target_arch = "aarch64", target_arch = "arm", target_arch = "x86_64", target_arch = "x86") are now all(have_perlasm, any(target_arch = "aarch64", target_arch = "arm", target_arch = "x86_64", target_arch = "x86")), but it may be the case that some of these ought to just be have_perlasm.

This PR addresses https://github.com/briansmith/ring/issues/1793. As discussed in that issue, the conditions in build.rs for PerlAsm support may be overly conservative, but expanding the set of targets which are deemed to be supported by PerlAsm will be trickier. This PR is just a bug fix that enables platforms such as aarch64-unknown-none to use the fallbacks rather than failing to build at link-time.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.30%. Comparing base (7bc7672) to head (e949d34).

:exclamation: Current head e949d34 differs from pull request most recent head 0e644b7. Consider uploading reports for the commit 0e644b7 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1937 +/- ## ========================================== + Coverage 96.26% 96.30% +0.03% ========================================== Files 140 140 Lines 20401 20855 +454 Branches 226 226 ========================================== + Hits 19639 20084 +445 - Misses 728 737 +9 Partials 34 34 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.