Repository navigation
Build with SwiftPM on Windows - #36
Open
mortenbekditlevsen wants to merge 1 commit into
Open
mortenbekditlevsen wants to merge 1 commit into
mortenbekditlevsen wants to merge 1 commit into
Conversation
- Defines _WINSOCKAPI_, NOMINMAX and NOCRYPT on Windows, as swift-nio-ssl's copy of BoringSSL does (2.37.3): otherwise windows.h's winsock.h clashes with winsock2.h. - Renames the thread-exit callback on Windows with a define (thread_win.cc allows it to be a macro). Unprefixed, it clashes with the one in swift-crypto's BoringSSL when both are linked into one binary. - Compiles the error tables from gen/crypto/err_data.cc instead of err_data.c. crypto/err/err.cc (C++) declares them without extern "C"; elsewhere a global variable's C++ name is its C name, but on Windows it isn't, so the C definitions didn't link.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates Package.swift to resolve Windows-specific compilation and linking issues. Specifically, it replaces err_data.c with gen/crypto/err_data.cc to avoid C++ name mangling issues on Windows, and adds several Windows-specific preprocessor definitions (_WINSOCKAPI_, NOMINMAX, NOCRYPT, and a custom p_thread_callback_boringssl macro) to prevent header clashes and symbol collisions. There are no review comments, so I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This builds gRPC's BoringSSL with SwiftPM on Windows. Only
Package.swiftchanges, so the changes survivescripts/sync-upstream.sh._WINSOCKAPI_,NOMINMAXandNOCRYPTon Windows, as swift-nio-ssl's copy of BoringSSL defines them. Otherwise windows.h's winsock.h clashes with winsock2.h.p_thread_callback_boringsslbecomesp_thread_callback_boringssl_grpc. It isn't prefixed like the other symbols, so it clashes with the one in swift-crypto's or swift-nio-ssl's BoringSSL when both end up in one binary.crypto/thread_win.ccalready allows the name to be a macro (it stringifies it throughEXPAND_AND_STRINGIFY).gen/crypto/err_data.ccinstead of the generatederr_data.c.crypto/err/err.ccis C++ and declares the tables withoutextern "C". Elsewhere a global variable's C++ name is the same as its C name, but on Windows it isn't, so the C definitions didn't link.gen/crypto/err_data.ccis BoringSSL's own C++ version of the same tables, and it comes with each sync. If you agree,scripts/generate-err-data.shmay no longer be needed. I've left it in.We build gRPC this way for Windows in firebase-swift, a Swift port of the Firebase SDK that also runs on Linux, Android and Windows. Its Windows CI builds Firestore and runs its integration tests with these changes, on top of 0.41.0. I also built this branch on macOS.
🤖 Generated with Claude Code