swiftlang / swiftlang/swift-corelibs-libdispatch
[SR-15528] Can't convert DispatchQueue to dispatch_queue_t on Linux
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 2.6k
- Forks
- 496
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
| 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>')
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer files run-me.c and run-me.swift and compile it using the shown swiftc command on Linux, then compare the behavior with macOS. Trace the DispatchQueue-to-dispatch_queue_t interop in libdispatch and the Standard Library; done means the Linux example compiles and passes the queue to sayHiOnQueue as it does on macOS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, swift
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100