Skip to content

Remove dependency on libatomic on Linux #29581

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 8 commits into from
Feb 12, 2020

Conversation

drexin
Copy link
Contributor

@drexin drexin commented Feb 1, 2020

Due to some unfortunate interplay between clang and libstdc++, clang was
not able to correctly identify to alignment of PoolRange and
SideTableRefCountBits, causing it to emit library calls instead of
inlining atomic operations. This was fixed by adding the appropriate
alignment to those types. In addition to that the march for the Linux
target was set to 'core2', which is the earliest architecture to support
cx16, which is necessary for the atomic operations on PoolRange.

Due to some unfortunate interplay between clang and libstdc++, clang was
not able to correctly identify to alignment of PoolRange and
SideTableRefCountBits, causing it to emit library calls instead of
inlining atomic operations. This was fixed by adding the appropriate
alignment to those types. In addition to that the march for the Linux
target was set to 'core2', which is the earliest architecture to support
cx16, which is necessary for the atomic operations on PoolRange.
@drexin
Copy link
Contributor Author

drexin commented Feb 1, 2020

preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

1 similar comment
@drexin
Copy link
Contributor Author

drexin commented Feb 1, 2020

preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

@compnerd
Copy link
Member

compnerd commented Feb 1, 2020

Wow! Nice catch on that. This is actually going to simplify a few things.

@compnerd
Copy link
Member

compnerd commented Feb 1, 2020

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 1, 2020

Build failed
Swift Test Linux Platform
Git Sha - d913eef

@drexin
Copy link
Contributor Author

drexin commented Feb 2, 2020

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 2, 2020

Build failed
Swift Test Linux Platform
Git Sha - d913eef

@drexin
Copy link
Contributor Author

drexin commented Feb 2, 2020

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 2, 2020

Build failed
Swift Test Linux Platform
Git Sha - d913eef

@drexin
Copy link
Contributor Author

drexin commented Feb 2, 2020

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 2, 2020

Build failed
Swift Test Linux Platform
Git Sha - d913eef

@drexin
Copy link
Contributor Author

drexin commented Feb 2, 2020

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 2, 2020

Build failed
Swift Test Linux Platform
Git Sha - 6db05fd

@drexin
Copy link
Contributor Author

drexin commented Feb 2, 2020

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 2, 2020

Build failed
Swift Test Linux Platform
Git Sha - 34a331e

@compnerd
Copy link
Member

compnerd commented Feb 3, 2020

I don't think that -march matters at link time.

@drexin
Copy link
Contributor Author

drexin commented Feb 3, 2020

Yeah, I don't know why it's failing in the first place. It emits __sync call in the LongRefcountingTest. That's why I tried adding the march there as well. I have so far been unable to reproduce this locally.

@drexin
Copy link
Contributor Author

drexin commented Feb 3, 2020

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2020

Build failed
Swift Test Linux Platform
Git Sha - feb7bb1

@drexin
Copy link
Contributor Author

drexin commented Feb 3, 2020

Ok, just reproduced the __sync issue in a 16.04 VM. Working on a fix.

@drexin
Copy link
Contributor Author

drexin commented Feb 3, 2020

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2020

Build failed
Swift Test Linux Platform
Git Sha - 525f408

@drexin
Copy link
Contributor Author

drexin commented Feb 4, 2020

@swift-ci please smoke test

@drexin
Copy link
Contributor Author

drexin commented Feb 4, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Feb 4, 2020

Build failed
Swift Test OS X Platform
Git Sha - d913eef

@drexin
Copy link
Contributor Author

drexin commented Feb 4, 2020

@compnerd Figured it out. The problem was that I used APPEND instead of APPEND_STRING in the cmake file to append the compiler flag.

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

LGTM with the minor nit on the CMake usage

set_property(TARGET "${test_dirname}" APPEND PROPERTY LINK_LIBRARIES
"atomic")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY COMPILE_FLAGS
Copy link
Member

Choose a reason for hiding this comment

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

I think that this is better written as:

target_compile_options(${test_dirname} PRIVATE
  -march=core2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No strong opinion, but it's done with set_property in the rest of the file, so maybe it's worth keeping it consistent?

Copy link
Member

Choose a reason for hiding this comment

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

The target_* form is more concise, avoids string manipulations, and should reduce memory overheads for CMake having to translate between representations. It also will make it easier to split apart the host and target builds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, changed it.

@drexin
Copy link
Contributor Author

drexin commented Feb 5, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Feb 5, 2020

Build failed
Swift Test OS X Platform
Git Sha - 62a5ebb

@swift-ci
Copy link
Contributor

swift-ci commented Feb 5, 2020

Build failed
Swift Test Linux Platform
Git Sha - 62a5ebb

@compnerd
Copy link
Member

@swift-ci please test

@compnerd compnerd merged commit 97df90f into swiftlang:master Feb 12, 2020
finagolfin added a commit to finagolfin/swift that referenced this pull request Apr 8, 2020
… and Haiku

Follow suit from linux, swiftlang#29581, tested on Android.
finagolfin added a commit to finagolfin/swift that referenced this pull request Nov 16, 2020
…and Haiku

Follow suit from linux, swiftlang#29581, tested on Android.
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.

3 participants