Skip to content

Link the concurrency runtime against libatomic on Linux #38501

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

Merged
merged 1 commit into from
Jul 20, 2021

Conversation

rjmccall
Copy link
Contributor

We mostly get away without this because we're fairly disciplined about using constant memory orderings, and apparently that's usually good enough to get inline accesses and avoid needing to link atomic. However, we have a few places with the task status atomic that use a non-constant load ordering with load and compare_exchange_weak, and my recent change to make that atomic a double-word was apparently sufficient on some (but not all) Linux distributions to get the compiler to call the runtime function. Regardless, we shouldn't be playing around in the margins here: Linux requires us to link libatomic, so we should.

We mostly get away without this because we're fairly disciplined
about using constant memory orderings, and apparently that's
usually good enough to get inline accesses and avoid needing to
link atomic.  However, we have a few places with the task status
atomic that use a non-constant load ordering with load and
compare_exchange_weak, and my recent change to make that atomic
a double-word was apparently sufficient on some (but not all)
Linux distributions to get the compiler to call the runtime
function.  Regardless, we shouldn't be playing around in the
margins here: Linux requires us to link libatomic, so we should.
@rjmccall rjmccall requested a review from compnerd July 20, 2021 06:07
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

# Frustratingly, in many cases this isn't necessary because the
# sequence is inlined, but we have some code that's just subtle
# enough to turn into runtime calls.
if(SWIFT_HOST_VARIANT STREQUAL "Linux")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjmccall @buttaface is it possible to make this change in different PR? I would like to merge this change to unblock nightly toolchain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no problem. I can always add it later if you need this patch right away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ktoso
Copy link
Contributor

ktoso commented Jul 20, 2021

Huh, thanks for the explanation in the opening comment, good to know!

@shahmishal
Copy link
Member

We will need this change on release/5.5 branch too, it's also failing there.
https://ci.swift.org/view/Swift%205.5/job/oss-swift-5.5-package-linux-ubuntu-18_04/248/console

@shahmishal shahmishal merged commit c77d0b1 into swiftlang:main Jul 20, 2021
@rjmccall rjmccall deleted the link-libatomic-concurrency branch July 20, 2021 18:25
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.

4 participants