Repository navigation
fix(linux): handle ATK C linkage with newer GLib headers - #193942
richyo-codes wants to merge 4 commits into
Conversation
Centralize the ATK linkage workaround and include C++ type traits outside the C linkage block. Keep GTK4 target selection and accessibility behavior out of this compatibility fix.
Let GLib include its own C++ support headers before entering the external C linkage block required by older ATK version declarations. Avoid depending explicitly on the standard headers GLib happens to use internally. Validated the ATK header and C linkage with Bullseye and Trixie sysroots.
Document the upstream 2.59.0 fix and older-version distribution backports, the reason GLib must load outside C linkage, and the condition for removing the wrapper. A header linkage probe fails without the wrapper for the local Bullseye ATK 2.38 and Trixie ATK 2.55 headers. Fixed host ATK 2.60.7 headers work directly; the GLib-first wrapper works in all three environments.
There was a problem hiding this comment.
Code Review
This pull request introduces a new compatibility header, fl_atk_compat.h, to centralize and handle ATK header C-linkage compatibility issues, replacing inline workarounds and direct <atk/atk.h> includes across several Linux platform files. The review feedback identifies multiple violations of the Google C++ Style Guide regarding include ordering, specifically recommending that primary headers be placed first and project headers be grouped and sorted alphabetically.
| extern "C" { | ||
| #include <atk/atk.h> | ||
| } | ||
| #include "flutter/shell/platform/linux/fl_atk_compat.h" |
There was a problem hiding this comment.
According to the Google C++ Style Guide, the primary header (fl_accessibility_handler.h) should be the very first include in a test file, and project headers should be grouped and sorted alphabetically.\n\nPlease reorder the includes as follows:\ncpp\n#include "flutter/shell/platform/linux/fl_accessibility_handler.h"\n\n#include "flutter/shell/platform/linux/fl_atk_compat.h"\n#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"\n
References
- The Google C++ Style Guide requires the primary header to be the first include, followed by other headers grouped and sorted alphabetically. (link)
| extern "C" { | ||
| #include <atk/atk.h> | ||
| } | ||
| #include "flutter/shell/platform/linux/fl_atk_compat.h" |
There was a problem hiding this comment.
According to the Google C++ Style Guide, the primary header (fl_view_accessible.h) should be the very first include in the source file, and other project headers should be grouped and sorted alphabetically.\n\nPlease reorder the includes as follows:\ncpp\n#include "flutter/shell/platform/linux/fl_view_accessible.h"\n\n#include "flutter/shell/platform/linux/fl_accessible_node.h"\n#include "flutter/shell/platform/linux/fl_accessible_text_field.h"\n#include "flutter/shell/platform/linux/fl_atk_compat.h"\n
References
- The Google C++ Style Guide requires the primary header to be the first include, followed by other headers grouped and sorted alphabetically. (link)
|
|
||
| #include <atk/atk.h> | ||
| #include <gio/gio.h> | ||
| #include "flutter/shell/platform/linux/fl_atk_compat.h" |
There was a problem hiding this comment.
According to the Google C++ Style Guide, project headers should be grouped together and sorted alphabetically.\n\nPlease reorder the project headers as follows:\ncpp\n#include "flutter/shell/platform/embedder/embedder.h"\n#include "flutter/shell/platform/linux/fl_atk_compat.h"\n#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"\n
References
- The Google C++ Style Guide requires project headers to be grouped together and sorted alphabetically. (link)
| #endif | ||
|
|
||
| #include <atk/atk.h> | ||
| #include "flutter/shell/platform/linux/fl_atk_compat.h" |
There was a problem hiding this comment.
According to the Google C++ Style Guide, project headers should be grouped together and sorted alphabetically.\n\nPlease reorder the project headers as follows:\ncpp\n#include "flutter/shell/platform/embedder/embedder.h"\n#include "flutter/shell/platform/linux/fl_atk_compat.h"\n#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"\n
References
- The Google C++ Style Guide requires project headers to be grouped together and sorted alphabetically. (link)
Summary
Fix a Linux engine compilation issue involving ATK C linkage and newer GLib headers while preserving compatibility with the existing Debian Bullseye sysroot.
Older ATK headers do not consistently declare the
atk_get_*versionfunctions with C linkage. The existing workaround wraps<atk/atk.h>inextern "C", but newer GLib headers can include C++ support headers. Including those headers inside a C linkage block can cause C++ compilation errors.Changes
fl_atk_compat.hcompatibility header that includes<glib.h>before wrapping<atk/atk.h>inextern "C".BUILD.gn.The underlying ATK header issue was fixed upstream in [at-spi2-core MR !219](https://gitlab.gnome.org/GNOME/at-spi2-core/-/merge_requests/219). See also [Debian bug #1145539](https://bugs.debian.org/1145539).
Compatibility and scope
This addresses one compilation issue encountered when preparing Linux engine builds for newer Debian Trixie sysroots, while maintaining compatibility with Bullseye.
Contributes to #194923, which tracks broader Bullseye/Trixie sysroot compatibility.
This PR intentionally does not:
The compatibility wrapper can be removed once all supported build environments contain the corrected ATK declarations.
Testing
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.