Skip to content

Conversation

ognevny
Copy link
Contributor

@ognevny ognevny commented Apr 30, 2025

Issues:

Resolves #2362

Description of changes:

when compiling aws-lc with clang pthreads are currently used. it's common to build Clang itself with Win32 thread model so usually -lpthread option is not passed for *-pc-windows-gnullvm targets, for example. this PR fixes the issue when aws-lc-rs fails to build on such targets because required pthread symbols are not being linked in resulting binary

Call-outs:

-

Testing:

for now some Rust dependent software in MSYS2 is being built with this patch and there wasn't any runtime issue yet

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@ognevny ognevny requested a review from a team as a code owner April 30, 2025 16:41
@codecov-commenter
Copy link

codecov-commenter commented Apr 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.77%. Comparing base (b0e8fbc) to head (fa43336).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2381      +/-   ##
==========================================
- Coverage   78.78%   78.77%   -0.02%     
==========================================
  Files         620      620              
  Lines      108077   108077              
  Branches    15349    15348       -1     
==========================================
- Hits        85153    85140      -13     
- Misses      22266    22280      +14     
+ Partials      658      657       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ognevny
Copy link
Contributor Author

ognevny commented May 1, 2025

CI failure seems unrelated

edit: oops, it should be MinGW specific

@ognevny ognevny force-pushed the fix-windows-clang branch from bee4e8e to 17dc891 Compare May 1, 2025 02:38
Copy link
Contributor

@justsmth justsmth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! ❤️ I'll try to get a CI job setup to test this.

@ognevny ognevny force-pushed the fix-windows-clang branch from 17dc891 to 577ff2a Compare May 1, 2025 11:39
@ognevny
Copy link
Contributor Author

ognevny commented May 1, 2025

I'll try to get a CI job setup to test this.

you can try to setup llvm-mingw to get a minimal clang+mingw toolchain. a good example on downloading and using such toolchain is available in mingw-w64 mirror

@justsmth
Copy link
Contributor

justsmth commented May 1, 2025

@ognevny -- I think I've almost got it all together... and it only took me a few dozen iterations. 🤣

The tests are failing and it's not clear why. (?) I plan to cherry-pick this commit onto your PR branch for testing.

@ognevny
Copy link
Contributor Author

ognevny commented May 1, 2025

The tests are failing and it's not clear why. (?) I plan to cherry-pick this commit onto your PR branch for testing.

just my guess, but go toolchains are mixed. try to set GOROOT environment before CMake invocation. also you can use a perl from MSYS environment, it's located under /usr instead of /clang64. it's usually installed along with other packages, but to ensure it you can add perl: (colon is important!) in pacboy field

@ognevny
Copy link
Contributor Author

ognevny commented May 1, 2025

locally ran tests and it also failed for me, but with an another error

[0/2] C:\WINDOWS\system32\cmd.exe /C "cd /D C:\msys64\home\maksa\forks\aws-l...m -shim-path C:/msys64/home/maksa/forks/aws-lc/build/ssl/test/bssl_shim.exe"Running SSL tests
go: downloading golang.org/x/crypto v0.10.0
go: downloading golang.org/x/sys v0.9.0
0/0/988/1000/5078
0/0/988/1000/5078
0/0/988/1000/5078
0/0/988/1000/5078
0/0/989/1000/5078
0/0/1988/2000/5078
0/0/1988/2000/5078
0/0/1989/2000/5078
0/0/2988/3000/5078
0/0/2988/3000/5078
0/0/2988/3000/5078
0/0/2988/3000/5078
0/0/2988/3000/5078
0/0/2989/3000/5078
0/0/3988/4000/5078
0/0/3989/4000/5078
0/0/4988/5000/5078
0/0/4989/5000/5078
FAILED (Peek-Basic-Server)
unexpected failure: local error 'read tcp [::1]:60434->[::1]:50601: i/o timeout', child error 'none', stdout:

stderr:


FAILED (Peek-ImplicitHandshake-Server)
unexpected failure: local error 'read tcp [::1]:60434->[::1]:50605: i/o timeout', child error 'none', stdout:

stderr:


FAILED (Peek-Shutdown-Server)
unexpected failure: local error 'read tcp [::1]:60434->[::1]:50609: i/o timeout', child error 'none', stdout:

stderr:


3/0/5078/5078/5078

exit status 1
FAIL    boringssl.googlesource.com/boringssl/ssl/test/runner    51.701s

FAILED: CMakeFiles/run_ssl_runner_tests C:/msys64/home/maksa/forks/aws-lc/build/CMakeFiles/run_ssl_runner_tests
C:\WINDOWS\system32\cmd.exe /C "cd /D C:\msys64\home\maksa\forks\aws-lc && C:\msys64\clang64\bin\cmake.exe -E echo "Running SSL tests" && cd ssl/test/runner && C:/msys64/clang64/bin/go.exe test -timeout 10m -shim-path C:/msys64/home/maksa/forks/aws-lc/build/ssl/test/bssl_shim.exe"
ninja: build stopped: subcommand failed.

@justsmth justsmth force-pushed the fix-windows-clang branch from 2abd797 to 74a11ba Compare May 1, 2025 12:54
@ognevny
Copy link
Contributor Author

ognevny commented May 1, 2025

seems like you have to pass GOROOT env in each step... is there any cmake option to hardcode Go path?

@justsmth justsmth force-pushed the fix-windows-clang branch 3 times, most recently from 99068d6 to 042297b Compare May 1, 2025 13:11
@ognevny
Copy link
Contributor Author

ognevny commented May 1, 2025

cmake itself uses different Go: -- Go compiler 1.21.13 found

@justsmth justsmth force-pushed the fix-windows-clang branch from 042297b to 807b7ae Compare May 1, 2025 13:18
@justsmth justsmth force-pushed the fix-windows-clang branch from 807b7ae to 316cb30 Compare May 1, 2025 13:21
@justsmth
Copy link
Contributor

justsmth commented May 1, 2025

Test are passing: https://github.com/aws/aws-lc/actions/runs/14776095409/job/41484616153?pr=2381 😊

@ognevny
Copy link
Contributor Author

ognevny commented May 1, 2025

great! how long will it take to integrate this change into aws-lc-sys rust crate? making it upstreamed ASAP will make maintenance burdens much easier... for now I have to explain how to fix the build

@justsmth
Copy link
Contributor

justsmth commented May 1, 2025

great! how long will it take to integrate this change into aws-lc-sys rust crate?

After this is merged, we would need tag a release of AWS-LC then prepare a release for aws-lc-sys that aligns with it. We could get this all together by next week. I'll see if I can speed that up.

ognevny referenced this pull request in msys2/MINGW-packages May 2, 2025
cargo manages to use vendored dependencies when they're listed with path

also change style for rustup recipe a bit: '\t' -> '  ' and remove extra
'/'
@ognevny
Copy link
Contributor Author

ognevny commented May 4, 2025

is there any issue that should be addressed in this PR?

@ognevny
Copy link
Contributor Author

ognevny commented May 5, 2025

is there any issue that should be addressed in this PR?

@justsmth ^

@dkostic
Copy link
Contributor

dkostic commented May 5, 2025

There is a CI test failing, not related to the changes in this PR. I restarted the failed build and will merge the PR when it succeeds.

@ognevny
Copy link
Contributor Author

ognevny commented May 6, 2025

There is a CI test failing, not related to the changes in this PR. I restarted the failed build and will merge the PR when it succeeds.

thanks, it succeeded now

@justsmth justsmth merged commit cddf0ec into aws:main May 6, 2025
114 checks passed
@ognevny ognevny deleted the fix-windows-clang branch May 6, 2025 19:21
@justsmth justsmth mentioned this pull request May 7, 2025
justsmth added a commit that referenced this pull request May 7, 2025
### Description of changes: 
Prepare v1.51.1

### What's Changed
* Use Win32 threads when compiling with Clang on MinGW by @ognevny in
#2381

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
SomeoneToIgnore pushed a commit to zed-industries/zed that referenced this pull request May 9, 2025
To pull in aws/aws-lc#2381 which fixes build on
MinGW with Clang

Release Notes:

- N/A
gstreamer-github pushed a commit to sdroege/gst-plugin-rs that referenced this pull request May 12, 2025
This is required to fix the build with clang+mingw on Windows,
see aws/aws-lc#2381

Updated via "cargo update -p aws-lc-rs --precise 1.13.1"

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2237>
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: Win32 threads should be used when compiling with clang
5 participants