Skip to content

Export objc_retainAutoreleasedReturnValue() #258

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 1 commit into from
Jun 30, 2017

Conversation

spevans
Copy link
Contributor

@spevans spevans commented Jun 16, 2017

  • This allows it to be used by Foundation so that the duplicate
    function can be removed from CFRuntime.c in corelibs-foundation.

  • This also makes the export match the symbol in libdispatch.a.

Since SwiftFoundation depends on libdispatch, there is no reason to have the function defined in both libraries. It shouldnt break the build as Foundation uses the linker argument --allow-multiple-definition but once this PR has been merged the duplicate function can be removed from Foundation and the linker argument eliminated.

At some point in the future the swift compiler may be fixed to not require this work around and then it can be removed from libdispatch as well.

@parkera
Copy link
Contributor

parkera commented Jun 16, 2017

I'm not sure we want to propagate the lie of this function on Linux. It promises autorelease behavior but can't deliver it.

@spevans
Copy link
Contributor Author

spevans commented Jun 16, 2017

@parkera Its really just a temporary fix, libFoundation.so is currently exporting it anyway, but this will allow it to be removed from libFoundation completely then once a better solution is implemented by the compiler (maybe just emiting the swift_retain() directly?) it can be removed from here. libdispatch.a currently exports the symbol so I dont think its anymore detrimental.

@parkera
Copy link
Contributor

parkera commented Jun 16, 2017

dispatch seems like the wrong place for it though - it doesn't have any of the API which requires it.

@dgrove-oss
Copy link
Contributor

Seems like the logical temporary fix (if one is needed) would be to have a single symbol in the swift runtime that both dispatch and foundation could link against on linux.

@parkera
Copy link
Contributor

parkera commented Jun 16, 2017

Yah I've long thought the runtime would be the place for both this stuff and the blocks as well. Putting it in dispatch is convenient but doesn't seem quite right.

@spevans
Copy link
Contributor Author

spevans commented Jun 16, 2017

I can do a PR to put it in the runtime instead, it will just need to be merged at the same time it is removed completely from libdispatch to avoid duplicate symbol issues

@spevans
Copy link
Contributor Author

spevans commented Jun 17, 2017

I updated the PR to remove the function and also created swiftlang/swift#10355 which adds the function to swift runtime.

~~This PR will need to be tested/ merged at the same time as the swift PR~~~

Adding it to the runtime was rejected as this is not the correct full solution, it is only a workaround. Ive gone back to the original solution of exporting it from libdispatch so it can be removed from corelibs-foundation and will open a Jira to work on a proper fix for the runtime.

@spevans spevans force-pushed the pr_expose_symbol branch from 45e331b to a7d94d0 Compare June 20, 2017 14:34
@spevans
Copy link
Contributor Author

spevans commented Jun 29, 2017

Is there any objection to this PR? I know it is a temporary work around but removing the duplicated symbol will be helpful in simplifying the linker commands used for SR-648. If this change is OK I will open a followup to remove the duplicate from libFoundation.

I opened https://bugs.swift.org/browse/SR-5271 for a correct fix for this problem which probably requires a compiler change but Im not sure how much work is involved there.

@parkera
Copy link
Contributor

parkera commented Jun 29, 2017

Is this function actually used anywhere in dispatch? If not, maybe a better answer is to simply remove it and let Foundation use its own.

Copy link
Contributor

@das das left a comment

Choose a reason for hiding this comment

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

I'm not a big fan of this but ok with it as a short term workaround

please fix the comment I mentioned and I will merge

extern "C" void swift_retain(void *);

SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be conditional to Linux ? (like other things are conditional to linux above)

though I guess it is really for non-Darwin, in which case I would amend the comment above to not mention Linux, this seems applicable to other potential targets that don't have an ObjC runtime (*bsd etc)

- This allows it to be used by Foundation so that the duplicate
  function can be removed.
@spevans spevans force-pushed the pr_expose_symbol branch from a7d94d0 to b756329 Compare June 29, 2017 23:56
@spevans
Copy link
Contributor Author

spevans commented Jun 29, 2017

@das I wrapped the function inside a #if !USE_OBJC and updated the comment changing Linux to non-ObjC platform.

@parkera It is used by swift_overlay.o

@das
Copy link
Contributor

das commented Jun 30, 2017

looks good, thanks!

@das das merged commit ded5bab into swiftlang:master Jun 30, 2017
das added a commit that referenced this pull request Jul 31, 2017
Export objc_retainAutoreleasedReturnValue()

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
@das das removed the darwin pending label Aug 1, 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.

4 participants