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

cmake: disable ASM for Windows ARM64 #989

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

vszakats
Copy link
Contributor

@vszakats vszakats commented Jan 2, 2024

With ASM support the builds either exit with an assert or hang (with asserts disabled).

autotools doesn't enable ASM for Windows ARM64, so it's not affected.

Fixes #987

With ASM support the builds either exit with an assert or hang
(with asserts disabled).
vszakats added a commit to curl/curl-for-win that referenced this pull request Jan 2, 2024
Turns out that the official Windows ARM64 curl.exe exited with an
assert when run with a simple command like: `curl https://example.org`.
```
Assertion failed: (i == BN_BITS2) || (h <= (BN_ULONG)1 << i), file \crypto\bn\bn_div.c, line 96
```
With asserts disabled the same command hung.

These warnings hinted to the problem:
```
In file included from libressl/crypto/bn/bn_add.c:65:
libressl/crypto/bn/arch/aarch64/bn_arch.h:35:16: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
   35 |             : [n]"=r"(n)
      |                       ^
libressl/crypto/bn/arch/aarch64/bn_arch.h:34:18: note: use constraint modifier "w"
   34 |         __asm__ ("clz   %[n], %[w]"
      |                         ^~~~
      |                         %w[n]
libressl/crypto/bn/arch/aarch64/bn_arch.h:36:15: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
   36 |             : [w]"r"(w));
      |                      ^
libressl/crypto/bn/arch/aarch64/bn_arch.h:34:24: note: use constraint modifier "w"
   34 |         __asm__ ("clz   %[n], %[w]"
      |                               ^~~~
      |                               %w[w]
libressl/crypto/bn/arch/aarch64/bn_arch.h:51:37: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
   51 |             : [carry]"=r"(carry), [r0]"=r"(r0)
      |                                            ^
[...]
```

autotools builds have ASM disabled by default for this build case.

Ref upstream PR disabling ASM for Windows ARM64 with CMake:
libressl/portable#989
@botovq
Copy link
Contributor

botovq commented Jan 2, 2024 via email

@vszakats
Copy link
Contributor Author

vszakats commented Jan 2, 2024

There is a long list of -Wasm-operand-widths compiler warnings (which I did miss throughout all the testing!)
and they do look like coming from inline ASM code in crypto/bn/arch/aarch64/bn_arch.h:
https://github.com/curl/curl-for-win/actions/runs/7224401784/job/19685602186#step:3:9017

Wrongly detected integer sizes in openssl/bn.h might be a reason.

@vszakats
Copy link
Contributor Author

vszakats commented Jan 2, 2024

FWIW, before:
https://curl.se/windows/dl-8.5.0_3/curl-8.5.0_3-win64a-mingw.zip (failing with assert)
and after binaries:
https://curl.se/windows/dl-8.5.0_4/curl-8.5.0_4-win64a-mingw.zip (working)

(though this disables ASM differently; without patching LibreSSL.)

@busterb
Copy link
Contributor

busterb commented Feb 12, 2024

Hey folks, you're right about the LLP64 nature of Windows 64-bit being the core issue here. I remember it being difficult to untangle last time I looked, but this seems like a reasonable workaround until it can be addressed more generally.

@busterb busterb self-assigned this Feb 12, 2024
@busterb busterb merged commit 4e25dc4 into libressl:master Feb 12, 2024
35 checks passed
@vszakats vszakats deleted the noasm-winarm64 branch February 12, 2024 10:55
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

Successfully merging this pull request may close these issues.

Windows ARM64 assert in bn_div.c
4 participants