Closed pixlwave closed 6 months ago
Is there a convenient way to run the test suite on these targets?
Global suggestions:
1: Let's do 1 PR per new target, since each target is going to have its own issues to address, it seems.
test
matrix with --no-run
. Basically copy-paste what was done for aarch64-apple-ios in .github/workflows/ci.yml
. This way, I can see directly what the build output is, in the CI jobs' logs.cargo test
on the actual hardware for iOS, at least. Do you have any pointers regarding this for these targets? Otherwise I think we have to presume that none of the assembly language code works for these targets, to be cautious. But, that seems pessimistic to the point of probably being unrealistic.armv7k-apple-watchos builds although there are 4 warnings about .o files with no symbols which I'm not sure if that is to be expected or not?
You didn't include the build output for those warnings.
Compiling ring v0.17.7 (/Users/runner/Fork/ring) warning: field 0
is never read --> src/arithmetic/n0.rs:19:1519 pub struct N0([Limb; 2]); -- ^^^^^^^^^ field in this struct
This warning is caused by a bug in rustc Nightly; it is a false positive that we are tracking in https://github.com/briansmith/ring/issues/1917.
ring git:(watchos) β― cargo +nightly build -Zbuild-std --target "arm64_32-apple-watchos" Compiling ring v0.17.7 (/Users/runner/Fork/ring) The following warnings were emitted during compilation: warning: ring@0.17.7: In file included from crypto/fipsmodule/ec/gfp_p384.c:246: warning: ring@0.17.7: crypto/fipsmodule/ec/ecp_nistz384.inl:167:35: error: implicit conversion loses integer precision: 'crypto_word_t' (aka 'unsigned long long') to 'size_t' (aka 'unsigned long') [-Werror,-Wshorten-64-to-32] warning: ring@0.17.7: p384_point_select_w5(&h, table, recoded);
In your fork, did you also patch target.h? Is target.h choosing
OPENSSL_64BIT
orOPENSSL_32BIT
? It seems like we want it to selectOPENSSL_64BIT
for the purposes of definingcrypto_word_t
, as crypto_word_t is always supposed to be the native word size. However, up to this point we've never hadcrypto_word_t
a different size thansize_t
, so we'd need to carefully. In this case, it seems like we need to do this kind of change:
static void p384_point_select_w5(P384_POINT *out,
- const P384_POINT table[16], size_t index) {
+ const P384_POINT table[16], crypto_word_t index) {
cargo:warning=clang: error: overriding '-mwatchsimulator-version-min=2.0' option with '--target=arm64-apple-watchos5.0-simulator' [-Werror,-Woverriding-t-option]
This seems like a cc-rs bug. Is this warning a false positive, or is it indicating a real problem? If it is a false positive I would accept a change to build.rs to work around it for this target.
PR #1918 added some build-time checks to identify potential ABI issues, which I also intend to act as documentation for what changes need to be made to support all these targets.
- Let's do 1 PR per new target, since each target is going to have its own issues to address, it seems.
That sounds like a sane approach to me π. This effort is something I'm doing in my spare time, so might be slow, but will split this all up with the rest of the suggestions etc.
- Let's add these to the
test
matrix with--no-run
. Basically copy-paste what was done for aarch64-apple-ios in.github/workflows/ci.yml
. This way, I can see directly what the build output is, in the CI jobs' logs.- I am not familiar with the details of watchos ABIs and how they differ from the other Apple ABIs for the same target. So, it would be useful to indicate what's the same and what's different more explicitly.
π
- I am aware that there are some projects that attempt to make it easy (easier) to run (the equivalent of)
cargo test
on the actual hardware for iOS, at least. Do you have any pointers regarding this for these targets? Otherwise I think we have to presume that none of the assembly language code works for these targets, to be cautious. But, that seems pessimistic to the point of probably being unrealistic.
Honestly I've not dealt with conditionally compiled code to this extent before in Rust but I agree it would be good to do this. Have been reading about cargo-dinghy which just so happens to have a recent PR for adding watchOS (and tvOS) support so seems like that would be an interesting place to start.
armv7k-apple-watchos builds although there are 4 warnings about .o files with no symbols which I'm not sure if that is to be expected or not?
You didn't include the build output for those warnings.
Its the first 4 lines that are really long:
warning: ring@0.17.7: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /Users/runner/Fork/ring/target/armv7k-apple-watchos/debug/build/ring-e19af6c0555b724d/out/libring_core_0_17_7_.a(x25519-asm-arm.o) has no symbols
warning: ring@0.17.7: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /Users/runner/Fork/ring/target/armv7k-apple-watchos/debug/build/ring-e19af6c0555b724d/out/libring_core_0_17_7_.a(poly1305_arm_asm.o) has no symbols
warning: ring@0.17.7: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /Users/runner/Fork/ring/target/armv7k-apple-watchos/debug/build/ring-e19af6c0555b724d/out/libring_core_0_17_7_.a(x25519-asm-arm.o) has no symbols
warning: ring@0.17.7: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /Users/runner/Fork/ring/target/armv7k-apple-watchos/debug/build/ring-e19af6c0555b724d/out/libring_core_0_17_7_.a(poly1305_arm_asm.o) has no symbols
In your fork, did you also patch target.h?
No I didn't, and given that its the hardest target, let's take arm64_32 last and come back to this then.
This seems like a cc-rs bug. Is this warning a false positive, or is it indicating a real problem? If it is a false positive I would accept a change to build.rs to work around it for this target.
Honestly I'm not sure, I'll have to look this one up and find out whats going on with the warning.
Hi, sorry. Just realised I left this open. Unfortunately I discovered a misconfiguration in the project I was trying to compile for watchOS where one of the dependencies was using rustls instead of native-tls so my personal need for this has gone down. I would love to follow this up some day (especially to learn about some of the ideas discussed), but it's unlikely I will get the time so I'm going to close this PR and if I do, I can do it target by target.
Please see #2112 and #2113. I would appreciate testing of them and feedback, especially related to performance and code size.
Hoping to make a follow-up PR to #1689 to add watchOS support, although in the current state this doesn't yet work for all of the targets:
aarch64-apple-watchos
is the only target to compile happily, although I don't believe there's any hardware actually using this yet πarmv7k-apple-watchos
builds although there are 4 warnings about .o files with no symbols which I'm not sure if that is to be expected or not?arm64_32-apple-watchos
fails to build, due to a couple ofimplicit conversion loses integer precision
errors. I think this makes sense as arm64_32 is considered to be aarch64 by Rust, even if the pointer size is 32-bit but I have no idea where to fix this.aarch64-apple-watchos-sim
andx86_64-apple-watchos-sim
both fail to build due to conflicting clang arguments-mwatchsimulator-version-min=2.0
and--target={aarch64|x86_64}-apple-watchos5.0-simulator
, although again, I'm failing to see where these 2 parameters come from π€Any pointers towards potential answers would be greatly appreciated π
Build output
aarch64-apple-watchos β
armv7k-apple-watchos β
arm64_32-apple-watchos β
aarch64-apple-watchos-sim β
x86_64-apple-watchos-sim β
ring git:(watchos) β― cargo +nightly build -Zbuild-std --target "x86_64-apple-watchos-sim" Compiling ring v0.17.7 (/Users/runner/Fork/ring) The following warnings were emitted during compilation: warning: ring@0.17.7: clang: error: overriding '-mwatchsimulator-version-min=2.0' option with '--target=x86_64-apple-watchos5.0-simulator' [-Werror,-Woverriding-t-option] error: failed to run custom build command for `ring v0.17.7 (/Users/runner/Fork/ring)` Caused by: process didn't exit successfully: `/Users/runner/Fork/ring/target/debug/build/ring-46c716d55784f0d8/build-script-build` (exit status: 1) --- stdout cargo:rerun-if-env-changed=RING_PREGENERATE_ASM cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_7_ cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE cargo:rerun-if-env-changed=PERL_EXECUTABLE OPT_LEVEL = Some("0") TARGET = Some("x86_64-apple-watchos-sim") HOST = Some("x86_64-apple-darwin") cargo:rerun-if-env-changed=CC_x86_64-apple-watchos-sim CC_x86_64-apple-watchos-sim = None cargo:rerun-if-env-changed=CC_x86_64_apple_watchos_sim CC_x86_64_apple_watchos_sim = None cargo:rerun-if-env-changed=TARGET_CC TARGET_CC = None cargo:rerun-if-env-changed=CC CC = None cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = None DEBUG = Some("true") Detecting WatchOS SDK path for watchsimulator running: "xcrun" "--show-sdk-path" "--sdk" "watchsimulator" exit status: 0 cargo:rerun-if-env-changed=CFLAGS_x86_64-apple-watchos-sim CFLAGS_x86_64-apple-watchos-sim = None cargo:rerun-if-env-changed=CFLAGS_x86_64_apple_watchos_sim CFLAGS_x86_64_apple_watchos_sim = None cargo:rerun-if-env-changed=TARGET_CFLAGS TARGET_CFLAGS = None cargo:rerun-if-env-changed=CFLAGS CFLAGS = None running: "clang" "-O0" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=x86_64-apple-watchos5.0-simulator" "-m64" "-mwatchsimulator-version-min=2.0" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator10.2.sdk" "-fembed-bitcode" "-I" "include" "-I" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-Werror" "-o" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c" cargo:warning=clang: error: overriding '-mwatchsimulator-version-min=2.0' option with '--target=x86_64-apple-watchos5.0-simulator' [-Werror,-Woverriding-t-option] exit status: 1 --- stderr running "perl" "crypto/chacha/asm/chacha-x86_64.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/chacha-x86_64-macosx.S" running "perl" "crypto/fipsmodule/aes/asm/aesni-x86_64.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/aesni-x86_64-macosx.S" running "perl" "crypto/fipsmodule/aes/asm/vpaes-x86_64.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/vpaes-x86_64-macosx.S" running "perl" "crypto/fipsmodule/bn/asm/x86_64-mont.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/x86_64-mont-macosx.S" running "perl" "crypto/fipsmodule/bn/asm/x86_64-mont5.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/x86_64-mont5-macosx.S" running "perl" "crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/p256-x86_64-asm-macosx.S" running "perl" "crypto/fipsmodule/modes/asm/aesni-gcm-x86_64.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/aesni-gcm-x86_64-macosx.S" running "perl" "crypto/fipsmodule/modes/asm/ghash-x86_64.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/ghash-x86_64-macosx.S" running "perl" "crypto/fipsmodule/sha/asm/sha512-x86_64.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/sha512-x86_64-macosx.S" running "perl" "crypto/cipher_extra/asm/chacha20_poly1305_x86_64.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/chacha20_poly1305_x86_64-macosx.S" running "perl" "crypto/fipsmodule/sha/asm/sha512-x86_64.pl" "macosx" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/sha256-x86_64-macosx.S" error occurred: Command "clang" "-O0" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=x86_64-apple-watchos5.0-simulator" "-m64" "-mwatchsimulator-version-min=2.0" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator10.2.sdk" "-fembed-bitcode" "-I" "include" "-I" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-Werror" "-o" "/Users/runner/Fork/ring/target/x86_64-apple-watchos-sim/debug/build/ring-5e8917d212bd1162/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args "clang" did not execute successfully (status code exit status: 1).