Skip to content

Facilitate implicit import of Dispatch in Foundation #201

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

Merged
merged 2 commits into from
Sep 14, 2017

Conversation

johnno1962
Copy link
Contributor

@johnno1962 johnno1962 commented Sep 12, 2017

Hi Apple,

Would you consder this minor change that achieves two things: It allows XCTest to build for Android by removing a reference to stdout and it paves the way for Foundation to implicitly import Dispatch for compatibility with Darwin. As this would create a implicit link against libdispatch.so, this requires this small change so building XCTest.so knows where to find the library when building on all Linuxies.

This PR is essentially the previous PR but not modifiying Package.swift and adding the path to the lib dispatch.so library during a toolchain build to resolve: https://ci.swift.org/job/swift-corelibs-foundation-PR-Linux/119/console when we tried to have Foundation implicitly import dispatch: swiftlang/swift-corelibs-foundation#1206 (comment)

Thanks,

John

# We embed an rpath of `$ORIGIN` to ensure other referenced
# libraries (like `Foundation`) can be found solely via XCTest.
"-Xlinker -rpath=\\$ORIGIN "
"-o {build_dir}/libXCTest.so".format(
swiftc=swiftc,
build_dir=build_dir,
dispatch_build_dir=os.path.join(args.libdispatch_build_dir, 'src', '.libs'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally in favor of this change, which makes this a little more explicit. Thanks!

fflush(stdout)
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer to @briancroom on this one. Does Android really not provide a stdout file handle? Is this a shortcoming in the Swift Glibc overlay when built for Android? If so, I guess I'm fine with this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is interesting! I dug a little bit and found that stdout isn't being build for Android currently: https://github.com/apple/swift/blob/48308411393e730cf3cb21d353a9be31045c47e4/stdlib/public/Platform/Platform.swift#L98

And here's a bug about a Swift test failure caused by the same issue (guess who filed it? 🙃): https://bugs.swift.org/browse/SR-1835

It looks like these could be brought in only by building against Android API level 23, which may be an acceptable change at some point in the future.

@johnno1962 johnno1962 changed the title Minor android changes Facilitate implicit import of Dispatch in Foundation Sep 14, 2017
@johnno1962
Copy link
Contributor Author

Hi @briancroom, I’ve changed the title of the this PR as while it does include a change for Android it is primarily about facilitating an implicit import of Dispatch when developers import Foundation to mimic the behaviour of Darwin for which this small change is a blocker. Otherwise the Linux Swift build breaks see: swiftlang/swift-corelibs-foundation#1206 (comment)

@briancroom
Copy link
Contributor

@swift-ci please test

@briancroom
Copy link
Contributor

Thanks @johnno1962, let's get this merged, pending swift-ci going smoothly.

@johnno1962
Copy link
Contributor Author

Thanks @briancroom, I’ve corrected the nits and indenting on the other PR and squashed so it shouldn’t conflict once this PR is merged if you're also happy with the Package.swift changes.

@briancroom briancroom merged commit 4f2e192 into swiftlang:master Sep 14, 2017
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.

3 participants