apple/swift-corelibs-libdispatch

[SR-15528] Can't convert DispatchQueue to dispatch_queue_t on Linux

swift-ci opened this issue · 0 comments

Previous ID SR-15528
Radar rdar://85783481
Original Reporter thomas (JIRA User)
Type Bug
Environment

MacOS

12.0.1 (21A559)
Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)
Target: x86_64-apple-macosx12.0

Linux:

Linux primary 5.4.0-90-generic #​101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal

Swift version 5.5.1 (swift-5.5.1-RELEASE)
Target: x86_64-unknown-linux-gnu
Additional Detail from JIRA
Votes 0
Component/s libdispatch, Standard Library
Labels Bug
Assignee None
Priority Medium

md5: a69653a3763608dc24b58bb1e336880c

Issue Description:

When calling a C API from Swift that takes a dispatch queue as argument, on Linux the type conversion fails.

Example. A C function that defines a function that takes a dispatch_queue_t as argument.

Code (run-me.c)
#include <dispatch/dispatch.h>
void sayHiOnQueue(dispatch_queue_t queue);

Code (run-me.swift):
import Foundation

let queue = DispatchQueue(label: "test")
sayHiOnQueue(queue)
Compiling via:
swiftc -import-objc-header run-me.h -emit-object -module-name runme run-me.swift

On macOS this works as expected. On Linux this fails with:

run-me.swift:4:14: error: cannot convert value of type 'DispatchQueue' to expected argument type 'dispatch_queue_t?' (aka 'Optional<OpaquePointer>')