-
Notifications
You must be signed in to change notification settings - Fork 737
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
*ring* fails to build for target_os = "none"
targets
#1793
Comments
the built-in rustc targets `{x86,x86_64,arm,aarch64}-none` all use the ELF format fixes briansmith#1793
the built-in rustc targets `{x86,x86_64,arm,aarch64}-none` all use the ELF format fixes briansmith#1793
This is intentional. See https://doc.rust-lang.org/rustc/platform-support/x86_64-unknown-none.html#requirements. We cannot use vector or floating point registers for this target without additional target features being enabled, but much of our x86-64 assembly code generally assumes at least SSE2 can be used without checking CPUID or target features. Further, it assumes AVX and other things can be used if CPUID reports they are available. Are we even allowed to execute CPUID on all these targets? I do not know in all of the assembly code is free of use of the red zone. So, as a start, at a minimum, every time we have Also, every assembly function's Rust declaration would need to be declared For AAarch64, I guess it would be similar. |
The "perlasm_format" stuff in build.rs already handles this specific part. "linux64" as the PerlAsm format means "sysv64", basically. |
Thanks for the pointers. I think that sounds reasonable. I'll have a closer look next week-ish. |
Thanks. I recommend commenting here with a proposed solution before writing a PR. For aarch64 and ARM we make use of static target feature detection. We combine the features detected statically with any dynamic target feature detection that we do. In order to properly support this target, I think that we need to do the analogous thing for x86/x86-64 features. Notably, it seems like we should have an OS allowlist for the dynamic CPU feature detection for x86-64/x86 like we do for AArch64 as it apparently is not safe on such targets to depend on what CPUID says when deciding which CPU features to use. As a side effect, we would then also be able to support i586 targets since we'd drop our implicit SSE2 dependency. Then the However, that would leave these targets with, by default, the slowest/worst implementations of all algorithms. I wonder if there are better targets where you can demonstrate your no_std support in a way where we'd be free to keep doing our dynamic detection and make use of SSE2 by default as we currently are? |
So, I think phase 1 is just to implement static feature detection for x86_64 like we do for aarch64. The combination of static and dynamic feature detection in Aarch64 serves as a model. See Line 156 in 445de2f
Dynamic feature detection has a lot more complexity. Let's take x86_64-unknown-none as an example. This is the target that is being used for Linux kernel code. In order to safely use vector registers for this target when running within the Linux kernel, we need to wrap all SSE usage in Now, let's say the target is x86_64-unknown-none and the target isn't the Linux kernel, but rather some other environment. How are we supposed to determine if the environment requires us to call functions analogous to Similar questions for the other target architectures (aarch64-, etc.). |
target_os = "none"
targetstarget_os = "none"
targets
#1937 would resolve the immediate issue of the build failures by fixing a bug that was preventing such targets from using the fallbacks, but does not address the availability of PerlAsm implementations. |
I'm tried compiling a no-std executable that depends on ring to the
x86_64-unknown-none
target and got a linker error listing several "undefined references" likering_core_0_17_5_ChaCha20_ctr32
andring_core_0_17_5_bn_mul_mont
.I have tracked down the problem to these being symbols in the (pregenerated?) asm group. The build script does not produce the assembly files because
none
is not in theLINUX_ABI
list. Adding"none"
to this list fixes the linker error and produces a working binary. I have also tested that my program works (+) with theaarch64-unknown-none
target. I'll submit a PR with that change.(+) I'll eventually push the source code of my program to this draft rustls PR
The text was updated successfully, but these errors were encountered: