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

[SR-5271] Don't emit objc_retainAutoreleasedReturnValue() on non-ObjC targets #47846

Closed
spevans opened this issue Jun 20, 2017 · 1 comment · Fixed by #72011
Closed

[SR-5271] Don't emit objc_retainAutoreleasedReturnValue() on non-ObjC targets #47846

spevans opened this issue Jun 20, 2017 · 1 comment · Fixed by #72011
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself IRGen LLVM IR generation Linux Platform: Linux objective-c interop Feature: Interoperability with Objective-C swift 5.10 unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@spevans
Copy link
Collaborator

spevans commented Jun 20, 2017

Previous ID SR-5271
Radar None
Original Reporter @spevans
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Linux
Assignee None
Priority Medium

md5: a6d7c57d30f3e5c418c7e873e72b29e1

relates to:

  • SR-2755 False objc_autoreleaseReturnValue dependency building on Linux
  • SR-5986 swift test induces an error "undefined reference to 'objc_retainAutoreleasedReturnValue'" when calls CFStringConvertEncodingToIANACharSetName(_: ) on Linux

Issue Description:

As per the comment in https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/Base.subproj/CFRuntime.c#L1702

For CF functions with 'Get' semantics, the compiler currently assumes that
the result is autoreleased and must be retained. It does so on all platforms
by emitting a call to objc_retainAutoreleasedReturnValue. On Darwin, this
is implemented by the ObjC runtime. On Linux, there is no runtime, and
therefore we have to stub it out here ourselves. The compiler will eventually
call swift_release to balance the retain below.
This is a workaround until the compiler no longer emits this callout on Linux.

The stub just calls swift_retain() but the compiler should be fixed properly so that this workaround can be removed.

@belkadan
Copy link
Contributor

cc @jckarter

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
al45tair added a commit to al45tair/swift that referenced this issue Mar 1, 2024
When ObjC interop is not enabled, we shouldn't be emitting calls to
`objc_retainAutoreleasedReturnValue()` as that function might not exist.

Call `swift_retain()` instead, to balance the `swift_release()` of the
returned value.

Fixes apple#47846, apple#45359.

rdar://23335318
al45tair added a commit to al45tair/swift that referenced this issue Mar 1, 2024
When ObjC interop is not enabled, we shouldn't be emitting calls to
`objc_retainAutoreleasedReturnValue()` as that function might not exist.

Call `swift_retain()` instead, to balance the `swift_release()` of the
returned value.

Fixes apple#47846, apple#45359.

rdar://23335318
@AnthonyLatsis AnthonyLatsis added objective-c interop Feature: Interoperability with Objective-C swift 5.10 IRGen LLVM IR generation unexpected behavior Bug: Unexpected behavior or incorrect output labels Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself IRGen LLVM IR generation Linux Platform: Linux objective-c interop Feature: Interoperability with Objective-C swift 5.10 unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants