-
Notifications
You must be signed in to change notification settings - Fork 258
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
[BUG] Compilation error using _Atomic type in C++ (r21 regression) #1178
Comments
Note that you code does not compile on NDK r20:
That's a simple copy/paste typo, line 4 should be
|
Ah yes, thank you. I’ve fixed the code above (I had initially been using a void pointer...). |
The easy fix is to use For me, it's enough to add to build.gradle:
|
Yes, including However I’d rather not have to change the code or hardcode llvm paths in the build script, so it would be great to see this fixed in a future NDK release. 👍 |
I would strongly recommend against adding the bits directory to your include path. This might work to fix stdatomic.h for this release, but it could quite easily give you the wrong header in other cases. |
@DanAlbert, you are right. I believe that the basic idea of using <atomic> inside <stdatomic.h> is flawed. People who include the latter expect it to work C11-style, not as a wrapper around STL. |
We'll be fixing the regression in r21b. Thanks for being clear up front that this was a regression from r20. That makes triage easy :)
tl;dr wrapping C++ atomics were designed to be compatible with C atomics, but the standard specified behavior is currently broken. You can't have The expectation is that http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0943r4.html will be the fix for this. This proposal describes the behavior we've had in AOSP for the past ~6 years. Using Note that the behavior you're describing has precedent in C++ already. |
That’s great news @DanAlbert! Can we expect r21b to also fix #1177? |
If I am not missing something, I see something exactly opposite:
passes compilation. |
Other way around. #include <stdatomic.h>
#include <atomic>
|
@triplef Yep. Sorry, been bad at triage this week. Fixed that now. |
This fails with r20, but passes with r21. |
Something worth noting is that libdispatch has its own macro wrappers around |
Sorry, forgot I hadn't replied to this. Yes, r21 has what was intended to be a fix for this problem. Unfortunately the fix broke other things, so apparently we didn't fix it quite right :) |
Spoke with hboehm about this and #1177, and I think our best bet is to revert r21 to match the r20 behavior for the time being. This means that the problems I mentioned above (can't have stdatomic.h and atomic in the same TU unless you're careful about ordering) will return, but they've been present in the NDK for several years and afaik no one noticed, so there's no rush to fix them. Keeping r21 with that behavior saves us from making a change now that we would potentially need to break compatibility with as the proposal continues to evolve. If we have to break it, I'd rather break it once than twice. Fair warning though: the current proposal and its general direction is toward not supporting the |
@pirama-arumuga-nainar looks like me reverting https://android-review.googlesource.com/c/platform/bionic/+/1086558 in the NDK sysroot is not going to cut it since that header is also copied into the Clang builtin headers (lib64/clang/...). We'll need to also revert that in r21's clang branch. How does the toolchain build get that header? |
It probably gets copied during build.py. We can revert that change and
regenerate prebuilts.
…On Wed, Feb 19, 2020, 5:15 PM Dan Albert ***@***.***> wrote:
@pirama-arumuga-nainar <https://github.com/pirama-arumuga-nainar> looks
like me reverting
https://android-review.googlesource.com/c/platform/bionic/+/1086558 in
the NDK sysroot is not going to cut it since that header is also copied
into the Clang builtin headers (lib64/clang/...). We'll need to also revert
that in r21's clang branch. How does the toolchain build get that header?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1178?email_source=notifications&email_token=AEZPQ6EMNQTHK54LPFKK2PTRDXKTXA5CNFSM4KMRMC32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMKLKVA#issuecomment-588559700>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEZPQ6GFU3WDAKNH5O4Q26DRDXKTXANCNFSM4KMRMC3Q>
.
|
We're going to have to create a compiler release branch for r21 in order to make progress here. |
Also true for #1184 (sorry, forgot to assign the milestone on a few bugs). |
This reverts commit 32b5f4e to make the real revert apply cleanly. Bug: android/ndk#1178 Test: None
…_include(<atomic>)" This reverts commit 76e2b15. Bug: android/ndk#1178 Test: None
This reverts commit 32b5f4e to make the real revert apply cleanly. Bug: android/ndk#1178 Test: None
…_include(<atomic>)" This reverts commit 76e2b15. Bug: android/ndk#1178 Test: None
Fix is in build 6352462 on https://ci.android.com/builds/branches/aosp-ndk-release-r21/grid? |
This reverts commit e8b1d13. Bug: android/ndk#1178 Test: None
Test: ndk/checkbuild.py && ndk/run_tests.py Bug: android/ndk#1178 Change-Id: I5427e4f1e8342f18f4dce943b4310860b98fdac0 (cherry picked from commit ccc4280)
Test: ndk/checkbuild.py && ndk/run_tests.py Bug: android/ndk#1178 Change-Id: I5427e4f1e8342f18f4dce943b4310860b98fdac0 (cherry picked from commit ccc4280)
Test: ndk/checkbuild.py && ndk/run_tests.py Bug: android/ndk#1178 Change-Id: I5427e4f1e8342f18f4dce943b4310860b98fdac0 (cherry picked from commit ccc4280)
Description
Using the C-style
_Atomic
type in a C++ file fails to compile with NDK r21, but compiles fine with r20 and on other platforms.test.cpp:
Error:
I think the issue is caused by the same change in bionic as #1177.
This e.g. causes the swift-corelibs-libdispatch project to fail to compile with r21 due to its use of atomic types in atomic.h, which is used in C++.
Environment Details
The text was updated successfully, but these errors were encountered: