You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clang has a notion of “returns twice” functions, used for things like fork/setjmp and other icky things. The compiler doesn’t reason about these function and the control flow that they entail, so DI and other properties are not correct.
When importing one of them, we should slap an ‘unavailable’ attribute on them, so swift programmers don’t use them.
The text was updated successfully, but these errors were encountered:
// swift -frontend -c -primary-file 2394.swift -sdk `xcrun -sdk macosx10.12 --show-sdk-path` -module-name main -o 2394.oimportDarwinvarx: Int32 = 0setjmp(&x)
I believe Clang contains some code that attributes functions like fork and setjmp with __attribute__ ((returns_twice)). By placing a breakpoint within a ClangImporter method, I can see that setjmp has that attribute set. So, as far as I understand, all I have to do is find a good spot in lib/ClangImporter to check for that attribute, then mark the symbol as unavailable if it's set. At that point, I think I can remove the explicit exclusion of fork and vfork, since they'll be unavailable anyway.
I wonder, though: this is a source breaking change, isn't it? The Swift code above used to compile, but as of this change, it will no longer compile. Is that acceptable, @belkadan?
I think #6513 resolves this issue, but this seems like an invasive, source-breaking change. Particularly disappointing for me is the fact that the Swift test suite runs on Android in part thanks to fork. Marking it unavailable will break those tests. I'll have to re-implement that portion in order to get them running again.