Attached patch fixes issues #63582 and #57718 when building my port to CYGWIN of llvm-project.
https://github.com/llvm/llvm-project/issues/63582
https://github.com/llvm/llvm-project/issues/57718
I have not seen this error also on LLVM as described in issue #51143, but perhaps this patch could be used for fixing it, since it is the same problem.
https://github.com/llvm/llvm-project/issues/51143