Skip to content

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

Closed
@spevans

Description

@spevans
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    IRGenLLVM IR generationLinuxPlatform: LinuxbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfobjective-c interopFeature: Interoperability with Objective-Cswift 5.10unexpected behaviorBug: Unexpected behavior or incorrect output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions