-
Notifications
You must be signed in to change notification settings - Fork 176
Add CMake build files #60
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
Conversation
Do we need to make sure we carry this define with us to keep Windows support? https://github.com/apple/swift-crypto/blob/main/Package.swift#L57 @compnerd |
Do we have any plan to keep the CMakeLists.txt up-to-date? |
Marking this a draft since there are build errors
I haven't figured out how to fix this yet.
@Lukasa - we might be able to use env var instead of hardcoding the list of files but I could be wrong. |
Maybe we can add building with CMake as a step to CI so that there would at least be feedback if a PR breaks it? |
I think we will absolutely have to do @neonichu's suggestion, irregardless of anything else. If we don't add that step I guarantee that we'll break you down the road because I'll 100% forget to make sure this still works. However, the other problem we have is that you're currently explicitly naming every single file in the CBoringSSL target. This target's files are updated as a monolithic block with some regularity, and the exact files in there have high churn. Is there some way we can express the list of files by way of a glob? If not, I think I'd like us to invest in some scripting to automatically generate the file list for a given target. This should be fairly easy, as right now we're just following the rules that SwiftPM lays out. Essentially I want some way to say "look at this Package.swift and generate the appropriate CMakeLists.txt equivalent". I don't think this is particularly technically challenging, but would drastically reduce the maintenance burden of the CMake build system. |
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
add_library(Crypto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a static library or a shared library? At least on Windows, static linking doesn't work yet, and needs to be shared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean this should say add_library(Crypto SHARED
? The examples that I've looked at don't specify SHARED
and only the C modules have STATIC
so I don't know what's the right thing to do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the current signature leaves it in the control of the user. If you specify -D BUILD_SHARED_LIBS=YES
then this is implicitly a dynamic library and otherwise (or if you do -D BUILD_SHARED_LIBS=NO
) it is implicitly a static library. The reason for not specifying an explicit shared/static here is to allow the user to select the build type. This is why setting the default value for BUILD_SHARED_LIBS
to YES
is what I suggested above.
The problem with using a GLOB for the file list is that any changes will not be picked up. You will need to remember that you changed things and do a clean build. I think that generating the file-list should be possible and would be a much nicer approach to just update the list as part of the generation script (as the updates are scripted). |
I think we should be able to script this using |
lmk if and when we need to set a CI job for this |
@swift-server-bot test this please |
Not sure how 5f80571 causes these errors. https://ci.swiftserver.group/job/swift-crypto-api-breakage-prb/68/console
https://ci.swiftserver.group/job/swift-crypto-api-breakage-prb/69/console
@swift-server-bot test this please |
@swift-server-bot test this please |
"soundess" validation failure is expected until #63 gets merged |
This is ready for review. |
crypto/fipsmodule/x86_64-mont.mac.x86_64.S | ||
crypto/fipsmodule/x86_64-mont5.mac.x86_64.S) | ||
endif() | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should cover windows and Linux as well, but that is okay to have as a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which ones are for Windows? I don't see any *x86_64*
for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows has some assembly routines for x86, not for x64. I don't think that it matters too much if we don't get that variant correct. I don't currently intend to ship a 32-bit toolchain. For Windows x86, use of swift-crypto as a client should go through SPM, which will handle it properly. If someone intends to ship a non-x64 variant of the toolchain, we should handle it at that time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Added Linux 6d2e5c1
I added |
Build error unrelated. Looks like build agent 1 is busted. @swift-server-bot test this please |
Motivation: This is to support swiftlang/swift-package-manager#3202, which adds swift-crypto as a dependency to SwiftPM. Modifications: Add CMake files. Result: Can build swift-crypto with cmake.
Make the BoringSSL based build for macOS complete enough. We can now build a shared library version of SwiftCrypto on macOS without CryptoKit.
Script was failing at "build_and_do" steps. Order seems to matter. - When build new then old, build fails. - When build old then new, build succeeds. This might be because "new" build adds files to `.build` that "old" doesn't expect? Probably because of the `.modulemap` files that were added as part of the PR. Cleaning up `.build` in between builds seems to fix the problem.
Regenerate CMakeLists.txt using script
Updated |
@tomerd build agent for 5.3 is still no good: https://ci.swiftserver.group/job/swift-crypto-swift53-prb/59/console |
@swift-server-bot test this please |
LGTM FWIW |
scripts/update_cmakelists.sh
Outdated
|
||
update_cmakelists "CCryptoBoringSSL" "*.c" | ||
update_cmakelists "CCryptoBoringSSLShims" "*.c" | ||
update_cmakelists "Crypto" "*.swift" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we not generating the .S
list on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wasn't sure if they change often. Sounds like we should generate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can, yeah. They do change with some frequency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amended 4a1b864
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Motivation: SwiftPM's CMake build (swiftlang/swift-package-manager#3202) unsuccessful even with apple#60. Modifications: - Use consistent `SWIFT_CRYPTO_EXPORTS` naming. In some places `CRYPTO_EXPORTS` was used instead. - Install `CCryptoBoringSSL` so we can import it in code (see swiftlang/swift-package-manager#3202) - Always set `BUILD_SHARED_LIBS` Result: Successful CMake build.
Motivation: SwiftPM's CMake build (swiftlang/swift-package-manager#3202) unsuccessful even with apple#60. Modifications: - Use consistent `SWIFT_CRYPTO_EXPORTS` naming. In some places `CRYPTO_EXPORTS` was used instead. - Install `CCryptoBoringSSL` so we can import it in code (see swiftlang/swift-package-manager#3202) - Always set `BUILD_SHARED_LIBS` Result: Successful CMake build.
Motivation: SwiftPM's CMake build (swiftlang/swift-package-manager#3202) unsuccessful even with #60. Modifications: - Use consistent `SWIFT_CRYPTO_EXPORTS` naming. In some places `CRYPTO_EXPORTS` was used instead. - Install `CCryptoBoringSSL` so we can import it in code (see swiftlang/swift-package-manager#3202) - Always set `BUILD_SHARED_LIBS` Result: Successful CMake build.
Motivation:
This is to support swiftlang/swift-package-manager#3202, which adds swift-crypto as a dependency to SwiftPM.
Modifications:
Add CMake files.
Result:
Can build swift-crypto with cmake.