Skip to content
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

Build fails for Windows ARM64 #1514

Closed
mdecimus opened this issue Sep 11, 2022 · 12 comments
Closed

Build fails for Windows ARM64 #1514

mdecimus opened this issue Sep 11, 2022 · 12 comments

Comments

@mdecimus
Copy link

mdecimus commented Sep 11, 2022

Hi,

I am unable to compile ring using a windows-2019 or windows-2022 Github runner image. The CI workflow I used is the same one used in this repository, however the build fails with the following error:

error: failed to run custom build command for `ring v0.16.20`

Caused by:
  process didn't exit successfully: `D:\a\ci-test\ci-test\target\release\build\ring-d8c08109d61404ae\build-script-build` (exit code: 101)
  --- stdout
  OPT_LEVEL = Some("3")
  TARGET = Some("aarch64-pc-windows-msvc")
  HOST = Some("x86_64-pc-windows-msvc")
  CC_aarch64-pc-windows-msvc = None
  CC_aarch64_pc_windows_msvc = None
  TARGET_CC = None
  CC = None
  CFLAGS_aarch64-pc-windows-msvc = None
  CFLAGS_aarch64_pc_windows_msvc = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("crt-static,neon,pmuv3")
  DEBUG = Some("false")
  aes_nohw.c
  OPT_LEVEL = Some("3")
  TARGET = Some("aarch64-pc-windows-msvc")
  HOST = Some("x86_64-pc-windows-msvc")
  CC_aarch64-pc-windows-msvc = None
  CC_aarch64_pc_windows_msvc = None
  TARGET_CC = None
  CC = None
  CFLAGS_aarch64-pc-windows-msvc = None
  CFLAGS_aarch64_pc_windows_msvc = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("crt-static,neon,pmuv3")
  DEBUG = Some("false")
  montgomery.c
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): error C2065: 'BN_ULLONG': undeclared identifier
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): error C2146: syntax error: missing ';' before identifier 'result'
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): warning C4555: result of expression not used
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): error C2065: 'result': undeclared identifier
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): error C2146: syntax error: missing ';' before identifier 'a'
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): warning C4552: '*': result of expression not used
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(192): error C2065: 'result': undeclared identifier
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(193): error C2065: 'result': undeclared identifier
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(193): warning C4293: '>>': shift count negative or too big, undefined behavior
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(38): warning C4163: '_addcarry_u64': not available as an intrinsic function
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(38): warning C4163: '_subborrow_u64': not available as an intrinsic function
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(62): warning C4013: '_addcarry_u64' undefined; assuming extern returning int
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(62): warning C4242: '=': conversion from 'int' to 'Carry', possible loss of data
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(76): warning C4242: '=': conversion from 'int' to 'Carry', possible loss of data
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(92): warning C4013: '_subborrow_u64' undefined; assuming extern returning int
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(92): warning C4242: '=': conversion from 'int' to 'Carry', possible loss of data
  C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(106): warning C4242: '=': conversion from 'int' to 'Carry', possible loss of data

  --- stderr
  running "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\arm64\\cl.exe" "-nologo" "-MT" "-O2" "-Brepro" "-I" "include" "-W4" "/GS" "/Gy" "/EHsc" "/GR-" "/Zc:wchar_t" "/Zc:forScope" "/Zc:inline" "/Zc:rvalueCast" "/sdl" "/Wall" "/wd4127" "/wd4464" "/wd4514" "/wd4710" "/wd4711" "/wd4820" "/wd5045" "/Ox" "-DNDEBUG" "-c" "/FoD:\\a\\ci-test\\ci-test\\target\\aarch64-pc-windows-msvc\\release\\build\\ring-c2920ccb72a52194\\out\\aes_nohw.obj" "crypto/fipsmodule/aes/aes_nohw.c"
  running "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\arm64\\cl.exe" "-nologo" "-MT" "-O2" "-Brepro" "-I" "include" "-W4" "/GS" "/Gy" "/EHsc" "/GR-" "/Zc:wchar_t" "/Zc:forScope" "/Zc:inline" "/Zc:rvalueCast" "/sdl" "/Wall" "/wd4127" "/wd4464" "/wd4514" "/wd4710" "/wd4711" "/wd4820" "/wd5045" "/Ox" "-DNDEBUG" "-c" "/FoD:\\a\\ci-test\\ci-test\\target\\aarch64-pc-windows-msvc\\release\\build\\ring-c2920ccb72a52194\\out\\montgomery.obj" "crypto/fipsmodule/bn/montgomery.c"
  thread 'main' panicked at 'execution failed', C:\Users\runneradmin\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\ring-0.16.20\build.rs:656:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.

To reproduce the error you can run the ci workflow in this repository.

Thank you.

@msuiche
Copy link

msuiche commented Sep 16, 2022

Same here. :(

@msuiche
Copy link

msuiche commented Sep 16, 2022

#1167 (comment) related

@sj6219
Copy link

sj6219 commented Sep 22, 2022

refer to
https://github.com/briansmith/ring/blob/main/BUILDING.md

Try the following in cargo.toml.
ring = { git = "https://github.com/sj6219/ring", branch = "0.16.20_alpha" }

Install visual studio 2022 and add the following components.

  • MSVC v143 - VS 2022 c++ ARM64 build tools(Latest)

Install LLVM and Strawberry Perl and add them to the environment variable path.

@mdecimus
Copy link
Author

Thanks @sj6219 . Unfortunately I won't be able to do that as I am using ring via the rustls crate. I'll have to wait until the fix is applied on ring directly.

@awakecoding
Copy link
Contributor

@sj6219 thanks for your branch, I have modified it on my side to make it look like the 0.16.20 release, and managed to inject it correctly in all of my dependencies this way. This should work for @mdecimus as well. You can find my branch here: https://github.com/awakecoding/ring/tree/0.16.20_alpha

You need to use the following in your Cargo.toml to force-replace the official 0.16.20 release from crates.io with the branch:

[patch.crates-io]
ring = { git = "https://github.com/awakecoding/ring", branch = "0.16.20_alpha" }

You can run "cargo update" and then check that it does get correctly picked up like this:

cargo tree -p ring
ring v0.16.20 (https://github.com/awakecoding/ring?branch=0.16.20_alpha#ec78aff5)

If you see other ring dependencies listed that don't point to the branch, it'll keep trying to build unpatched versions. The branch requires having clang.exe in the PATH to work properly, but it's preinstalled in most CI environments now. I conditionally patched my cargo.toml file for Windows ARM64 only because the branch doesn't work well for other targets. To test if compilation works, make sure to build executables or shared libraries, otherwise it won't get to throw linker errors.

Here's my modified step in GitHub Actions to fix my own build:

      - name: Fix ring dependency for Windows ARM64
        if: runner.os == 'Windows' && matrix.arch == 'arm64'
        shell: pwsh
        run: |
          @('', '[patch.crates-io]',
          'ring = { git = "https://github.com/awakecoding/ring", branch = "0.16.20_alpha" }') | % {
            Add-Content -Path "Cargo.toml" -Value $_
          }
          $VSINSTALLDIR = $(vswhere.exe -latest -requires Microsoft.VisualStudio.Component.VC.Llvm.Clang -property installationPath)
          $VCINSTALLDIR = Join-Path $VSINSTALLDIR "VC"
          $LLVM_ROOT = Join-Path $VCINSTALLDIR "Tools\Llvm\x64"
          echo "PATH=$Env:PATH;${LLVM_ROOT}\bin" >> $Env:GITHUB_ENV

You can find the full workflow file for my project here as reference: https://github.com/Devolutions/sspi-rs/blob/master/.github/workflows/nuget.yml

@sj6219
Copy link

sj6219 commented Sep 27, 2022

@awakecoding
It's more convenient to use [patch.crates-io]
I learned something good this time. Thank you.

@mdecimus
Copy link
Author

Thanks @awakecoding !

@sj6219
Copy link

sj6219 commented Sep 30, 2022

@awakecoding
The pregenerated files for the 0.16.20 version has been regenerated.
You can update my branch.
https://github.com/sj6219/ring/tree/0.16.20_alpha

You will no longer need a github action.

@awakecoding
Copy link
Contributor

@awakecoding The pregenerated files for the 0.16.20 version has been regenerated. You can update my branch. https://github.com/sj6219/ring/tree/0.16.20_alpha

You will no longer need a github action.

do you mean the branch should build cleanly for all platforms, not just Windows ARM64?

@sj6219
Copy link

sj6219 commented Oct 1, 2022

It seems buildable on all platforms. @briansmith knows exactly, but when I tested it on Android, macos, and windows, there was no problem.

@briansmith
Copy link
Owner

Hi. Thanks for all the interest in this. I think people are mostly interested here in trying to get Rustls working? If so, seems like Rustls people are willing to upgrade to 0.17 when it is released, so I think releasing 0.17 is the most efficient way of moving this forward. Accordingly I'm closing this as a dupe of #1167.

@AArnott
Copy link

AArnott commented Aug 19, 2023

@awakecoding thanks for #1514 (comment). It seems to work in the simple case. But in a case where ring is used more (I guess) I get a bunch of unresolved external symbol errors.

Any suggestions?

AArnott added a commit to nerdcash/zingolib that referenced this issue Aug 21, 2023
The `ring` crate doesn't natively support win-arm64 yet. But a fork adds that support [as described here][workaround].

[workaround]: briansmith/ring#1514 (comment)
AArnott added a commit to nerdcash/zingolib that referenced this issue Sep 3, 2023
The `ring` crate doesn't natively support win-arm64 yet. But a fork adds that support [as described here][workaround].

[workaround]: briansmith/ring#1514 (comment)
AArnott added a commit to nerdcash/zingolib that referenced this issue Sep 8, 2023
The `ring` crate doesn't natively support win-arm64 yet. But a fork adds that support [as described here][workaround].

[workaround]: briansmith/ring#1514 (comment)
AArnott added a commit to nerdcash/zingolib that referenced this issue Oct 4, 2023
The `ring` crate doesn't natively support win-arm64 yet. But a fork adds that support [as described here][workaround].

[workaround]: briansmith/ring#1514 (comment)
wjones127 pushed a commit to lancedb/lance that referenced this issue Jun 25, 2024
Upgrades `aws-config` because `aws-config@0.56` has a dependency on
`ring@0.16` [^1] which does not support `aarch64-pc-windows` [^2].

> error: failed to run custom build command for `ring v0.16.20`.

Support for `aarch64-pc-windows` was added in `ring@0.17` [^3] which
`aws-config@0.57` uses [^4].

Unfortunately, there's a hideous amount of changes between these two
version, although no breaking changes are mentioned in the changelog
[^5]. Does a maintainer here have a suggestion of what kind of testing
we might need to do?

[^1]:
https://github.com/awslabs/aws-sdk-rust/blob/d212f8dd428e140b8ff414261f6921b2901a7dbc/sdk/aws-config/Cargo.toml#L98-L100
[^2]: briansmith/ring#1514
[^3]:
briansmith/ring#1167 (comment)
[^4]:
https://github.com/awslabs/aws-sdk-rust/blob/511abe92a476c27d1e49758fe54eac0886ecf731/sdk/aws-config/Cargo.toml#L98-L100
[^5]: https://github.com/awslabs/aws-sdk-rust/compare/d212f8d..511abe9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants