awslabs / aws-crt-swift

Apache License 2.0
15 stars 18 forks source link

Build fails on Windows. #289

Open jeffdav opened 3 weeks ago

jeffdav commented 3 weeks ago

Describe the bug

Building on Windows using swift build fails with errors.

Expected Behavior

swift build should build the project on Windows.

Current Behavior

PS C:\Users\jeffd\src\aws-crt-swift> git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
PS C:\Users\jeffd\src\aws-crt-swift> git pull
Already up to date.
PS C:\Users\jeffd\src\aws-crt-swift> swift build
warning: 'aws-crt-swift': Invalid Exclude 'C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-checksums\source\intel\visualc': File not found.
Building for debugging...
...snip warnings about format specifiers...
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\windows\iocp\socket.c:293:27: error: field has incomplete type 'struct aws_overlapped'
  293 |     struct aws_overlapped signal;
      |                           ^
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\windows\iocp\socket.c:293:12: note: forward declaration of 'struct aws_overlapped'
  293 |     struct aws_overlapped signal;
      |            ^
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\windows\iocp\socket.c:844:57: error: incomplete definition of type 'struct aws_overlapped'
  844 |     struct socket_connect_args *socket_args = overlapped->user_data;
      |                                               ~~~~~~~~~~^
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\windows\iocp\socket.c:293:12: note: forward declaration of 'struct aws_overlapped'
  293 |     struct aws_overlapped signal;
      |            ^
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\windows\iocp\socket.c:974:5: error: call to undeclared function 'aws_overlapped_init'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  974 |     aws_overlapped_init(&socket_impl->read_io_data->signal, s_socket_connection_completion, connect_args);
      |     ^
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\windows\iocp\socket.c:990:9: error: call to undeclared function 'aws_overlapped_to_windows_overlapped'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  990 |         aws_overlapped_to_windows_overlapped(&socket_impl->read_io_data->signal));
      |         ^
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\windows\iocp\socket.c:1626:43: error: incomplete definition of type 'struct aws_overlapped'
 1626 |     struct aws_socket *socket = overlapped->user_data;
      |                                 ~~~~~~~~~~^
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\windows\iocp\socket.c:293:12: note: forward declaration of 'struct aws_overlapped'
  293 |     struct aws_overlapped signal;
      |            ^
...snip more errors saying basically the same thing...
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
[20/227] Compiling AwsCIo source\windows\iocp\socket.c
PS C:\Users\jeffd\src\aws-crt-swift>

Reproduction Steps

  1. Clone the repo.
  2. Run swift build from the repo root.
  3. Observe.

Possible Solution

My initial investigation indicated defining AWS_USE_IO_COMPLETION_PORTS might solve the issue. Indeed, that does allow things to progress further:

PS C:\Users\jeffd\src\aws-crt-swift> swift build -Xcc -DAWS_USE_IO_COMPLETION_PORTS
warning: 'aws-crt-swift': Invalid Exclude 'C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-checksums\source\intel\visualc': File not found.
Building for debugging...
...snip format specifier warnings...
C:\Users\jeffd\src\aws-crt-swift\aws-common-runtime\aws-c-io\source\bsd\kqueue_event_loop.c:22:10: fatal error: 'sys/event.h' file not found
   22 | #include <sys/event.h>
      |          ^~~~~~~~~~~~~
1 error generated.
[40/224] Compiling AwsCIo source\bsd\kqueue_event_loop.c
PS C:\Users\jeffd\src\aws-crt-swift>

This seems like a different problem. Perhaps this shouldn't be built at all on Windows?

Additional Information/Context

No response

aws-crt-swift version used

commit 7b42e0343f28b3451aab20840dc670abd12790bd (HEAD -> main, tag: v0.36.0, origin/main, origin/HEAD)

Compiler and Version used

compnerd.org Swift version 6.0-dev (LLVM a527f49f462b0d7, Swift eef85a7be270421) Target: x86_64-unknown-windows-msvc

Operating System and version

Windows 11 Version 23H2 OS Build 22631.4249

DmitriyMusatkin commented 3 weeks ago

Dont think we currently support windows at all, so this would be a feature request

jeffdav commented 3 weeks ago

My real goal is to make aws-sdk-swift build on Windows, but I need this to build first.

I spent some time looking at it and put together a draft change that mostly makes it build: https://github.com/awslabs/aws-crt-swift/pull/290

See comments in the PR, and let me know what you think.

waahm7 commented 2 weeks ago

Currently, both Aws-crt-swift and Aws-sdk-swift don't support Windows. This is a feature request, and I think we will probably hit more issues than just #290 to properly support Windows and also add CI for it. Swift SDK might have to do some work as well on their side. We have added this to our backlog and will update here as soon as we have any updates.

Please 👍 the original issue and that will help us prioritize this.