Skip to content
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

Merged
merged 1 commit into from
Sep 29, 2016

Conversation

modocache
Copy link
Contributor

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.

This pull request was split out of #4972, which addresses SR-1362.

@gottesmm
Copy link
Contributor

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?

@gottesmm
Copy link
Contributor

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.

Copy link
Contributor

@gottesmm gottesmm left a 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
Copy link
Contributor

@gottesmm gottesmm Sep 25, 2016

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?

Copy link
Contributor Author

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
Copy link
Contributor

@gottesmm gottesmm Sep 25, 2016

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.

Copy link
Contributor

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.

@modocache
Copy link
Contributor Author

modocache commented Sep 25, 2016

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.

That's fair. I think the closest example of TARGET_SDKS being used this way is in stdlib/public/Platform, although the target names are different: swiftDarwin, swiftGlibc, and swiftMSVCRT. I guess it's unconventional, but it does work remarkably well for #4972... 😇

@gottesmm
Copy link
Contributor

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?

@modocache
Copy link
Contributor Author

Even if they're given the same names, the libraries do end up in their own subfolders -- macOS's in macosx/x86_84/libswiftCore.dylib, Android's in android/amv7/libswiftCore.so, and so on. I feel like that's ideal. It seems like naming them differently will make it harder to specify them as dependencies -- swiftGlibc will need to depend on swiftCoreAndroid, swiftDarwin will need to depend on swiftCore or swiftCoreDarwin, and so on. On the other hand, is there a compelling reason to name them differently? If this isn't the current convention, maybe it could become the new convention...? :)

@modocache
Copy link
Contributor Author

modocache commented Sep 26, 2016

@gottesmm New comments added! Let me know what you think.

@gottesmm
Copy link
Contributor

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.
@modocache
Copy link
Contributor Author

@swift-ci please smoke test and merge

@modocache
Copy link
Contributor Author

@swift-ci Please smoke test and merge

@swift-ci swift-ci merged commit ba1127f into swiftlang:master Sep 29, 2016
@tfiala
Copy link
Contributor

tfiala commented Sep 29, 2016

We have several builders that are red after this. Two external ones are here:
https://ci.swift.org/job/oss-lldb-incremental-linux-ubuntu-15_10/6238/
https://ci.swift.org/job/oss-lldb-incremental-linux-ubuntu-16_04/83/

I'm going to try a clean build. If that doesn't fix it, we need this removed.

@gottesmm
Copy link
Contributor

@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.

@tfiala
Copy link
Contributor

tfiala commented Sep 29, 2016

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.

@tfiala
Copy link
Contributor

tfiala commented Sep 29, 2016

(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.

@tfiala
Copy link
Contributor

tfiala commented Sep 29, 2016

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.

@modocache
Copy link
Contributor Author

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 modocache deleted the stdlib-stubs-cmake-target-sdks branch September 29, 2016 17:03
@tfiala
Copy link
Contributor

tfiala commented Sep 29, 2016

@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).

@gottesmm
Copy link
Contributor

@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.

@tfiala
Copy link
Contributor

tfiala commented Sep 29, 2016

@tfiala I already have some thoughts in this area, but it would be good to also involve @llvm-beanz as well.

Okay. As long as we're working towards a solution, that sounds good.

@llvm-beanz
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants