-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Enable Dispatch overlay on Linux #974
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
This tries to use the system version of libdispatch in the overlay (which might not be there, or be terribly outdated or something else), not the version that we are building. |
Right - but there's (currently) no integration of the swift-corelibs-libdispatch build into the swift build. Hopefully this would at least allow further integration of Dispatch on Linux whist we work out how to integrate the builds. |
Sorry, but this will break the build on systems where the is no system libdispatch, or it is outdated. |
On Linux, the addition of the overlay is optional - so won't be broken out of the box. Obviously I'm happy to make changes though if you have some suggestions on how to add the overlay and avoid breakages. |
@seabaylea is away for a couple of weeks so I am following up on his behalf in his absence. @gribozavr can you tell us what's required in order for this request to be accepted? We're prepared to make whatever changes are necessary. Or will this require a change to the build environment so Dispatch is always built for Linux? |
I see, so it won't be built by default. It should be fine as a platform for experimentation, but not for production. One issue that I'm seeing is that on OS X, with this pull request merged, I'm seeing warnings from ninja:
Could you investigate? I don't immediately see what would be the cause of this. |
Great! Thanks @gribozavr. Yes, we'll take a look. |
The warnings are reported due a duplicate rule to build Dispatch.apinotesc. The apinotes compilation happens in the add_swift_library() function defined in AddSwift.cmake. For every module, the related apinotes are picked up. With the "dispatch overlay" changes we see Dispatch.apinotes being picked up for "Darwin" and "Dispatch" - the former is invalid. The above tweak will avoid this problem. |
@gribozavr Could you please review/test the above change? |
My understanding was that @parkera and @phausler did not want to go in this direction; they preferred that the corelibs version of dispatch become a mixed-source library (like mixed-source frameworks built with Xcode). I'm sure they can comment better than me, though, and maybe I was misunderstanding. |
I first mixed this up with the changes to get the dispatch project into the build script, but @jrose-apple is right - dispatch should not use the overlay on Linux but instead provide all functionality itself. This has to be the long term direction. Instead of building part of dispatch (and other overlay projects) into every application, we provide their functionality as a library. |
See also #1030 . |
@seabaylea Thanks for this work. It sounds, however, that @parkera advises we put non-Darwin changes to libDispatch in the corelibs. Closing this pull request. |
Now that libdispatch is compiling and passing almost all applicable tests on Linux we need to enable its use by Swift code by enabling the Dispatch overlay to be build on Linux. The code changes below are (very) heavily based on a commit (ac6de62) from @slavapestov in November that was previously reverted due to a build break.
This takes the same approach of enabling the Dispatch overlay on Linux as a non-default option, enabled by passing:
to
utils/build-script
The use of
MACH_SEND
,MACH_RECV
andMEMORYPRESSURE
are wrapped by#if defined (__APPLE__)
in Dispatch.cpp and by#if _runtime(_ObjC)
in Dispatch.swift as they're not supported by libdispatch on Linux (and unlikely to be on other non-Darwin platforms). This follows what Slava did previously.Additionally
qos_class_t
isn't available on Linux as there's nosys/qos.h
, so is replaced withCInt
on Linux (as it is in libdispatch).