-
Notifications
You must be signed in to change notification settings - Fork 708
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
"attempt to use an ARM instruction on a Thumb-only processor" building for thumbv7em-none-eabi #813
Comments
What if you use If you can't use cross then please share a script that installs all the necessary dependencies on Ubuntu. |
|
But, did you see if it works when |
|
I've been attempting to work through this (for the target
|
There are also issues where In any case it seems like support for bare-metal thumb targets might be trickier than just fixing the assembly issue... |
More generally, the crate won't build as |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I am doing some work to make ring with for wasm32-unknown-unknown and part of that was to make ring be Removing the use of libc for such targets is the subject of issue #39. It looks to be very solvable for these Cortex-M CPUs without any third-party dependencies. The trickier sticking point is how to know generate random bytes for these targets; that should be its own issue. Regarding the actual subject of this issue (as judged by the summary of the issue), the attempt to compile ARM instructions on thumb-only targets, I suggest we change build.rs or some other part of the build system to skip the problematic assembly files for thumb-only targets. But, how can we identify whether a target is thumb-only? On top of that, I imagine for cortex-M we want to use static feature detection instead of runtime feature detection in cpu.rs. It seems doable. It would be nice if we didn't have to do it by enumerating every single thumb-only target_arch though. |
It looks like the environment variable CARGO_CFG_TARGET_FEATURE will contain mclass in a comma separated list if it's a thumb-only target, but it actually seems like the problem is the inverse: we're compiling files that require ARMv8 (aesv8-armx.pl, ghashv8-armx.pl) or ARMv7+NEON (x25519-asm-arm.S) on all ARM platforms. There are some improvements that can be made in the assembly files as well: they're not guarding their NEON implementations with I'll try to carve out some time tonight or tomorrow to upload a patch here to improve build.rs's target detection and one to upstream BoringSSL to sprinkle |
Consider somebody who wants to build an executable that runs on any ARMv6 system or later, and optionally use NEON if the CPU supports NEON, and optionally use AAarch32 instructions if the CPU supports AAarch32 instructions, using runtime feature detection. This is what ring allows today with the current scheme. |
Ah, right. Perhaps |
I think we should add a feature "static-feature-detection-only" that switches cpu.rs from using dynamic feature detection to static feature detection based on |
So I've fallen across this issue attempting to compile https://github.com/cloudflare/quiche for
I'm guessing the first change I listed above ( |
IDK what the status of the Thumb support is for ring's assembly. I do think that at least some, maybe most, of the assembly is thumb compatible. Maybe some could be tweaked to become Thumb-compatbile. There might be some assembly we need to exclude on a case-by-case basis from Thumb builds,
These warnings won't be considered errors if building from a packaged version of ring (from crates.io, or vendored from crates.io)
IDK what cmake-rs has to do with it. But, it is probably the case that ring's build.rs needs to be changed w.r.t. PIC stuff. Should we just assume that cc-rs automatically does the right thing? If so, it would be great to have a citation to support that. Then we can remove any/all PIC-related stuff in build.rs.
It does now, and has for a few months. |
Cargo now sets In PR #1100 [edit: not 1101], I hard-coded the CPU feature set for ARM apple devices because at the time In addition, I'm happy to move more dynamic CPU feature detection out of the assembly language and into the Rust code so that more static feature detection can be used. But, also, recent ARM-targeting compilers do set various macros when a CPU feature is guaranteed to be provided. Look at how BoringSSL's |
@briansmith I'm ignorant to much of Ring, but are you saying there are equivalent .c or .rs implementations for everything that is implemented in .S ? (I told you I'm ignorant to much of Ring :) So, the right approach is to select a .c or .rs implementation for the thumb targets? |
@briansmith
With those changes, Ring compiles for my thumb target. So the next two things will be:
I'm open to suggestions on how to do either or both. Here is how I'm building: |
The RP2040 has a random bit generator that is not recommend for cryptography applications:
https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf https://docs.rs/rp2040-hal/latest/rp2040_hal/rosc/struct.RingOscillator.html#method.get_random_bit |
There are C/Rust implementations of almost everything, but not absolutely everything.
I doubt that's the best approach. I believe upstream OpenSSL and probably BoringSSL have full support for Thumb targets in the assembly. It is hard to read the assembly code because it uses Perl (!) as a macro language, so all the assembly is embedded within Perl. I suggest we start by stating the exact steps to reproduce, making no assumptions about any compilers being installed on the build machine or any environment variables being set. In particular, in order to cross-compile ring, you need a C compiler that can cross-compile for the target. So, let's see the steps to reproduce that involve installing, in some way, that cross-compiler, or using environment variables to override the compiler to use clang instead. Then let's see what errors we encounter when there is a working target C compiler/assembler. |
If you haven't seen it, Bunnie has a pure-Rust version of ring (over in their Xous fork), allowing it to compile for RISC-V. |
I've been trying to get ring working on thumb targets, and hit this error when running
cargo build --target thumbv7em-none-eabi
:This could be due to the build script not detecting the architecture correctly, because as far as I can tell BoringSSL should work on thumb targets.
The text was updated successfully, but these errors were encountered: