-
Notifications
You must be signed in to change notification settings - Fork 52
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
import Atomics won't compile in Playgrounds #55
Comments
Ok I went ahead and implemented the looping construct and now my fork passes all the tests and can run in playgrounds. I need to run the tests on both the modified and unmodified code to try to quantify how much of a performance hit this is. It seemed noticeably slower, but that could be just that I was watching it. As a side note, it seems like a pretty big oversight that the std lib doesn't implement these two methods in Unmanaged so that none of this is necessary in a library like swift-atomics. It also seems bad that I have to use a fork to demonstrate the use of swift-atomics in a playground. Any thoughts or advice for other solutions are welcome. |
Looping over swift_retain/release technically doesn't break correctness, but if the loop survives into the generated binary, then the resulting code will have unacceptably bad performance. So this isn't a viable workaround, unless the relevant LLVM optimization pass replaces the loop with a direct call to swift_retain_n/swift_release_n. |
I had sort of figured that out. So I have a branch that implements it this way which I use for teaching about atomics using playgrounds and use the main branch version for actual compiled code. |
Hm. This package needs these two functions only to work around swiftlang/swift#56105. Fixing that bug would allow the package to remove these, although only if it is compiled using a toolchain that includes the fix. (The package would still need the headers, though, so this probably wouldn't help with #62. To fix that, we likely need to wait until we have native atomics in the Swift toolchain.) |
Planning for getting rid of the C module has started in #74. However, this won't land until some Swift compiler & stdlib work is done (and is shipping), so the current workaround will need to remain in place for a while. |
As a stopgap workaround, #95 attempts to switch to using dlsym to access these on Darwin platforms, hopefully bypassing this issue. |
I verified that #97 will resolve the "symbol not found" issues for However, I'm still seeing subsequent missing symbol issues about |
I am trying to import swift-atomics into a Playground. This fails to compile the shims because Playgrounds don't (and as far as I can tell, won't) link
libswiftCore.dylib
. This is similar to Issue #8 in that its dying in the same place, unfortunately the work arounds don't work here. There is mention of using Unmanaged to do this in: SR-13708.Given that the only use of these two functions is in:
I've been giving thought to trying to replace
_sa_retain_n(void *object, uint32_t n)
andvoid _sa_release_n(void *object, uint32_t n)
with Swift versions that do what the comment in SR13708 suggests, but wanted to check and 1) see if that is actually advisable and 2) ask why the comment:"Looping over Unmanaged.retain/release doesn't seem like a viable option, although I'm sure that would work too."
indicates both that it "doesn't seem viable" and "would work too" .
Information
Target: arm64-apple-macosx12.0
Checklist
main
branch of this package.Steps to Reproduce
git clone https://github.com/CSCIX65G/AtomicsExample/tree/main/Sources/AtomicsExample, try to run the Playground
Expected behavior
The playground should compile and run.
Actual behavior
The playground fails to compile
The text was updated successfully, but these errors were encountered: