-
Notifications
You must be signed in to change notification settings - Fork 257
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] surface_control.h
and *font*.h
contains C++ constructs
#1920
Comments
Hmm. I'd like to fix this in r26 but that particular component has gotten tricky to update now that rv64 is in the development branch. It isn't a regression in r26, so this may slip to r27. I don't think that would be a problem for your use case because you could just update those projects from the canary anyway. Really you probably don't even need an NDK and could just pull the sysroot from ci.android.com. |
(and i guess this is another vote for "we really should get around to setting up the 'check that every header can be included in .c files' test" that comes up every year or so...) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Note that the same issue appears in the thermal headers as well:
Not sure if you're aware and/or adding a CI process to check that all headers are C-compliant, so mentioning it here. |
We tried, but the build systems we have to work made it quite difficult. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Looks like the font headers have been fixed, but On that note I'm very much inclined to follow @DanAlbert's advice and migrate the @appujee what is your plan for the rust label? While this issue primarily impacts our ecosystem, the effect is global (headers aren't usable in plain C) and not limited to Rust. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@enh-google sure, I understand why this is the case, but wanted to report these issues as a whole and have a team of Googlers pick this up, rather than me painstakingly going through every API and requesting clarification everywhere, effectively picking up that job. Which I'm already doing to a significant extent, by using my free time to map NDK APIs into Rust, parsing the documentation, and finding various inconsistencies or general lack of clear and consistent documentation. Sounds like I'll either have to leave it be, or file many separate issues on https://issuetracker.google.com/issues/new?component=192763&template=1032811 (assuming the NDK component is correct). Notice that I'm trying to be helpful by pointing out lacking or inconsistent documentation, rather than figuring it out myself from the codebase and moving on with my day (with the added benefit of the semantics being locked in place). Asking a contributor to also take over part of someones job of triaging via |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
The NDK APIs are supposed to be C-compatible. This one accidentally included a default argument, which is a C++ feature. That's being fixed, so this needs to pass the argument explicitly. Bug: android/ndk#1920 Test: treehugger Change-Id: I8e47a5cba8d485993c65e1b59e42ac5d7bd8d276
The NDK APIs are supposed to be C-compatible. This one accidentally included a default argument, which is a C++ feature. That's being fixed, so this needs to pass the argument explicitly. Bug: android/ndk#1920 Test: treehugger Change-Id: Ia79da4b4593dfd46302cb44298e906bb8e6c4d86
This is far from the only C incompatibility in this file, but it's the one that's most likely to not break builds, so I'm starting small. This is a source compat break, but not an ABI break. Bug: android/ndk#1920 Test: treehugger Change-Id: I5a32762fa61b1399fb354397479603858184ea05
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Bug: android/ndk#1920 Test: treehugger Change-Id: Ib8296e7b9c86809d16fbde0787d016095a189387
This header currently cannot be processed by a C compiler as it contains C++ patterns, which prevent us from generating bindings in the [Rust `ndk-sys` crate]. This was originally reported at https://github.com/ android/ndk/issues/1920. The compatibility changes are as follows: - Remove `= -1` default-argument; - Suffix `ADataSpace` usage with `enum` tag. A word of warning: other bindings take this as an `int`, which is less descriptive. What is correct for these APIs, and can we unify it?; - Replace `&` references with `*` pointers, and marked them as `_Nonnull`. Confusingly lots of headers and functions here are lacking `_Nonnull`/`_Nullable` annotations, making our mapping "job" in Rust pretty terrible. Some improvements to the bindings: - Make HDR metadata struct pointers `const` as they are only used for reading; - Remove the duplicate `Available since API level 34.` on `ASurfaceTransaction_setExtendedRangeBrightness()` that was introduced in the wrong place in I62df5447bc547be52f6b00fedf1006c8d66a5faf, and later added again _after_ the parameter list in I8bebb31f0bd38e36139026a539030e5b61b75b4c. Note that the other notions _above_ the parameter list (also added by the first linked change) are kept; - Fix a typo reference to `SurfaceControlStats` as reported in [comment 14]. [Rust `ndk-sys` crate]: https://github.com/rust-mobile/ndk [comment 14]: https://issuetracker.google.com/issues/300602767#comment14 Change-Id: I9186df4abe7cb8246b2d10c1b41ab13664bad3ec Signed-off-by: Marijn Suijten <[email protected]>
This header currently cannot be processed by a C compiler as it contains C++ patterns, which prevent us from generating bindings in the [Rust `ndk-sys` crate]. This was originally reported at https://github.com/ android/ndk/issues/1920. The compatibility changes are as follows: - Remove `= -1` default-argument; - Suffix `ADataSpace` usage with `enum` tag. A word of warning: other bindings take this as an `int`, which is less descriptive. What is correct for these APIs, and can we unify it?; - Replace `&` references with `*` pointers, and marked them as `_Nonnull`. Confusingly lots of headers and functions here are lacking `_Nonnull`/`_Nullable` annotations, making our mapping "job" in Rust pretty terrible. Some improvements to the bindings: - Make HDR metadata struct pointers `const` as they are only used for reading; - Remove the duplicate `Available since API level 34.` on `ASurfaceTransaction_setExtendedRangeBrightness()` that was introduced in the wrong place in I62df5447bc547be52f6b00fedf1006c8d66a5faf, and later added again _after_ the parameter list in I8bebb31f0bd38e36139026a539030e5b61b75b4c. Note that the other notions _above_ the parameter list (also added by the first linked change) are kept; - Fix a typo reference to `SurfaceControlStats` as reported in [comment 14]. [Rust `ndk-sys` crate]: https://github.com/rust-mobile/ndk [comment 14]: https://issuetracker.google.com/issues/300602767#comment14 Change-Id: I9186df4abe7cb8246b2d10c1b41ab13664bad3ec Signed-off-by: Marijn Suijten <[email protected]>
This header currently cannot be processed by a C compiler as it contains C++ patterns, which prevent us from generating bindings in the [Rust `ndk-sys` crate]. This was originally reported at https://github.com/ android/ndk/issues/1920. The compatibility changes are as follows: - Remove `= -1` default-argument; - Suffix `ADataSpace` usage with `enum` tag. A word of warning: other bindings take this as an `int`, which is less descriptive. What is correct for these APIs, and can we unify it?; - Replace `&` references with `*` pointers, and marked them as `_Nonnull`. Confusingly lots of headers and functions here are lacking `_Nonnull`/`_Nullable` annotations, making our mapping "job" in Rust pretty terrible. Some improvements to the bindings: - Make HDR metadata struct pointers `const` as they are only used for reading; - Remove the duplicate `Available since API level 34.` on `ASurfaceTransaction_setExtendedRangeBrightness()` that was introduced in the wrong place in I62df5447bc547be52f6b00fedf1006c8d66a5faf, and later added again _after_ the parameter list in I8bebb31f0bd38e36139026a539030e5b61b75b4c. Note that the other notions _above_ the parameter list (also added by the first linked change) are kept; - Fix a typo reference to `SurfaceControlStats` as reported in [comment 14]. [Rust `ndk-sys` crate]: https://github.com/rust-mobile/ndk [comment 14]: https://issuetracker.google.com/issues/300602767#comment14 Change-Id: I9186df4abe7cb8246b2d10c1b41ab13664bad3ec Signed-off-by: Marijn Suijten <[email protected]>
Still a work in progress. It's going to take a while still. Moving to r28. |
Most of the issues have been cleaned up. The reference arguments are definitely still there though. I'd been saving those for last because it'd be a safety regression to do that without also adding |
Understood; I've been spread equally thin (thinner than individual atoms, how is that possible) with no time to set up an AOSP tree to help you out. Either way thank you for pushing parts of my commits forward! I do hope that I can one day land the |
The problems aren't thing a non-googler could help with anyway, unfortunately :( Making the change isn't the hard part, it's getting it past all the presubmit crap we have. And the post-submit stuff, for that matter. |
Actually we are way closer on this than I'd expected. At least for the set of headers you mentioned, it really is just the C++ references left in https://r.android.com/q/topic:%22surface_control-c-compat%22 fixes the rest of the originally filed problems. Getting that merged will probably take a few days since downstream branches always cause headaches. |
https://r.android.com/3205058 fixes We'll probably regress on this again. I'll take another stab at enforcing C compatibility at build time, but the last few times I tried it proved very difficult. I might be able to do something stupid but good enough instead. |
https://ci.android.com/builds/branches/aosp-master-ndk/grid?head=12185972&tail=12185972&legacy=1 and newer should be fixed. If it's not too much work for you to test the canary, want to do that and let me know if I missed anything bindgen needs? |
Thanks @DanAlbert, that's awesome! Works flawlessly as demonstrated at rust-mobile/ndk@6175ea0. Forgot to mention but your fix for |
Great, thanks for confirming. I'll keep working on adding some validation to make sure we don't regress. Adding it in the right place to catch it early is the hard part, but if that doesn't pan out I suppose I can add something to the NDK tests themselves. If we catch it then, the mistake has already been made in the OS so it'll delay a release (potentially for a long time, seeing how long it took us to fix this) as opposed to preventing the broken change from landing in the first place, but that's better than shipping it broken.
File doc bugs anywhere the docs aren't clear and I'll see what I can do. The newer APIs should have somewhat okay docs (they go through fairly thorough review, but a lot of the wtfs aren't apparent until they start getting used in the wild), and I've been trying to improve some of the older docs. I expect there are several months of full time work fixing all the old stuff though, so some direction toward the worst offenders would help. |
The doc bug I've filed thus far is probably too generic to gain any traction (likewise reporting general formatting and spelling mistakes is a dead end beyond contributing them myself, but that's a full-time job: https://issuetracker.google.com/issues/300602767). Specifically, and perhaps this should be driven generically, it'd be nice to know when objects are internally synchronized inside Android, hence making them thread-safe. Specifically, in Rust this applies to the whole object, not just a few functions (though there are ways to represent such interactions too).
For callbacks the main issue I've been debugging a while back (and am a bit fuzzy on the details) is race conditions regarding when a callback is registered, replaced, removed, and the entire object being removed/destroyed, versus the callback being triggered. Unfortunately I've only vaguely recollected my thoughts in rust-mobile/ndk#464, and will need to run some experiments again. |
The NDK APIs are supposed to be C-compatible. This one accidentally included a default argument, which is a C++ feature. That's being fixed, so this needs to pass the argument explicitly. Bug: android/ndk#1920 Test: treehugger Change-Id: Ia79da4b4593dfd46302cb44298e906bb8e6c4d86
Description
I maintain the Rust
ndk
andndk-sys
crates, and they rely onbindgen
to parse C headers.Unfortunately, while attempting to generate these for the font headers and later
surface_control.h
Rust'sbindgen
utility complains that the headers are not valid C (these things only work in C++):Missing
struct
andenum
tagsThese are easy enough (but ugly) to work around with
typedef
s:Language features we cannot work around
Default function arguments
~/Android/Sdk/ndk/26.0.10404224/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/surface_control.h:343:57
:C++ references instead of pointers
/home/marijn/Android/Sdk/ndk/26.0.10404224/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/surface_control.h:379:83
(and at more places):Affected versions
r25, r26
Canary version
No response
Host OS
Linux
Host OS version
Arch Linux
Affected ABIs
armeabi-v7a, arm64-v8a, x86, x86_64
Build system
Other (specify below)
Other build system
bindgen
on headers onlyminSdkVersion
Irrelevant for header codegen
Device API level
No response
The text was updated successfully, but these errors were encountered: