-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[stubs] Update CMake to use TARGET_SDKS (NFC) #5002
[stubs] Update CMake to use TARGET_SDKS (NFC) #5002
Conversation
So I guess what is happening here is that instead of doing tests using if statements, we are using TARGET_SDK and creating two different libraries to decide what to conditionally compile? |
Yes. I did understand this correctly. It is a little weird since I think we usually use such an IN_SDK thing for individual libraries that are only on one platform or the other IIRC. |
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.
Looks good overall, just want some updated comments.
SwiftNativeNSXXXBase.mm.gyb) | ||
set(swift_stubs_unicode_normalization_sources | ||
UnicodeNormalization.cpp) | ||
set(LLVM_OPTIONAL_SOURCES |
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.
Isn't LLVM_OPTIONAL_SOURCES dead?
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.
Removing this results in a CMake error, so I don't think so.
@@ -1,33 +1,40 @@ | |||
set(swift_stubs_objc_sources) | |||
set(swift_stubs_unicode_normalization_sources) | |||
set(swift_stubs_sources |
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.
Can you add comments for each group of these sources. Maybe saying something like:
// Platform Independent Sources
set(swift_stubs_platform_independent_sources ...)
// Darwin Only ObjC Sources. This consists of objective-c related stubs.
...
// Sources for Android, Cygwin, FreeBSD, Linux. This consists currently of just ICU sources. [[INSERT EXPLANATION OF WHY WE DO NOT DO THIS ON DARWIN]].
...
I forgot the story with ICU on Darwin, but IIRC @aschwaighofer knows. Arnold, do you remember.
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.
On Darwin we don't use ICU for String functions (hashing, comparison) but call to Foundation's NSString/CFString functions. On non-darwin platforms we call to ICU for this functionality.
The stubs for calling to ICU are in UnicodeNormalization.cpp.
That's fair. I think the closest example of |
maybe the way to do it is to just change the names of the libraries. I.e. maybe: swiftStubsDarwin. But I am not sure what you would use for the others... NonDarwin? |
Even if they're given the same names, the libraries do end up in their own subfolders -- macOS's in |
1d569fd
to
f04ef12
Compare
@gottesmm New comments added! Let me know what you think. |
I think this is fine. Resolve the conflict and let er rip. |
The `add_swift_library` CMake function takes an optional `TARGET_SDKS` parameter. When used, only CMake targets for the specified SDKs are added. Refactor `stdlib/public/stubs` to use this parameter. This also eliminates logic that determines additional flags or source files to include based on `SWIFT_HOST_VARIANT`, which makes it easier for hosts to add targets for different platforms.
f04ef12
to
b86125a
Compare
@swift-ci please smoke test and merge |
@swift-ci Please smoke test and merge |
We have several builders that are red after this. Two external ones are here: I'm going to try a clean build. If that doesn't fix it, we need this removed. |
@modocache @tfiala If we need to revert this, this just shows how in light of cmake changes, we need to be sure that we use a clean test. |
It appears all that is needed here is a build directory wipe. Two of the CI nodes I saw failing made it past the CMake issue in the Swift portion after doing a clean build. |
(i.e. this is fine). @gottesmm yes, I think we may want smarts to detect cmake changes, and when present, maybe force a clean build. We'll have to think about that and look at how many clean builds that would have triggered. I don't know the portion of changelists that have CMake-related changes, but it's something we can look at. |
It gets a bit trickier than that, though, since we have several build slaves that are eligible for a job. So it's not good enough to just scan the new changes since the last build for a build job. We'd have to scan the new change lists since the last build of the job per slave, since the build slave has its own local directory. Maybe the better thing to do here would be to wipe the build dir on all eligible build slaves at the time of detection. That simplifies the "how to delete" step, but complicates the "find and execute" brains of it. Anyways, we'll take this offline. |
Oomph, sorry for the build failures, and sorry about not responding sooner. I'll use the Swift CI clean build options for the other CMake pull requests I have queued up. Let me know if there's also something I can do beyond that. |
@modocache Oh no worries, I think it exposes something we probably need to address at the infrastructure level. (Not to mention, CMake probably shouldn't be failing here, but I'm not sure if that's an issue with our application of it or an issue of it not flushing out something it should have flushed out). |
@tfiala I already have some thoughts in this area, but it would be good to also involve @llvm-beanz as well. The issue that I have found to cause this the most often is with respect to assumptions around default values being added to the cmake cache. So for instance, someone makes a change, provides a default that will work, but in the incremental build there is already a cached value that does not work with the default. So things get out of wack. |
Okay. As long as we're working towards a solution, that sounds good. |
Looking at this, it is almost certainly a situation where swift's build is using cached variables and shouldn't be. Since the commits didn't directly change the value of a cached variable there should be no need to clean out the caches, unless there are cached variables being used in unholy ways (which I think is the case here). For example it looks like library dependencies are being cached as internal variables. That is not right. |
The
add_swift_library
CMake function takes an optionalTARGET_SDKS
parameter. When used, only CMake targets for the specified SDKs are added.Refactor
stdlib/public/stubs
to use this parameter. This also eliminates logic that determines additional flags or source files to include based onSWIFT_HOST_VARIANT
, which makes it easier for hosts to add targets for different platforms.This pull request was split out of #4972, which addresses SR-1362.