Skip to content

Conversation

@aciidgh
Copy link
Contributor

@aciidgh aciidgh commented Oct 21, 2017

rdar://problem/28109524 [SR-6178]: Pass -fblocks to clang for C language targets

Currently, blocks in C libraries will only work if the C target is being imported by a Swift target and that Swift target imports Dispatch. This isn't very optimal but its better than passing -Xcc -fblocks on the command line. This will not cause any issues if the C target is not using blocks. We can track always linking against blocks runtime as an enhancement.

@aciidgh aciidgh requested a review from ddunbar October 21, 2017 00:12
@aciidgh
Copy link
Contributor Author

aciidgh commented Oct 21, 2017

(need to update the tests to account for this change, will do if we go ahead with this PR)

#if os(macOS)
args += ["-fobjc-arc"]
#elseif os(Linux)
args += ["-fblocks"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably just be added unconditionally, like -fmodules. It doesn't do any harm on Apple platforms, and it'll be necessary on BSD and Systemz and all the others.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed

Copy link
Contributor

Choose a reason for hiding this comment

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

also when cross-compiling to Linux, you definitely want to have -fblocks set.

Copy link
Contributor

@ddunbar ddunbar left a comment

Choose a reason for hiding this comment

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

Can we get an integration test that validates this?

@aciidgh aciidgh force-pushed the always-add-blocks-linux branch from 352dbd5 to dbb8e55 Compare October 23, 2017 18:10
@aciidgh
Copy link
Contributor Author

aciidgh commented Oct 23, 2017

@swift-ci please smoke test

<rdar://problem/28109524> [SR-6178]: Pass -fblocks to clang for C language targets

Currently, blocks in C libraries will only work if the C target is being
imported by a Swift target and that Swift target imports Dispatch. This
isn't very optimal but its better than passing -Xcc -fblocks on the
command line. This will not cause any issues if the C target is not
using blocks. We can track always linking against blocks runtime as an
enhancement.
@aciidgh aciidgh force-pushed the always-add-blocks-linux branch from dbb8e55 to 621acf6 Compare October 23, 2017 19:39
@aciidgh
Copy link
Contributor Author

aciidgh commented Oct 23, 2017

@swift-ci please smoke test

@aciidgh aciidgh merged commit d01f13b into swiftlang:master Oct 23, 2017
@aciidgh aciidgh deleted the always-add-blocks-linux branch October 23, 2017 20:12
@aciidgh
Copy link
Contributor Author

aciidgh commented Oct 23, 2017

Integration test: swiftlang/swift-integration-tests#25

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.

4 participants