Skip to content

Foundation expects undefined symbol: objc_retainAutoreleasedReturnValue #982

Closed
@MaxDesiatov

Description

@MaxDesiatov

Currently, when linking with libFoundation.a compiled to WASI you get these errors:

wasm-ld: error: /usr/lib/swift_static/wasi/libFoundation.a(NSCalendar.swift.obj): 
undefined symbol: objc_retainAutoreleasedReturnValue
wasm-ld: error: /usr/lib/swift_static/wasi/libFoundation.a(DateFormatter.swift.obj): undefined symbol: objc_retainAutoreleasedReturnValue

I've been able to track it down to this line in DateFormatter.swift:

return CFDateFormatterGetFormat(_cfObject)._swiftObject

and this line in NSCalendar.swift:

return Identifier(rawValue: CFCalendarGetIdentifier(_cfObject)._swiftObject)

Looks like objc_retainAutoreleasedReturnValue intrinsic is emmitted in certain cases when bridging from CoreFoundation objects to Swift values (strings in this case). I haven't been able to find where this intrinsic is available to link it to avoid linker errors, and I'm also not sure how to stop the compiler from emitting it. I've checked the upstream Linux SDK (targeting Linux, no WebAssembly and cross-compilation involved) and it also has references to this intrinsic. If it actually works for Swift on Linux, I'm not even sure if turning it off for WebAssembly is a good idea.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions