-
Notifications
You must be signed in to change notification settings - Fork 730
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
assert!(cfg!(target_feature = "sse") && cfg!(target_feature = "sse2")) panic at build on i386, i586, FreeBSD, or many target_os=none x86 targets. #1999
Comments
What are the steps to reproduce? |
See the attached log above ☝️ Looks like
|
What do you get when you do this?
For me, rustc indicates that sse and sse2 are there. I see in your build log that there are warnings that Make sure you're not disabling SSE/SSSE2 in .cargo/config.toml or otherwise. |
Seems like rust is configured for pentiumpro (no SSEx) in the FreeBSD ports tree? |
At https://www.freebsd.org/releases/14.0R/hardware/#proc-i386, it is written:
|
FreeBSD 15.0 hasn't been released yet, so this is in the future. For me, this blocks e.g. Do we amend the i386 target on FreeBSD, for rust? @MikaelUrankar I know you're familiar with the FreeBSD rust porting, what do you suggest here? Perhaps we should discuss this in bugzilla? |
Note that you can build ring with If you actually want ring to support x86 systems that don't have SSE2, then we'd need somebody to submit a PR that adds the runtime checking for SSE2 to every assembly language function called. They are easy to find; look for |
I'll just note that I'm observing the same problem for the
This is seen for
|
Yes, the also applies to that target. |
@briansmith I'd like to help out supporting the i586 target. After looking into the code, I have no clue what exactly I should do. Also looking at |
this also affects Debian's i386 arch, since that has neither SSE nor SSE2. not building ring anymore there would remove a huge chunk of Rust packages in turn. is anybody already working on such a conditionalizing patch? |
I've written a patch that forces a generic no-asm build on x86 targets without sse2 and uploaded it to Debian. Obviously this is not optimal, runtime detection would be better but it stops this being a rc bug for us. |
I am open to addressing this issue but I don't intend to work on it myself any time soon except to review a PR that fixes it and which is tested in GitHub Actions CI in some way. I suggest we use i586-unknown-linux-gnu as the target to test in GitHub Actions. The PR should make the SSE/SSE2 detection work like other feature detection currently works and which matches the current (at the time of reviewing the PR) coding conventions in ring. |
@briansmith I'm completly open to make the PR. It would just be very helpful if you could show me a single location where action is required and what needs to be done. The rest can be done by me. |
I suggest you do this with In some cases, the assembly code already depends on some other feature, like AES-NI. In that case, we can change You can get a sense for how much work this is by going through the code looking for "prefixed_extern!" that has a |
Thx for this comprehensive guide. I'll do my best to implement that. |
Great! In terms of testing, look at how qemu is used in CI to test on older CPUs. Then you can run |
@briansmith would it help if a PR was made with the patch that debian is using? It looks okay to me. Here is the comparison, it needs to be rebased but will look the same: main...redox-os:ring:redox-0.17.8 |
Patch from Debian Fixes briansmith#1999
After PR #2295 is merged, it will be very clear what needs to be done to resolve this properly:
Note that BoringSSL, last year, discarded the non-SSE2 code in bn_mul_,mont because they were never testing it. That makes me am glad we discarded it beforehand. |
That patch doesn't look good to me, as it disables all CPU feature detection on x86, AFAICT. That will destroy performance. What we really want is to use the fast implementations when SIMD is available based on dynamic CPU feature detection, and fall back to the slow fallback implementations only when absolutely necessary. |
PR #2346 lays the foundation for adding dynamic detection of SSE/SSE2 to ring to targets that don't enable SSE/SSE2 by default. In that PR (and the ones leading up to it) I have cited the relevant sections of the Intel documentation and left breadcrumbs regarding what needs to be updated if/when we add SSE/SSE2 dynamic detection. I would appreciate people taking a look at that PR. Also, in ci.yml, in the
...
The |
Hi @plugwash, thank you for your work adapting ring to work with Debian's platform support policies. I saw your patch that you linked above. I think it would be great if we could have the Debian patch adjusted so that on systems where SSE2 isn't the baseline (target_feature = "sse2" is false), ring would still use the SSE2 (and SSSE3, and AES-NI, etc.) implementations if it detects that the CPU supports the SIMD features. Here are some notes on your patch:
This patch isn't necessary to keep ring working on SSE2-less systems. And it is harmful because it prevents ring from using the AES-NI implementation, which is much, much, much faster.
Here, the final else branch can be patched to something like:
This will keep ring working well for the vast majority of people who have SSSE3 and later features, while keeping it working for people who don't.
However, I really think the 0.17.8 patch should be improved to minimize the harm it does. Or, I can reprioritize the release of 0.17.9 and we can work together to minimize the harm of the 0.17.9 patching. |
Also, since you're a Debian maintainer, this is just as good of a place as any to note that I intend for the 0.17.9 release to also have MSRV 1.63, (ring 0.17.8 MSRV was 1.61, IIRC, but Debian Stable has Rust 1.63, IIUC.) |
Bad example, as that function actually doesn't require SSE. chacha.rs doesn't need to be patched at all, for x86, in the main branch, or in 0.17.8. |
AFAICT, montgomery.rs is the only place that needs to be patched for SSE2, under the very reasonable assumption that every AES-NI-capable CPU will support SSE2 (the CPU and OS must already support SSE registers for AES-NI to work). |
To make the patching easier, I've submitted PR #2358. |
PR #2361 brings in BoringSSL's checks for SSE2 on the C side, and changes build.rs to automatically pass "-msse2" to the C compiler for x86 targets. |
In PR #2359, I added a requirement that SSSE3 be detected in order to use AES-NI. (Technically SSE2 is all that is required but I don't think there are any non-SSSE3 AES-NI-capable systems.) |
I've rebased PR #2346 on top of all the changes I merged yesterday, mentioned above. |
In PR #2368 I add a test that you should ensure passes (except on ancient CPUs) in your patched versions of ring. |
OK, friends, I've just released 0.17.9; It's live at https://crates.io/crates/ring/0.17.9. Commit ecbcdb3. To update your patches, delete everything you did for 0.17.8. Then remove these two lines:
(Note that there are other similar assertions that are specific to x86_64; you can leave those alone.) Please report back if that isn't sufficient for your needs. I hope, in a future release, to support the no-SSE2 configuration out of the box, but I didn't have time for that in the 0.17.9 release. (BTW, when I was at Mozilla, around 2012 or so, I think we measured the percentage of SSE2-capable 32-bit x86 systems (that were running Firefox and providing telemetry) around 99%. According to https://issues.chromium.org/issues/40354305, in 2014, 99.66% of Chrome users on Windows had SSE2 support.) |
Thanks, i'll check out the new version soon. It's very possible that for Debian this issue becomes moot in the not too distant future. There seems to be general support in the project for increasing the baseline, the main thing that seems to be holding things up is it's unclear who should make the descision. |
Release notes: https://github.com/sqlpage/SQLPage/releases/tag/v0.33.0 Migrate i386 patch per suggestion from upstreams author: briansmith/ring#1999 (comment)
Hi!
I get this error when building an app using ring-0.17.8
I tried to find info using the three issue links in the code, but I don't have enough experience with rust, to be honest, I'm just packaging an application. It seems to me that the problem is with the assert call itself, so perhaps this is actually a bug?
Removing the check will make the code build.
Do you need more information, just specify what is needed. Build log attached.
sqlpage-0.20.0.log
The text was updated successfully, but these errors were encountered: