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

always @preconcurrency import Glibc/Musl/Bionic/Android/WASILibc #5170

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

weissi
Copy link
Contributor

@weissi weissi commented Feb 15, 2025

Related issues:

I've got a working program

@preconcurrency import Glibc
import Foundation

await Task {
  _ = fputs("hello\n", stderr)
}.value

but alas, if swift-format reformats it, it makes it (note that the two imports are reordered)

import Foundation
@preconcurrency import Glibc

await Task {
  _ = fputs("hello\n", stderr)
}.value

which unfortunately doesn't compile

$ swift format --in-place test.swift && swiftc -swift-version 6 test.swift && echo OK
test.swift:5:24: error: reference to var 'stderr' is not concurrency-safe because it involves shared mutable state
3 | 
4 | await Task {
5 |   _ = fputs("hello\n", stderr)
  |                        `- error: reference to var 'stderr' is not concurrency-safe because it involves shared mutable state
6 | }.value
7 | 

SwiftGlibc.stderr:1:12: note: var declared here
1 | public var stderr: UnsafeMutablePointer<FILE>!
  |            `- note: var declared here

the problem is that Foundation imports Glibc/Musl but doesn't mark them @preconcurrency.

@weissi weissi changed the title always @preconcurrency import Glibc/Musl always @preconcurrency import Glibc/Musl/Bionic/Android/WASILibc Feb 15, 2025
@weissi
Copy link
Contributor Author

weissi commented Feb 15, 2025

/ci test

@parkera
Copy link
Contributor

parkera commented Feb 19, 2025

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants